/**
 * 佳晨生物信息超算中心 - CSS 设计系统
 * 
 * 包含：
 * 1. Design Tokens（设计变量）
 * 2. 亮色/暗色/跟随系统 主题系统
 * 3. 基础排版
 * 4. 布局系统
 * 5. 核心组件样式
 */

/* ============================================
   1. 设计变量（Design Tokens）
   ============================================ */

:root {
    /* --- 品牌色 --- */
    --primary: #0066B3;
    --primary-light: #3395d6;
    --primary-dark: #004680;
    --primary-rgb: 0, 102, 179;
    
    --secondary: #0A8F8F;
    --secondary-light: #2db3b3;
    --secondary-dark: #066666;
    --secondary-rgb: 10, 143, 143;

    /* --- 语义色 --- */
    --success: #28a745;
    --success-light: #48c774;
    --success-dark: #1e7e34;
    --warning: #f0ad4e;
    --warning-light: #ffc107;
    --warning-dark: #d39e00;
    --danger: #dc3545;
    --danger-light: #f14668;
    --danger-dark: #bb2d2b;
    --info: #17a2b8;
    
    /* --- 中性色 --- */
    --dark: #1a2a3a;
    --dark-secondary: #2C3E50;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    /* --- 背景色 --- */
    --bg-primary: #ffffff;
    --bg-secondary: #F5F7FA;
    --bg-tertiary: #eef1f5;
    
    /* --- 文字色 --- */
    --text-primary: #1a2a3a;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --text-disabled: #adb5bd;
    
    /* --- 边框 --- */
    --border-color: #dee2e6;
    --border-color-light: #e9ecef;
    
    /* --- 阴影 --- */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.12);
    
    /* --- 圆角 --- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* --- 间距系统（基于 4px） --- */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;       /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    
    /* --- 字号系统 --- */
    --text-xs: 0.75rem;      /* 12px */
    --text-sm: 0.875rem;     /* 14px */
    --text-base: 1rem;       /* 16px */
    --text-lg: 1.125rem;     /* 18px */
    --text-xl: 1.25rem;      /* 20px */
    --text-2xl: 1.5rem;      /* 24px */
    --text-3xl: 1.875rem;    /* 30px */
    --text-4xl: 2.25rem;     /* 36px */
    
    /* --- 行高 --- */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;
    
    /* --- 过渡 --- */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
    
    /* --- 导航高度 --- */
    --navbar-height: 70px;
    
    /* --- 容器最大宽度 --- */
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1280px;
}


/* ============================================
   2. 暗色主题（Dark Mode）
   ============================================ */

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f0f23;
    
    --text-primary: #e8e8e8;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --text-disabled: #505050;
    
    --border-color: #2d2d44;
    --border-color-light: #252538;
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.7);
    
    /* 暗色主题下的卡片和内容 */
    --card-bg: #1e1e32;
    --input-bg: #252538;
    --hover-bg: rgba(255, 255, 255, 0.05);
}

/* 跟随系统偏好 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #1a1a2e;
        --bg-secondary: #16213e;
        --bg-tertiary: #0f0f23;
        
        --text-primary: #e8e8e8;
        --text-secondary: #b0b0b0;
        --text-muted: #808080;
        --text-disabled: #505050;
        
        --border-color: #2d2d44;
        --border-color-light: #252538;
        
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.6);
        
        --card-bg: #1e1e32;
        --input-bg: #252538;
        --hover-bg: rgba(255, 255, 255, 0.05);
    }
}


/* ============================================
   3. 基础排版
   ============================================ */

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Noto Sans SC', 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: var(--leading-tight);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}


/* ============================================
   4. 布局系统
   ============================================ */

/* 容器 */
.container-custom {
    width: 100%;
    max-width: var(--container-lg);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

@media (min-width: 768px) {
    .container-custom {
        padding: 0 var(--space-6);
    }
}

@media (min-width: 1024px) {
    .container-custom {
        padding: 0 var(--space-8);
    }
}

/* 卡片 */
.card-elevated {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color-light);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

/* 内容卡片 */
.content-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    border: 1px solid var(--border-color-light);
    transition: background-color var(--transition-normal), box-shadow var(--transition-normal);
}

@media (max-width: 768px) {
    .content-card {
        padding: var(--space-4);
        border-radius: var(--radius-md);
    }
}


/* ============================================
/* 统计卡片组件 - 大号 macOS 风格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    position: relative;
    background: #ffffff;
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    border: none;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: row;
    align-items: center;
    transition: all 0.2s ease;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    border-radius: 14px 14px 0 0;
}

.stat-card--blue::before   { background: linear-gradient(90deg, #007AFF, #5AC8FA); }
.stat-card--green::before  { background: linear-gradient(90deg, #34C759, #30D158); }
.stat-card--orange::before { background: linear-gradient(90deg, #FF9500, #FFCC00); }
.stat-card--purple::before { background: linear-gradient(90deg, #5856D6, #AF52DE); }

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

/* 左侧：图标 + 数值 + 标题 */
.stat-card__left {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 16px 18px 18px;
}

.stat-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-bottom: 10px;
}

.stat-card--blue .stat-card__icon   { background: rgba(0,122,255,0.1);  color: #007AFF; }
.stat-card--green .stat-card__icon  { background: rgba(52,199,89,0.1);   color: #34C759; }
.stat-card--orange .stat-card__icon { background: rgba(255,149,0,0.1);  color: #FF9500; }
.stat-card--purple .stat-card__icon { background: rgba(88,86,214,0.1);  color: #5856D6; }

.stat-card__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
    letter-spacing: -1px;
}

.stat-card--blue .stat-card__value   { color: #007AFF; }
.stat-card--green .stat-card__value  { color: #34C759; }
.stat-card--orange .stat-card__value { color: #FF9500; }
.stat-card--purple .stat-card__value { color: #5856D6; }

.stat-card__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1d29;
    margin-bottom: 2px;
    line-height: 1.3;
}

.stat-card__sublabel {
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #8E8E93;
}

/* 右侧：功能说明 */
.stat-card__right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px 18px 20px 0;
    gap: 6px;
}

.stat-card__desc {
    font-size: 0.75rem;
    color: #6c757d;
    line-height: 1.5;
}

.stat-card__action {
    font-size: 0.72rem;
    color: #8E8E93;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 兼容旧版 */
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-bottom: 14px; }
.stat-card .stat-value { font-size: 2.6rem; font-weight: 700; line-height: 1; margin-bottom: 6px; letter-spacing: -1px; }
.stat-card .stat-label { font-size: 0.95rem; font-weight: 600; color: #1a1d29; margin-bottom: 2px; }
.stat-card .stat-description { font-size: 0.75rem; color: #6c757d; margin-top: auto; padding-top: 8px; border-top: 1px solid rgba(0,0,0,0.05); }

/* 主题变体 */
.stat-card--primary::before { background: linear-gradient(90deg, #007AFF, #5AC8FA); }
.stat-card--primary .stat-icon { background: rgba(0,122,255,0.1); color: #007AFF; }
.stat-card--primary .stat-value { color: #007AFF; }

.stat-card--success::before { background: linear-gradient(90deg, #34C759, #30D158); }
.stat-card--success .stat-icon { background: rgba(52,199,89,0.1); color: #34C759; }
.stat-card--success .stat-value { color: #34C759; }

.stat-card--warning::before { background: linear-gradient(90deg, #FF9500, #FFCC00); }
.stat-card--warning .stat-icon { background: rgba(255,149,0,0.1); color: #FF9500; }
.stat-card--warning .stat-value { color: #FF9500; }

.stat-card--secondary::before { background: linear-gradient(90deg, #5856D6, #AF52DE); }
.stat-card--secondary .stat-icon { background: rgba(88,86,214,0.1); color: #5856D6; }
.stat-card--secondary .stat-value { color: #5856D6; }


/* ============================================
   6. 按钮组件
   ============================================ */

.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    gap: var(--space-2);
}

.btn-modern:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.3);
}

.btn-modern:active {
    transform: scale(0.98);
}

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

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

.btn-modern--secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-modern--secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.btn-modern--outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

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

.btn-modern--ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-modern--ghost:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.btn-modern--sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
}

.btn-modern--lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-base);
}


/* ============================================
   7. 主题切换组件
   ============================================ */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 4px;
    gap: 2px;
}

.theme-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: var(--text-sm);
}

.theme-toggle-btn:hover {
    color: var(--text-primary);
}

.theme-toggle-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}


/* ============================================
   8. 加载状态
   ============================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--gray-200) 0%,
        var(--gray-100) 50%,
        var(--gray-200) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ============================================
   9. 表格样式
   ============================================ */

.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-modern thead {
    background: var(--bg-secondary);
}

.table-modern th {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    padding: var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table-modern td {
    padding: var(--space-4);
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--border-color-light);
    vertical-align: middle;
}

.table-modern tbody tr {
    transition: background-color var(--transition-fast);
}

.table-modern tbody tr:hover {
    background: var(--hover-bg);
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}


/* ============================================
   10. 徽章/标签
   ============================================ */

.badge-modern {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-modern--success {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.badge-modern--warning {
    background: rgba(240, 173, 78, 0.1);
    color: var(--warning-dark);
}

.badge-modern--danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.badge-modern--info {
    background: rgba(23, 162, 184, 0.1);
    color: var(--info);
}

.badge-modern--primary {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}


/* ============================================
   11. 表单元素
   ============================================ */

.form-input-modern {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-input-modern:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-input-modern::placeholder {
    color: var(--text-disabled);
}

[data-theme="dark"] .form-input-modern,
:root:not([data-theme="light"]):not([data-theme]) .form-input-modern {
    background: var(--input-bg, #252538);
    border-color: var(--border-color);
}


/* ============================================
   12. 动画和过渡
   ============================================ */

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

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

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

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ============================================
   13. 工具类
   ============================================ */

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
