/**
 * CFM邮件数据看板 - 公共样式文件
 * 包含所有页面共享的CSS变量、组件样式和工具类
 */

/* ==================== CSS变量定义 ==================== */
:root {
    /* 主色调 - 冰川蓝 */
    --primary-color: #447793;
    --primary-light: #5a8aa6;
    --primary-lighter: #8bb0c4;
    --primary-dark: #2d5a74;
    
    /* 辅助色 - 晨雾紫 */
    --secondary-color: #9c7b98;
    --secondary-light: #b8a0b5;
    --secondary-lighter: #d4c5d2;
    
    /* 强调色 - 香槟金 */
    --accent-color: #c4b454;
    --accent-light: #d4c574;
    
    /* 状态色 */
    --success: #70b3a4;
    --success-light: #a8d4c9;
    --warning: #faad14;
    --warning-light: #fcd34d;
    --error: #d19a9a;
    --error-light: #e8c5c5;
    
    /* 背景色 */
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-hover: rgba(68, 119, 147, 0.08);
    --page-background: #f0f4f8;
    
    /* 文字色 */
    --text-primary: #262626;
    --text-secondary: #595959;
    --text-tertiary: #8c8c8c;
    --text-number: #1890ff;
    
    /* 边框 */
    --border-light: rgba(255, 255, 255, 0.5);
    --border-primary: rgba(68, 119, 147, 0.3);
    --card-border: #e8e8e8;
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    
    /* 玻璃拟态 */
    --glass-blur: blur(20px);
    
    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* 过渡 */
    --transition-fast: all 0.2s ease;
    --transition-base: all 0.3s ease;
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* 渐变 */
    --gradient-bg-light: linear-gradient(135deg, #f5f7fa 0%, #e8edf2 100%);
    --gradient-primary: linear-gradient(135deg, #447793 0%, #5a8aa6 100%);
}

/* ==================== 基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--gradient-bg-light);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
}

/* 背景装饰 */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(68, 119, 147, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(156, 123, 152, 0.1) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-20px, -20px); }
}

/* ==================== 导航菜单 ==================== */
.nav-menu-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
}

.nav-menu-trigger {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4);
    transition: all 0.3s ease;
    font-size: 20px;
}

.nav-menu-trigger:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.nav-menu-content {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--card-border);
    padding: 8px;
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s ease;
    transform-origin: bottom right;
}

.nav-menu-wrapper:hover .nav-menu-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.nav-menu-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-menu-item:hover {
    background: #f0f4f8;
    color: var(--primary-color);
}

.nav-menu-item i {
    width: 20px;
    margin-right: 10px;
    text-align: center;
}

.nav-menu-divider {
    height: 1px;
    background: var(--card-border);
    margin: 8px 0;
}

/* ==================== 玻璃拟态卡片 ==================== */
.metric-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-lg);
    transition: var(--transition-base);
}

.metric-card:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.metric-value {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 2rem;
}

.metric-title {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==================== 数据表格 ==================== */
.data-table {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-header {
    background: linear-gradient(135deg, rgba(68, 119, 147, 0.08) 0%, rgba(68, 119, 147, 0.03) 100%);
    font-weight: 600;
    color: var(--text-primary);
}

.table-row {
    transition: var(--transition-fast);
    animation: fadeInRow 0.3s ease forwards;
    opacity: 0;
}

.table-row:hover {
    background: var(--bg-hover);
}

@keyframes fadeInRow {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== 按钮样式 ==================== */
.time-filter-btn {
    transition: var(--transition-base);
    border-radius: var(--radius-md);
    padding: 8px 20px;
    font-weight: 500;
    border: 1px solid var(--border-primary);
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
}

.time-filter-btn.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md);
}

.time-filter-btn:hover:not(.active) {
    background: var(--bg-hover);
    border-color: var(--primary-light);
}

.tab-btn {
    transition: var(--transition-base);
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
}

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.tab-btn:hover:not(.active) {
    background: var(--bg-hover);
}

/* ==================== 滚动条 ==================== */
.scrollable-table {
    max-height: 300px;
    overflow-y: auto;
}

.scrollable-table::-webkit-scrollbar {
    width: 8px;
}

.scrollable-table::-webkit-scrollbar-track {
    background: rgba(68, 119, 147, 0.05);
    border-radius: var(--radius-sm);
}

.scrollable-table::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: var(--radius-sm);
}

.scrollable-table::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* ==================== 表单元素 ==================== */
.form-input {
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    padding: 8px 12px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(68, 119, 147, 0.2);
}

/* 开关 */
.switch, .toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input, .toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider, .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before, .toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider,
input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before,
input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* ==================== 状态标签 ==================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.status-badge.success {
    background-color: #f6ffed;
    color: var(--success);
    border: 1px solid #b7eb8f;
}

.status-badge.error {
    background-color: #fff2f0;
    color: var(--error);
    border: 1px solid #ffccc7;
}

.status-badge.warning {
    background-color: #fffbe6;
    color: var(--warning);
    border: 1px solid #ffe58f;
}

/* ==================== Toast 通知 ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 18px;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success { background: linear-gradient(135deg, #10b981, #059669); }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toast.info { background: linear-gradient(135deg, #3b82f6, #2563eb); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==================== 骨架屏 ==================== */
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, 
        rgba(68, 119, 147, 0.05) 25%, 
        rgba(68, 119, 147, 0.1) 50%, 
        rgba(68, 119, 147, 0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-md);
}

/* ==================== 模态框 ==================== */
.modal-overlay {
    animation: fadeIn 0.2s ease;
}

.modal-content {
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ==================== 图表容器 ==================== */
.chart-container {
    height: 300px;
    width: 100%;
}

.chart-3d-container {
    height: 400px;
    width: 100%;
}

/* ==================== 面板展开/收缩 ==================== */
.charts-grid-container {
    display: flex;
    gap: 1rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-panel {
    flex: 1;
    min-width: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.chart-panel:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.chart-panel.expanded {
    flex: 3;
    z-index: 10;
}

.chart-panel.collapsed {
    flex: 1;
}

.chart-panel::after {
    content: '\f065';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 16px;
    right: 16px;
    color: #bfbfbf;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chart-panel:hover::after {
    opacity: 1;
}

.chart-panel.expanded::after {
    content: '\f066';
    opacity: 1;
    color: var(--primary-color);
}

/* ==================== 工具类 ==================== */
.trend-up {
    color: var(--success);
    font-weight: 600;
}

.trend-down {
    color: var(--error);
    font-weight: 600;
}

.email-count {
    color: var(--primary-color);
    font-weight: 600;
}

/* 错误状态 */
.error-state {
    text-align: center;
    padding: 40px 20px;
}

.error-state .icon {
    font-size: 48px;
    color: #d19a9a;
    margin-bottom: 16px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state .icon {
    font-size: 48px;
    color: #bfbfbf;
    margin-bottom: 16px;
}

/* 页面加载遮罩 */
.page-loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--gradient-bg-light);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.page-loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* 数字动画效果 */
.metric-value.updating {
    transform: scale(1.1);
    color: #70b3a4;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .nav-menu-wrapper {
        bottom: 16px;
        right: 16px;
    }
    
    .nav-menu-trigger {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}
