/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 根变量定义 */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #16a34a;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --info-color: #0891b2;
    --ws-color: #25d366;
    --tg-color: #0088cc;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* 基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-color);
    min-height: 100vh;
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--shadow-md);
}

.header-content {
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* 卡片样式 */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: #f1f5f9;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* 特殊卡片头部颜色 */
.ws-header {
    background: linear-gradient(135deg, var(--ws-color), #20c55e);
    color: white;
}

.tg-header {
    background: linear-gradient(135deg, var(--tg-color), #0ea5e9);
    color: white;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background-color: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.input-group {
    display: flex;
    position: relative;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.btn-toggle {
    background: var(--border-color);
    border: 2px solid var(--border-color);
    border-left: none;
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-toggle:hover {
    background: #cbd5e1;
}

.help-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-export {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.loading-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* 导出网格布局 */
.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.export-card {
    transition: var(--transition);
}

.export-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* 结果区域样式 */
.result-area {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: #f8fafc;
}

.result-success {
    background: #f0fdf4;
    border-color: var(--success-color);
    color: #166534;
}

.result-error {
    background: #fef2f2;
    border-color: var(--error-color);
    color: #991b1b;
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.download-link:hover {
    background: var(--primary-color);
    color: white;
}

/* 日志样式 */
.log-container {
    max-height: 300px;
    overflow-y: auto;
    background: #1e293b;
    border-radius: var(--border-radius);
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.log-item {
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.log-time {
    color: #64748b;
    flex-shrink: 0;
}

.log-message {
    color: #e2e8f0;
}

.log-item.success .log-message {
    color: #22c55e;
}

.log-item.error .log-message {
    color: #ef4444;
}

.log-item.warning .log-message {
    color: #f59e0b;
}

.log-item.info .log-message {
    color: #3b82f6;
}

/* 通知弹窗样式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

.notification-content {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-close:hover {
    color: var(--text-primary);
}

.notification.success .notification-content {
    border-left: 4px solid var(--success-color);
}

.notification.error .notification-content {
    border-left: 4px solid var(--error-color);
}

.notification.warning .notification-content {
    border-left: 4px solid var(--warning-color);
}

.notification.info .notification-content {
    border-left: 4px solid var(--info-color);
}

/* 页脚样式 */
.footer {
    margin-top: 3rem;
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

/* 动画效果 */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .export-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .notification {
        left: 15px;
        right: 15px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 0;
    }
    
    .header h1 {
        font-size: 1.75rem;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .main-content {
        gap: 1.5rem;
    }
}

/* 滚动条样式 */
.log-container::-webkit-scrollbar {
    width: 6px;
}

.log-container::-webkit-scrollbar-track {
    background: #334155;
    border-radius: 3px;
}

.log-container::-webkit-scrollbar-thumb {
    background: #64748b;
    border-radius: 3px;
}

.log-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 加载状态样式 */
.btn.loading .btn-text {
    opacity: 0;
}

.btn.loading .loading-spinner {
    display: block;
}

/* 输入验证样式 */
.form-control.invalid {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgb(220 38 38 / 0.1);
}

.form-control.valid {
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgb(22 163 74 / 0.1);
}
