/**
 * 瑾佳文化传媒工作室 - 公共样式表
 * 统一的 CSS 变量系统和基础样式
 * @version 1.0.0
 */

/* ===== CSS Reset & 基础设置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* ===== 基础背景 ===== */
    --bg-base: #f5f7fb;
    --bg-elevated: rgba(255, 255, 255, 0.85);
    --bg-elevated-strong: rgba(255, 255, 255, 0.95);
    --bg-subtle: rgba(248, 250, 252, 0.6);
    
    /* ===== 文本层级（增强对比度） ===== */
    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-tertiary: #64748B;
    --text-quaternary: #94A3B8;
    --text-inverse: #FFFFFF;
    
    /* ===== 边框层级 ===== */
    --border-subtle: rgba(15, 23, 42, 0.06);
    --border-default: rgba(15, 23, 42, 0.10);
    --border-strong: rgba(15, 23, 42, 0.16);
    --border-focus: rgba(0, 102, 204, 0.45);
    
    /* ===== 阴影层级 ===== */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
    --shadow-2xl: 0 25px 50px -12px rgba(15, 23, 42, 0.15);
    --shadow-inner: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(135, 206, 235, 0.05);
    --shadow-glow: 0 0 0 3px rgba(0, 102, 204, 0.15);
    
    /* ===== 强调色 ===== */
    --accent-blue: #0066CC;
    --accent-blue-light: #87CEEB;
    --accent-blue-dark: #1E5BB8;
    --accent-blue-soft: rgba(0, 102, 204, 0.08);
    --accent-gold: #D4AF37;
    --accent-gold-dark: #B8960C;
    --accent-gold-soft: rgba(212, 175, 55, 0.12);
    
    /* ===== 渐变 ===== */
    --gradient-bg: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 25%, #f5f0ff 50%, #e0f0f5 75%, #f0f4ff 100%);
    --gradient-hero: linear-gradient(135deg, #FAFBFF 0%, #F0F5FB 50%, #FAFBFF 100%);
    --gradient-card: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.7) 100%);
    --gradient-shine: linear-gradient(90deg, transparent, rgba(135,206,235,0.4), rgba(212,175,55,0.3), transparent);
    
    /* ===== 排版系统 ===== */
    --font-sans: 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    
    --text-xs: 0.75rem;
    --text-sm: 0.85rem;
    --text-base: 0.95rem;
    --text-md: 1rem;
    --text-lg: 1.15rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
    --text-6xl: 4rem;
    
    --leading-tight: 1.2;
    --leading-snug: 1.4;
    --leading-normal: 1.6;
    --leading-relaxed: 1.75;
    --leading-loose: 2;
    
    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-wide: 0.05em;
    --tracking-wider: 0.1em;
    
    /* ===== 间距系统 ===== */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;
    
    /* ===== 圆角 ===== */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* ===== 动画 ===== */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-base: 300ms;
    --duration-slow: 500ms;
    --duration-slower: 800ms;
    
    /* ===== 焦点环 ===== */
    --focus-ring: 0 0 0 3px rgba(0, 102, 204, 0.25);
    --focus-ring-offset: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent-blue);
    
    /* ===== z-index 层级 ===== */
    --z-base: 1;
    --z-elevated: 10;
    --z-sticky: 100;
    --z-modal: 1000;
    --z-popover: 1001;
    --z-toast: 2000;
    --z-countdown: 9999;
    --z-login: 10000;
    
    /* ===== 布局 ===== */
    --sidebar-w: 220px;
}

/* ===== 深色模式变量 ===== */
[data-theme="dark"] {
    --bg-base: #0F172A;
    --bg-elevated: rgba(15, 23, 42, 0.85);
    --bg-elevated-strong: rgba(15, 23, 42, 0.95);
    --bg-subtle: rgba(30, 41, 59, 0.6);
    
    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-tertiary: #94A3B8;
    --text-quaternary: #64748B;
    
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);
    
    --gradient-bg: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    --gradient-card: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.7) 100%);
}

/* ===== 全局样式 ===== */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--gradient-bg);
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(135,206,235,0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(212,175,55,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(176,224,230,0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===== 滚动条优化 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { 
    background: rgba(135, 206, 235, 0.3); 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(135, 206, 235, 0.5); }

/* ===== 侧边栏 ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-elevated);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    backdrop-filter: blur(40px) saturate(180%);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-lg), var(--shadow-inner);
    will-change: transform;
    transition: transform var(--duration-slow) var(--ease-out), 
                background var(--duration-slow) ease, 
                border-color var(--duration-slow) ease;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, rgba(135,206,235,0.35) 0%, rgba(212,175,55,0.25) 50%, rgba(135,206,235,0.35) 100%);
    pointer-events: none;
}

.sidebar-header {
    padding: var(--space-6) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 0.125em;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-logo-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin: 0 auto 15px;
    display: block;
    border-radius: var(--radius-sm);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-5) 0;
}

.sidebar-nav ul,
.sidebar-nav-list {
    list-style: none;
}

.sidebar-nav li,
.sidebar-nav-item {
    margin: 2px 0;
}

.sidebar-nav a,
.sidebar-nav-link {
    display: block;
    padding: var(--space-3) var(--space-6);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    transition: all var(--duration-base) var(--ease-out);
    border-left: 3px solid transparent;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    position: relative;
}

.sidebar-nav a:hover,
.sidebar-nav-link:hover {
    background: rgba(255,255,255,0.8);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue-light);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.sidebar-nav a:focus-visible,
.sidebar-nav-link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.sidebar-nav a.active,
.sidebar-nav-link.active {
    color: var(--accent-blue);
    background: rgba(255,255,255,0.9);
    border-left-color: var(--accent-blue);
    font-weight: 600;
    box-shadow: var(--shadow-md), var(--shadow-inner);
}

[data-theme="dark"] .sidebar-nav a:hover,
[data-theme="dark"] .sidebar-nav-link:hover {
    background: rgba(30, 41, 59, 0.7);
}

[data-theme="dark"] .sidebar-nav a.active,
[data-theme="dark"] .sidebar-nav-link.active {
    background: rgba(30, 41, 59, 0.8);
}

.sidebar-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-subtle);
}

.copyright {
    font-size: var(--text-xs);
    color: var(--text-quaternary);
    letter-spacing: var(--tracking-wide);
}

/* ===== 主内容区 ===== */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    position: relative;
    z-index: var(--z-base);
}

/* ===== 移动端菜单按钮 ===== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: var(--space-4);
    left: var(--space-4);
    z-index: 1000;
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: var(--shadow-md), var(--shadow-inner);
    transition: all var(--duration-base) var(--ease-out);
}

.mobile-menu-toggle:hover {
    background: var(--bg-elevated-strong);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
    transition-duration: 0.15s;
}

.mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--accent-gold);
    margin: 4px auto;
    transition: var(--duration-base) var(--ease-out);
}

/* ===== 主题切换按钮 ===== */
.theme-toggle {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 10001;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-slow) var(--ease-out);
    box-shadow: var(--shadow-lg), var(--shadow-inner);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    overflow: hidden;
}

.theme-toggle::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(135,206,235,0.15), transparent, rgba(212,175,55,0.1), transparent);
    animation: themeGlow 6s linear infinite;
    opacity: 0.6;
    pointer-events: none;
}

@keyframes themeGlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.theme-toggle:hover {
    transform: scale(1.12);
    border-color: var(--border-default);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
    background: var(--bg-elevated-strong);
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.theme-toggle .theme-icon {
    font-size: 1.5rem;
    transition: transform var(--duration-base) var(--ease-spring);
}

.theme-toggle:hover .theme-icon {
    transform: rotate(20deg);
}

/* ===== 响应式断点 ===== */
/* 大屏（>1440） */
@media (min-width: 1440px) {
    :root {
        --sidebar-w: 240px;
    }
    body { font-size: 16px; }
}

/* 平板（769-1024） */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 200px;
    }
    body { font-size: 15px; }
}

/* 手机（<=768） */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 0px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 220px;
        box-shadow: var(--shadow-2xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .theme-toggle {
        bottom: var(--space-5);
        right: var(--space-5);
        width: 48px;
        height: 48px;
    }

    .theme-toggle .theme-icon {
        font-size: 1.25rem;
    }
}

/* 小屏手机（<=480） */
@media (max-width: 480px) {
    .theme-toggle {
        width: 44px;
        height: 44px;
        bottom: var(--space-4);
        right: var(--space-4);
    }
    body { font-size: 14px; }
}

/* 超小屏（<=360，如iPhone SE） */
@media (max-width: 360px) {
    :root {
        --space-4: 0.875rem;
        --space-6: 1.25rem;
    }
    body { font-size: 13px; }
}

/* 横屏手机（<=896宽 + landscape） */
@media (max-width: 896px) and (orientation: landscape) {
    .sidebar { width: 200px; }
    .mobile-menu-toggle { display: block; }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    button, a, [role="button"] {
        -webkit-tap-highlight-color: transparent;
    }
    .theme-toggle:hover { transform: none; }
    .theme-toggle:active { transform: scale(0.95); }
}

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

/* 打印样式 */
@media print {
    body { background: #fff; color: #000; animation: none; }
    .sidebar, .theme-toggle, .mobile-menu-toggle { display: none !important; }
    .main-content { margin-left: 0; }
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #666;
    }
}

/* ===== 图片懒加载优化 ===== */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity var(--duration-base) var(--ease-out);
}

img[loading="lazy"].loaded,
img[loading="lazy"][src] {
    opacity: 1;
}

/* ===== 无障碍优化 ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* ===== 打印样式 ===== */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .theme-toggle {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    body {
        background: white;
        color: black;
    }
}