/* ==================== 主题系统 ==================== */

/* 浅色主题（默认） */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --accent-gradient: linear-gradient(135deg, #4361ee, #3a56d4);
    --success-gradient: linear-gradient(135deg, #10b981, #059669);
    --warning-gradient: linear-gradient(135deg, #f59e0b, #d97706);
    --danger-gradient: linear-gradient(135deg, #ef4444, #dc2626);
}

/* 深色主题 */
[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: #262626;
    --bg-card-hover: #333333;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #333333;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
    --accent-gradient: linear-gradient(135deg, #667eea, #764ba2);
    --success-gradient: linear-gradient(135deg, #34d399, #10b981);
    --warning-gradient: linear-gradient(135deg, #fbbf24, #f59e0b);
    --danger-gradient: linear-gradient(135deg, #f87171, #ef4444);
}

/* 全局样式 */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 卡片样式 */
.card, .welcome-card, .unread-section, .health-card, .settings-card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 文字颜色 */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
}

.text-muted, .text-secondary {
    color: var(--text-secondary);
}

/* 输入框样式 */
input, textarea, select {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

/* 按钮样式 */
.btn-primary {
    background: var(--accent-gradient);
}

.btn-success {
    background: var(--success-gradient);
}

.btn-warning {
    background: var(--warning-gradient);
}

.btn-danger {
    background: var(--danger-gradient);
}

/* 边框和阴影 */
.border {
    border-color: var(--border-color) !important;
}

.shadow-sm {
    box-shadow: var(--shadow-sm);
}

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

.shadow-lg {
    box-shadow: var(--shadow-lg);
}

/* 消息列表 */
.message-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

.message-item:hover {
    background-color: var(--bg-card-hover);
}

.message-item.unread {
    background: linear-gradient(90deg, rgba(67, 97, 238, 0.1), var(--bg-card));
}

/* 模态框 */
.modal-content {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* Toast */
.toast {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.toast-header {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* 表格 */
table {
    color: var(--text-primary);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--bg-secondary);
}

/* 深色主题特定优化 */
[data-theme="dark"] .welcome-card {
    background: linear-gradient(135deg, #065f46, #064e3b);
}

[data-theme="dark"] .stat-icon,
[data-theme="dark"] .quick-action-btn {
    filter: brightness(1.2);
}

[data-theme="dark"] img {
    filter: brightness(0.9);
}

/* 主题切换按钮 */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 25px -5px rgba(0,0,0,0.3);
}

[data-theme="dark"] .theme-toggle {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

/* Toast 消息深色主题样式 */
[data-theme="dark"] .toast {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

[data-theme="dark"] .toast-body {
    color: var(--text-primary) !important;
}

/* 主题切换容器 */
.theme-toggle-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 9998;
}

/* 主题菜单按钮 */
.theme-menu-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-menu-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

/* 主题菜单 */
.theme-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.theme-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 菜单项 */
.theme-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.theme-menu-item:hover {
    background: var(--bg-secondary);
}

.theme-menu-item.active {
    background: var(--primary);
    color: white;
}

.theme-menu-item i {
    font-size: 1.25rem;
}

.theme-menu-item span {
    font-weight: 500;
    font-size: 0.95rem;
}

/* 响应式 - 移动端 */
@media (max-width: 768px) {
    .theme-toggle-container {
        bottom: 90px;
        right: 15px;
    }
    
    .theme-toggle,
    .theme-menu-btn {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
    
    .theme-menu {
        min-width: 160px;
    }
}
