/* =====================================================================
 * Foliage v1.0 Design Tokens — tokens.css
 * 基于 v0.9.72 tokens.css · 搬运 + 微升级 · 2026-06-11
 *
 * 升级:
 *   - 品牌蓝 #4f8cff → #5b9aff (+8% 饱和度)
 *   - 卡片圆角 14px → 16px
 *   - 卡片内边距新增 --space-7: 28px
 *   - 毛玻璃 blur 12px → 16px
 *   - Light 主题合并为单一定义 (清理冗余)
 *   - Vue SPA token 统一为 -- 前缀 (取消 --v- 前缀)
 * ===================================================================== */

/* =====================================================================
 * §1 默认主题 (Dark)
 * ===================================================================== */
:root {
  /* --- 背景 --- */
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --surface-3: #2e3348;
  --surface-accent: rgba(34, 197, 94, 0.15);

  /* --- 边框 --- */
  --border: #2e3348;
  --border-strong: #3a4055;

  /* --- 文字 --- */
  --text: #e1e4ed;
  --text-muted: #c5c9d4;
  --text-dim: #8b90a0;
  --text-inverse: #fff;

  /* --- 品牌 --- */
  --accent: #5b9aff;             /* v1.0: +8% 饱和度 */
  --accent-hover: #7ab4ff;
  --accent-deep: #3a7de0;
  --accent-btn: #3a7de0;
  --accent-link: #7ab4ff;
  --accent-soft: rgba(91, 154, 255, 0.15);
  --accent-soft-2: rgba(91, 154, 255, 0.08);
  --accent-glow: rgba(91, 154, 255, 0.30);
  --premium: #a78bfa;

  /* --- 渐变 --- */
  --gradient: linear-gradient(135deg, #5b9aff 0%, #a78bfa 100%);
  --gradient-soft: linear-gradient(135deg, rgba(91,154,255,0.15) 0%, rgba(167,139,250,0.15) 100%);

  /* --- 涨跌 (CN 默认) --- */
  --up-color: #ef4444;
  --down-color: #22c55e;
  --up-bg: rgba(239, 68, 68, 0.12);
  --down-bg: rgba(34, 197, 94, 0.12);

  /* --- 语义色 --- */
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --purple: #a78bfa;
  --neutral: #fbbf24;
  --danger: var(--red);
  --success: var(--green);
  --warning: var(--yellow);

  /* --- 毛玻璃 v1.0: blur 16px --- */
  --glass-bg: rgba(26, 29, 39, 0.6);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-blur: blur(16px);

  /* --- 阴影 --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 24px rgba(91, 154, 255, 0.25);
  --shadow-overlay: rgba(0, 0, 0, 0.35);
  --shadow-deep: rgba(0, 0, 0, 0.45);

  /* --- 圆角 v1.0: radius-md 16px --- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* --- 间距 v1.0: 新增 space-7 --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* --- 字号 --- */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.05rem;
  --text-xl: 1.2rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;

  /* --- 字体 --- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Consolas, "Monaco", monospace;
  --font-display: var(--font-sans);

  /* --- 字重 --- */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-black: 800;

  /* --- 行高 --- */
  --leading-tight: 1.25;
  --leading-snug: 1.4;
  --leading-normal: 1.7;
  --leading-relaxed: 1.75;

  /* --- 过渡 --- */
  --transition-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* --- Z-index --- */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal: 9999;
  --z-toast: 10000;

  /* --- 布局 --- */
  --container: 1100px;
  --container-wide: 1320px;
  --header-height: 64px;
  --radius-button: 10px;
  --radius-card: 16px;

  /* ===================================================================
   * §2 语义层 Token (Semantic)
   * =================================================================== */
  --color-primary: var(--accent);
  --color-primary-hover: var(--accent-hover);
  --color-primary-deep: var(--accent-deep);
  --color-success: var(--badge-success, #16a34a);
  --color-success-bg: rgba(22, 163, 74, 0.12);
  --color-danger: var(--badge-danger, #ef4444);
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  --color-warning: var(--yellow);
  --color-warning-bg: rgba(251, 191, 36, 0.13);
  --color-info: var(--accent);
  --color-info-bg: var(--accent-soft);

  /* 业务色 */
  --metric-positive: #059669;
  --metric-positive-bg: rgba(5, 150, 105, 0.1);
  --metric-negative: #dc2626;
  --metric-negative-bg: rgba(220, 38, 38, 0.1);
  --metric-baseline: #2563eb;
  --metric-baseline-bg: rgba(37, 99, 235, 0.08);
  --metric-neutral: #6b7280;

  --status-ok: #22c55e;
  --status-ok-bg: rgba(34, 197, 94, 0.13);
  --status-warn: #eab308;
  --status-warn-bg: rgba(234, 179, 8, 0.13);
  --status-degraded: #f97316;
  --status-degraded-bg: rgba(249, 115, 22, 0.13);
  --status-error: #ef4444;
  --status-error-bg: rgba(239, 68, 68, 0.13);

  /* --- DOCS-002 V1 修复: badge 业务状态色 (CN 风格: 成功=绿, 危险=红) --- */
  /* 修复前: .badge-success 误用 var(--up-color) (CN 红), 与"成功"语义冲突 */
  --badge-success: #16a34a;
  --badge-success-bg: rgba(22, 163, 74, 0.12);
  --badge-warning: #eab308;
  --badge-warning-bg: rgba(234, 179, 8, 0.12);
  --badge-danger: #ef4444;
  --badge-danger-bg: rgba(239, 68, 68, 0.12);
  --badge-info: #3b82f6;
  --badge-info-bg: rgba(59, 130, 246, 0.12);

  /* 报告/打印 */
  --report-text-strong: #222;
  --report-border-soft: #e0e0e0;
  --report-hover-bg: #e8f0fe;
  --report-bg-soft: #f8f9fa;
  --report-bg-table-even: #fafbfc;

  /* ECharts 雷达图 */
  --radar-tech: #60a5fa;
  --radar-inst: #818cf8;
  --radar-concept: #f472b6;
  --radar-value: #22d3ee;

  /* Fib 图表 */
  --fib-line: rgba(167, 139, 250, 0.45);
  --fib-confluence: rgba(91, 154, 255, 0.6);
  --fib-time-window: rgba(251, 191, 36, 0.35);

  /* ===================================================================
   * §3 意图层 Token (Intent)
   * =================================================================== */
  --bg-button-primary: var(--accent-btn);
  --bg-button-primary-hover: var(--accent-hover);
  --bg-button-secondary: var(--surface-2);
  --bg-button-danger: var(--red);
  --bg-button-success: var(--green);
  --text-button-primary: var(--text-inverse);
  --text-link: var(--accent-link);
  --text-link-hover: var(--accent-hover);
  --border-input-focus: var(--accent);
  --border-input-error: var(--red);
  --bg-input-focus: var(--accent-soft);
  --bg-surface-danger: var(--down-bg);
  --bg-surface-success: var(--up-bg);
  --bg-surface-warning: rgba(251, 191, 36, 0.08);
  --bg-surface-info: var(--accent-soft);
  --text-feedback-error: var(--red);
  --text-feedback-success: var(--green);
  --text-feedback-warning: var(--yellow);

  --scrim: rgba(0, 0, 0, 0.55);
  --bg-light-page: #fafbfc;
  --border-input: #e5e7eb;
  --accent-soft-2: rgba(91, 154, 255, 0.08);
  --accent-soft-3: rgba(91, 154, 255, 0.32);
}


/* =====================================================================
 * §4 Light 主题 (合并为单一定义)
 * v1.0 T14 扩展: 补全 text-inverse / premium / accent-soft-2/3 / metric-* /
 *   status-* / badge-* / fib-* / radar-* 等业务色
 * ===================================================================== */
[data-theme="light"] {
  --bg: #fafbfc;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --surface-3: #e7eaf0;
  --border: #e1e4e8;
  --border-strong: #c8ccd1;

  --text: #1a1d27;
  --text-muted: #3d4151;
  --text-dim: #5b6072;
  --text-inverse: #ffffff;          /* v1.0 Light: 反转文字色 (按钮上文字) */

  --accent: #2d6cdf;
  --accent-hover: #1a4a99;
  --accent-soft: rgba(45, 108, 223, 0.10);
  --accent-soft-2: rgba(45, 108, 223, 0.06);
  --accent-soft-3: rgba(45, 108, 223, 0.32);
  --accent-glow: rgba(45, 108, 223, 0.20);
  --accent-deep: #1a4a99;
  --accent-btn: #2d6cdf;
  --accent-link: #2d6cdf;
  --premium: #7c3aed;                /* v1.0 Light: Pro 标识紫色加深 */

  --gradient: linear-gradient(135deg, #2d6cdf 0%, #8b5cf6 100%);
  --gradient-soft: linear-gradient(135deg, rgba(45,108,223,0.12) 0%, rgba(139,92,246,0.12) 100%);

  --up-color: #b91c1c;
  --down-color: #15803d;
  --up-bg: rgba(239, 68, 68, 0.08);
  --down-bg: rgba(34, 197, 94, 0.08);

  --green: #10b981;
  --red: #ef4444;
  --yellow: #92400e;
  --orange: #9a3412;
  --purple: #7c3aed;
  --neutral: #92400e;
  --danger: var(--red);
  --success: var(--green);
  --warning: var(--yellow);

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-blur: blur(16px);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 24px rgba(45, 108, 223, 0.20);
  --shadow-overlay: rgba(15, 17, 23, 0.45);
  --shadow-deep: rgba(15, 17, 23, 0.55);

  /* ECharts 雷达图 (Light 下微调对比度) */
  --radar-tech: #3b82f6;
  --radar-inst: #6366f1;
  --radar-concept: #ec4899;
  --radar-value: #0891b2;

  /* Fib 图表 (Light 用更深的紫色确保可读) */
  --fib-line: rgba(124, 58, 237, 0.45);
  --fib-confluence: rgba(45, 108, 223, 0.6);
  --fib-time-window: rgba(146, 64, 14, 0.35);

  /* Semantic 业务色 (Light 适配) */
  --color-warning: var(--yellow);
  --color-warning-bg: rgba(146, 64, 14, 0.10);
  --color-info: var(--accent);
  --color-info-bg: var(--accent-soft);

  --metric-positive: #047857;
  --metric-positive-bg: rgba(4, 120, 87, 0.10);
  --metric-negative: #b91c1c;
  --metric-negative-bg: rgba(185, 28, 28, 0.10);
  --metric-baseline: #1d4ed8;
  --metric-baseline-bg: rgba(29, 78, 216, 0.08);
  --metric-neutral: #6b7280;

  --status-ok: #15803d;
  --status-ok-bg: rgba(21, 128, 61, 0.13);
  --status-warn: #92400e;
  --status-warn-bg: rgba(146, 64, 14, 0.13);
  --status-degraded: #c2410c;
  --status-degraded-bg: rgba(194, 65, 12, 0.13);
  --status-error: #b91c1c;
  --status-error-bg: rgba(185, 28, 28, 0.13);

  --badge-success: #15803d;
  --badge-success-bg: rgba(21, 128, 61, 0.12);
  --badge-warning: #92400e;
  --badge-warning-bg: rgba(146, 64, 14, 0.12);
  --badge-danger: #b91c1c;
  --badge-danger-bg: rgba(185, 28, 28, 0.12);
  --badge-info: #1d4ed8;
  --badge-info-bg: rgba(29, 78, 216, 0.12);

  --scrim: rgba(15, 17, 23, 0.45);
  --bg-light-page: #fafbfc;
  --border-input: #d1d5db;
}


/* =====================================================================
 * §5 系统自动跟随 (prefers-color-scheme)
 * ===================================================================== */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg: #fafbfc;
    --surface: #ffffff;
    --surface-2: #f1f3f5;
    --surface-3: #e7eaf0;
    --border: #e1e4e8;
    --text: #1a1d27;
    --text-muted: #5b6072;
    --accent-link: #2d6cdf;
    --accent-btn: #2d6cdf;
    --accent: #2d6cdf;
  }
}


/* =====================================================================
 * §6 Global 涨跌覆盖 (data-color-scheme="gl")
 * ===================================================================== */
[data-color-scheme="gl"] {
  --up-color: #34d399;
  --down-color: #f87171;
  --up-bg: rgba(52, 211, 153, 0.12);
  --down-bg: rgba(248, 113, 113, 0.12);
  --green: #34d399;
  --red: #f87171;
}

[data-theme="light"][data-color-scheme="gl"] {
  --up-color: #047857;
  --down-color: #b91c1c;
  --up-bg: rgba(16, 185, 129, 0.08);
  --down-bg: rgba(239, 68, 68, 0.08);
  --green: #047857;
  --red: #b91c1c;
}


/* =====================================================================
 * §7 主题切换平滑过渡
 * ===================================================================== */
html, body, .card, .btn, .nav-item, .surface-2, .modal-overlay-full,
input, textarea, select, [class*="bg-"], [class*="text-"] {
  transition: background-color 0.3s ease, color 0.3s ease,
              border-color 0.3s ease, box-shadow 0.3s ease;
}


/* =====================================================================
 * §8 无障碍: 减少动效偏好
 * ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* =====================================================================
 * §9 全局基础
 * ===================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "kern" 1;
}

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

img, svg, video {
  display: block;
  max-width: 100%;
}

/* Focus visible (a11y) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Skip to content (a11y) */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semibold);
}
.skip-to-content:focus {
  top: var(--space-2);
}
