/**
 * Design Tokens
 * 同时支持浅色 / 暗色（prefers-color-scheme）。
 * 所有页面（C端 / 客户经理 / Boss / 登录）一律使用变量，避免硬编码。
 */

:root {
  /* ========================================
     色彩系统 - 浅色主题
     ======================================== */

  /* 表面 / 背景 */
  --bg-page: #F5F6F8;
  --bg-card: #FFFFFF;
  --bg-secondary: #F2F4F7;
  --bg-tertiary: #E8EAF0;
  --bg-hover: #F0F1F3;
  --bg-active: #E8E9EB;
  --bg-overlay: rgba(0, 0, 0, 0.45);

  /* 文字 */
  --text-primary: #1A1D29;
  --text-secondary: #4B5163;
  --text-tertiary: #8A8FA3;
  --text-quaternary: #B5B8C4;
  --text-placeholder: #B5B8C4;
  --text-on-primary: #FFFFFF;        /* 在主色/反色背景上的可读文字 */

  /* 边框 / 分隔线 */
  --border-color: #E2E5EB;
  --border-light: #ECEEF2;
  --border-strong: #C9CDD7;

  /* A股习惯：红涨绿跌 */
  --color-up: #E94B3C;
  --color-up-bg: rgba(233, 75, 60, 0.10);
  --color-up-bg-strong: rgba(233, 75, 60, 0.18);
  --color-down: #00C48C;
  --color-down-bg: rgba(0, 196, 140, 0.10);
  --color-down-bg-strong: rgba(0, 196, 140, 0.18);

  /* 强调色（品牌） */
  --color-primary: #00BFA5;
  --color-primary-dark: #00A896;
  --color-primary-bg: rgba(0, 191, 165, 0.10);

  /* 语义状态色 - 浅色用浅底深字，暗色用深底亮字 */
  --status-success-bg: #DCFCE7;
  --status-success-text: #15803D;
  --status-success-border: #BBF7D0;

  --status-warning-bg: #FEF3C7;
  --status-warning-text: #B45309;
  --status-warning-border: #FCD34D;

  --status-danger-bg: #FEE2E2;
  --status-danger-text: #B91C1C;
  --status-danger-border: #FCA5A5;

  --status-info-bg: #DBEAFE;
  --status-info-text: #1D4ED8;
  --status-info-border: #BFDBFE;

  --status-neutral-bg: #F1F2F4;
  --status-neutral-text: #6B7280;
  --status-neutral-border: #E5E7EB;

  /* 选填强调色 */
  --color-warning: #F59E0B;
  --color-warning-bg: rgba(245, 158, 11, 0.10);
  --color-purple: #6366F1;

  /* 头像渐变（在两套主题下都能看清） */
  --avatar-gradient: linear-gradient(135deg, #3B82F6, #1D4ED8);
  --avatar-text: #FFFFFF;

  /* 反色按钮（"主操作"使用） */
  --invert-bg: #1A1D29;
  --invert-bg-hover: #2C3041;
  --invert-text: #FFFFFF;

  /* ========================================
     字体系统
     ======================================== */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Menlo", monospace;

  --text-4xl: 36px;
  --text-3xl: 28px;
  --text-2xl: 24px;
  --text-xl: 20px;
  --text-lg: 17px;
  --text-base: 15px;
  --text-sm: 13px;
  --text-xs: 12px;
  --text-xxs: 11px;

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  --leading-tight: 1.2;
  --leading-normal: 1.4;
  --leading-relaxed: 1.6;

  /* ========================================
     间距 / 圆角 / 阴影
     ======================================== */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* ========================================
     过渡 / 布局
     ======================================== */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;

  --phone-width: 390px;
  --header-height: 56px;
  --nav-height: 60px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);

  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;

  --stock-icon-sm: 36px;
  --stock-icon-md: 44px;
  --stock-icon-lg: 56px;

  --chart-mini-width: 64px;
  --chart-mini-height: 32px;
}

/* ============================================================
   暗色模式 - 全套覆盖
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    /* 表面 / 背景 */
    --bg-page: #0D0D0F;
    --bg-card: #18181B;
    --bg-secondary: #1F1F23;
    --bg-tertiary: #27272A;
    --bg-hover: #232328;
    --bg-active: #2D2D32;
    --bg-overlay: rgba(0, 0, 0, 0.65);

    /* 文字 */
    --text-primary: #F5F5F7;
    --text-secondary: #C7C9D1;
    --text-tertiary: #8B8E99;
    --text-quaternary: #56585F;
    --text-placeholder: #56585F;
    --text-on-primary: #0D0D0F;

    /* 边框 */
    --border-color: #2A2A2E;
    --border-light: #232327;
    --border-strong: #3A3A3F;

    /* A股 红涨绿跌（暗色下提亮） */
    --color-up: #F87171;
    --color-up-bg: rgba(248, 113, 113, 0.14);
    --color-up-bg-strong: rgba(248, 113, 113, 0.24);
    --color-down: #4ADE80;
    --color-down-bg: rgba(74, 222, 128, 0.14);
    --color-down-bg-strong: rgba(74, 222, 128, 0.24);

    /* 品牌 */
    --color-primary: #2DD4BF;
    --color-primary-dark: #14B8A6;
    --color-primary-bg: rgba(45, 212, 191, 0.14);

    /* 语义状态色 - 暗色用半透明 + 亮文字 */
    --status-success-bg: rgba(34, 197, 94, 0.18);
    --status-success-text: #4ADE80;
    --status-success-border: rgba(34, 197, 94, 0.35);

    --status-warning-bg: rgba(251, 191, 36, 0.18);
    --status-warning-text: #FBBF24;
    --status-warning-border: rgba(251, 191, 36, 0.35);

    --status-danger-bg: rgba(239, 68, 68, 0.18);
    --status-danger-text: #F87171;
    --status-danger-border: rgba(239, 68, 68, 0.35);

    --status-info-bg: rgba(96, 165, 250, 0.18);
    --status-info-text: #93C5FD;
    --status-info-border: rgba(96, 165, 250, 0.35);

    --status-neutral-bg: rgba(255, 255, 255, 0.06);
    --status-neutral-text: #A1A1AA;
    --status-neutral-border: rgba(255, 255, 255, 0.12);

    --color-warning: #FBBF24;
    --color-warning-bg: rgba(251, 191, 36, 0.16);

    /* 头像 */
    --avatar-gradient: linear-gradient(135deg, #60A5FA, #2563EB);

    /* 反色按钮 - 暗色下用亮色 */
    --invert-bg: #F5F5F7;
    --invert-bg-hover: #E4E4E7;
    --invert-text: #0D0D0F;

    --shadow-sm: none;
    --shadow-card: 0 0 0 1px var(--border-color);
    --shadow-elevated: 0 0 0 1px var(--border-color), 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-modal: 0 0 0 1px var(--border-color), 0 16px 48px rgba(0, 0, 0, 0.6);
  }

  /* 默认表单控件 */
  input, select, textarea {
    color-scheme: dark;
  }
}
