/**
 * 主题切换系统 - 企业级设计
 * 支持日间/夜间模式
 */

/* ==================== 日间模式（默认） ==================== */
:root, [data-theme="light"] {
    --theme-bg-body: #f1f5f9;
    --theme-bg-card: #ffffff;
    --theme-bg-sidebar: #1e293b;
    --theme-text-primary: #1e293b;
    --theme-text-secondary: #64748b;
    --theme-border: #e2e8f0;
}

/* ==================== 夜间模式 ==================== */
[data-theme="dark"] {
    --theme-bg-body: #0f172a;
    --theme-bg-card: #1e293b;
    --theme-bg-sidebar: #0f172a;
    --theme-text-primary: #f1f5f9;
    --theme-text-secondary: #94a3b8;
    --theme-border: #334155;
    
    /* 覆盖主色板 */
    --primary-50: #1e3a5f;
    --primary-100: #1e3a5f;
    --gray-50: #1e293b;
    --gray-100: #334155;
    --gray-200: #475569;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --border-color: #334155;
}

/* 夜间模式全局调整 */
[data-theme="dark"] body {
    background: var(--theme-bg-body);
    color: var(--theme-text-primary);
}

[data-theme="dark"] .login-page {
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
}

[data-theme="dark"] .login-box,
[data-theme="dark"] .card,
[data-theme="dark"] .topbar,
[data-theme="dark"] .modal-content {
    background: var(--theme-bg-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .sidebar {
    background: var(--theme-bg-sidebar);
    border-right: 1px solid var(--theme-border);
}

[data-theme="dark"] .table th {
    background: var(--gray-100);
    color: var(--theme-text-secondary);
}

[data-theme="dark"] .table td {
    border-color: var(--theme-border);
}

[data-theme="dark"] .table tbody tr:hover {
    background: var(--gray-100);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .form-group select {
    background: var(--gray-100);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group textarea:focus,
[data-theme="dark"] .form-group select:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .btn-secondary {
    background: var(--gray-200);
    color: var(--theme-text-primary);
}

[data-theme="dark"] .btn-outline {
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

[data-theme="dark"] .collapsible-header {
    background: var(--gray-100);
}

[data-theme="dark"] .collapsible-content {
    border-color: var(--theme-border);
}

[data-theme="dark"] .stat-card {
    background: var(--theme-bg-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--theme-border);
}

[data-theme="dark"] .card-footer {
    background: var(--gray-100);
}

[data-theme="dark"] .bulk-actions {
    background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .file-upload {
    background: var(--gray-100);
    border-color: var(--theme-border);
}

[data-theme="dark"] .file-upload:hover,
[data-theme="dark"] .file-upload.dragover {
    background: var(--primary-50);
    border-color: var(--primary-400);
}

[data-theme="dark"] .alert {
    border-left-width: 3px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--gray-100);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--gray-300);
}

/* ==================== 主题切换按钮 ==================== */
.theme-switcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 90;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    font-size: 14px;
    color: var(--text-primary);
}

.theme-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .theme-toggle-btn {
    background: var(--theme-bg-card);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

/* ==================== 主题切换通知 ==================== */
.theme-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-600);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
}

.theme-notification.show {
    opacity: 1;
}

/* ==================== 过渡动画 ==================== */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
    transition: background-color 0.3s, border-color 0.3s, color 0.3s !important;
}

/* ==================== 响应式调整 ==================== */
@media (max-width: 768px) {
    .theme-switcher {
        bottom: 16px;
        right: 16px;
    }
    
    .theme-toggle-btn {
        padding: 8px 12px;
    }
    
    .theme-toggle-btn .theme-text {
        display: none;
    }
}