/* ============================================================================
   TigerAI Cloud — Design Tokens
   ----------------------------------------------------------------------------
   萃取自 landing-page/cloud 前端（Tailwind v4 + Inter，深色玻璃擬態風格）。
   這是設計系統的「單一真實來源」。任何專案都能直接 import 這個檔案使用。

   分層：
     1. Primitive tokens  — 原始色票/數值（--c-*, --gray-*…），不帶語意
     2. Semantic tokens   — 帶語意的別名（--color-bg, --color-accent…），UI 應只用這層
   ========================================================================== */

:root {
  color-scheme: dark;

  /* ── Primitive · 中性灰階 ─────────────────────────────────────────── */
  --gray-50: #f9fafb;
  --gray-950: #030712;
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --white: #ffffff;
  --black: #000000;

  /* ── Primitive · 品牌主色 Indigo ──────────────────────────────────── */
  --indigo-950: #1e1b4b;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --indigo-400: #818cf8;
  --indigo-300: #a5b4fc;

  /* ── Primitive · 行動/成功 Emerald ────────────────────────────────── */
  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-400: #34d399;

  /* ── Primitive · 危險 Red ─────────────────────────────────────────── */
  --red-500: #ef4444;
  --red-400: #f87171;

  /* ── Primitive · 警告 Amber ───────────────────────────────────────── */
  --amber-500: #f59e0b;
  --amber-400: #fbbf24;

  /* ── Semantic · 背景與表面 ────────────────────────────────────────── */
  --color-bg: var(--gray-950);                  /* 頁面底色 */
  --color-surface: var(--gray-900);             /* 實心面板（sidebar、modal） */
  --color-surface-glass: rgb(255 255 255 / 0.05); /* 玻璃卡片 */
  --color-surface-inset: rgb(0 0 0 / 0.30);     /* 卡片內凹區塊 */
  --color-surface-muted: rgb(17 24 39 / 0.5);   /* 表格/分頁容器底 */
  --color-overlay: rgb(0 0 0 / 0.60);           /* modal 遮罩 */

  /* 互動狀態底色（會隨主題切換） */
  --color-hover: rgb(255 255 255 / 0.05);        /* 列 / 連結 hover */
  --color-hover-strong: rgb(255 255 255 / 0.10); /* icon 按鈕 hover */
  --color-field: rgb(17 24 39 / 0.8);            /* 一般輸入框底 */
  --color-field-solid: var(--gray-800);          /* modal 內實心輸入框底 */
  --color-disabled-bg: rgb(55 65 81 / 0.5);      /* 失效按鈕底 */

  /* ── Semantic · 邊框 ──────────────────────────────────────────────── */
  --color-border: rgb(255 255 255 / 0.10);      /* 預設邊框 */
  --color-border-subtle: rgb(255 255 255 / 0.05); /* 更淡的分隔線 */
  --color-border-strong: rgb(255 255 255 / 0.30); /* hover 強調邊框 */

  /* ── Semantic · 文字 ──────────────────────────────────────────────── */
  --color-text: var(--white);                   /* 主要文字 */
  --color-text-secondary: var(--gray-400);      /* 次要文字 */
  --color-text-muted: var(--gray-500);          /* 提示/標籤 */
  --color-text-disabled: var(--gray-600);       /* 失效文字 */

  /* ── Semantic · 互動色（含玻璃底/邊框） ───────────────────────────── */
  --color-accent: var(--indigo-500);            /* 品牌主色 */
  --color-accent-text: var(--indigo-400);       /* 主色文字/icon */
  --color-accent-bg: rgb(99 102 241 / 0.20);    /* 主色玻璃底 */
  --color-accent-border: rgb(99 102 241 / 0.30);

  --color-action: var(--emerald-600);           /* 主要按鈕 */
  --color-action-hover: var(--emerald-500);
  --color-action-text: var(--emerald-400);
  --color-action-bg: rgb(16 185 129 / 0.20);
  --color-action-border: rgb(16 185 129 / 0.30);

  --color-danger: var(--red-500);
  --color-danger-text: var(--red-400);
  --color-danger-bg: rgb(239 68 68 / 0.10);
  --color-danger-border: rgb(239 68 68 / 0.30);

  --color-warning-text: var(--amber-400);
  --color-warning-bg: rgb(251 191 36 / 0.10);
  --color-warning-border: rgb(251 191 36 / 0.30);

  /* ── Typography ───────────────────────────────────────────────────── */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, monospace;

  --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 */

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* ── Spacing（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 */

  /* ── Border radius ────────────────────────────────────────────────── */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.5rem;    /* 8px  — 輸入框、小按鈕 */
  --radius-lg: 0.75rem;   /* 12px — 按鈕、icon 容器 */
  --radius-xl: 1rem;      /* 16px — 卡片、modal */
  --radius-full: 9999px;  /* 藥丸/圓點 */

  /* ── Shadows ──────────────────────────────────────────────────────── */
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.5);
  --shadow-glow-action: 0 10px 25px -5px rgb(16 185 129 / 0.25); /* emerald 光暈 */
  --shadow-glow-accent: 0 10px 25px -5px rgb(99 102 241 / 0.25); /* indigo 光暈 */

  /* ── Motion ───────────────────────────────────────────────────────── */
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Effects ──────────────────────────────────────────────────────── */
  --blur-glass: 8px; /* backdrop-blur-sm */

  /* ── 品牌漸層背景 ─────────────────────────────────────────────────── */
  --gradient-bg: linear-gradient(
    to bottom right,
    rgb(30 27 75 / 0.40),
    var(--gray-950) 50%,
    var(--gray-950)
  );
}

/* ============================================================================
   Light theme — 只覆寫會變的「語意」token，primitive 不動。
   以 <html data-theme="light"> 啟用。
   ========================================================================== */
[data-theme="light"] {
  color-scheme: light;

  --color-bg: var(--gray-50);
  --color-surface: var(--white);
  --color-surface-glass: rgb(255 255 255 / 0.70);
  --color-surface-inset: rgb(0 0 0 / 0.04);
  --color-surface-muted: rgb(255 255 255 / 0.70);
  --color-overlay: rgb(0 0 0 / 0.40);

  --color-border: rgb(0 0 0 / 0.10);
  --color-border-subtle: rgb(0 0 0 / 0.06);
  --color-border-strong: rgb(0 0 0 / 0.25);

  --color-text: var(--gray-900);
  --color-text-secondary: var(--gray-600);
  --color-text-muted: var(--gray-500);
  --color-text-disabled: var(--gray-400);

  /* 在淺底上需用較深的色階維持對比 */
  --color-accent-text: var(--indigo-600);
  --color-action-text: var(--emerald-600);
  --color-danger-text: var(--red-500);
  --color-warning-text: var(--amber-500);

  --color-accent-bg: rgb(99 102 241 / 0.12);
  --color-action-bg: rgb(16 185 129 / 0.12);
  --color-danger-bg: rgb(239 68 68 / 0.08);
  --color-warning-bg: rgb(251 191 36 / 0.12);

  --color-hover: rgb(0 0 0 / 0.04);
  --color-hover-strong: rgb(0 0 0 / 0.08);
  --color-field: var(--white);
  --color-field-solid: var(--white);
  --color-disabled-bg: var(--gray-200);

  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.15);

  --gradient-bg: linear-gradient(
    to bottom right,
    rgb(99 102 241 / 0.08),
    var(--gray-50) 50%,
    var(--gray-50)
  );
}

/* 尊重使用者的減少動態偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
