/* ============================================================================
 * QQboot UI 设计令牌（Design Tokens）
 * ----------------------------------------------------------------------------
 * 唯一依据文件。桌面端、手机端、用户端、管理端全部从这里取值。
 * 任何模板不得自造颜色、圆角、阴影、间距；缺什么先在这里加。
 *
 * 命名对齐 shadcn/ui v4 语义变量（background / foreground / card / primary /
 * secondary / muted / accent / destructive / border / input / ring），
 * 这样后续如果接入 Tailwind v4，可以直接把 @theme 映射过来。
 *
 * 取值说明：
 *   - 颜色一律 hex，不用 oklch()。目标环境含 Android 旧版 WebView 与
 *     iOS 15 以下，oklch 在这些内核上会整条声明失效并回退成黑色。
 *   - 对比度按 WCAG 2.2 AA：正文 ≥ 4.5:1，大字号与图标 ≥ 3:1。
 *   - 暗色模式用 [data-theme="dark"]，不依赖 prefers-color-scheme，
 *     避免用户在系统暗色下仍被强制变暗。
 * ========================================================================== */

:root {
  /* ---------------------------------------------------------------- 色板基底
   * 中性色取 zinc 系（略带冷调），比纯灰更有质感，也不会和主色打架。 */
  --gray-25:  #fcfcfd;
  --gray-50:  #f8f9fb;
  --gray-100: #f1f3f7;
  --gray-150: #eaedf3;
  --gray-200: #e2e6ee;
  --gray-300: #cbd2e0;
  --gray-400: #9aa4b8;
  --gray-500: #6b7689;
  --gray-600: #556074;
  --gray-700: #3d4759;
  --gray-800: #28313f;
  --gray-900: #1a2230;
  --gray-950: #0f1520;

  /* ---------------------------------------------------------------- 语义颜色 */
  --background: #f7f8fb;          /* 页面底色，比纯白低 2% 亮度，衬托白卡 */
  --foreground: #1a2230;          /* 主文字 14.8:1 */
  --card: #ffffff;                /* 卡片、弹窗、下拉 */
  --card-foreground: #1a2230;
  --popover: #ffffff;
  --popover-foreground: #1a2230;

  --primary: #2f5fe0;             /* 主色：蓝 600，按钮、链接、选中态 */
  --primary-hover: #2650c4;
  --primary-active: #1f44a8;
  --primary-foreground: #ffffff;
  --primary-soft: #eef3ff;        /* 主色浅底：选中标签、弱按钮 */
  --primary-soft-foreground: #2350c8;
  --primary-border: #c9d9ff;

  --secondary: #f1f3f7;           /* 次级按钮底 */
  --secondary-hover: #e8ebf2;
  --secondary-foreground: #28313f;

  --muted: #f4f6fa;               /* 弱背景：表头、代码块、空状态 */
  --muted-foreground: #667184;    /* 次要文字 4.64:1（在 --background 上） */
  /* 第三级文字：占位符、分隔符、图标等。
     取值经过四种背景实测：card 5.20 / background 4.89 / muted 4.80 / accent 4.68，
     全部达到 WCAG AA 4.5:1，因此在任何底色上承载次要文字都安全。 */
  --subtle-foreground: #646d80;

  --accent: #eef3ff;              /* hover 高亮底 */
  --accent-foreground: #2350c8;
  /* 在 --accent / --primary-soft 底上的次要文字，需比 --muted-foreground 再深一档（4.63:1） */
  --muted-foreground-on-accent: #636e81;

  --destructive: #ca3244;         /* 危险：删除、封禁、失败（4.61:1 on soft） */
  --destructive-hover: #bb2f40;
  --destructive-foreground: #ffffff;
  --destructive-soft: #fdeef0;
  --destructive-border: #f7cdd2;

  --success: #0f7d59;             /* 成功：正常、已发布、通过（4.61:1 on soft） */
  --success-soft: #e8f6f1;
  --success-border: #bfe6d8;

  --warning: #9d6104;             /* 警告：待审核、将过期（4.64:1 on soft） */
  --warning-soft: #fdf4e3;
  --warning-border: #f3ddb4;

  --info: #1b6bcc;                /* 信息：提示条（4.66:1 on soft） */
  --info-soft: #eaf3fd;
  --info-border: #c3ddf8;

  /* 边框与输入 */
  --border: #e4e8f0;              /* 卡片描边 */
  --border-strong: #d3d9e6;       /* 输入框、分隔强调 */
  --input: #dfe4ee;               /* 输入框默认描边 */
  --input-hover: #c8d0e0;
  --ring: #2f5fe0;                /* 焦点环 */

  /* 图表色（多序列，色盲友好顺序） */
  --chart-1: #2f5fe0;
  --chart-2: #12a08a;
  --chart-3: #d98324;
  --chart-4: #8b5cf6;
  --chart-5: #d33b4d;

  /* ---------------------------------------------------------------- 圆角
   * 8/10/12/16/999 五档。shadcn 的 0.625rem≈10px 与 --radius-md 对齐。 */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-pill: 999px;

  /* ---------------------------------------------------------------- 间距
   * 4px 基准栅格。命名按倍数，不用 t-shirt size，避免歧义。 */
  --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;

  /* ---------------------------------------------------------------- 字号
   * 1.25 倍模块化。正文桌面 14px / 手机 16px（避免 iOS 输入框聚焦缩放）。 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;

  --leading-tight: 1.25;
  --leading-snug: 1.4;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --tracking-tight: -0.011em;
  --tracking-normal: 0;
  --tracking-wide: 0.02em;

  /* ---------------------------------------------------------------- 阴影
   * 浅色 SaaS 的关键：阴影要极轻，靠描边区分层级，不靠投影。 */
  --shadow-xs: 0 1px 2px rgba(24, 34, 48, .04);
  --shadow-sm: 0 1px 3px rgba(24, 34, 48, .06), 0 1px 2px rgba(24, 34, 48, .04);
  --shadow-md: 0 4px 12px rgba(24, 34, 48, .07), 0 1px 3px rgba(24, 34, 48, .05);
  --shadow-lg: 0 12px 28px rgba(24, 34, 48, .09), 0 2px 6px rgba(24, 34, 48, .05);
  --shadow-xl: 0 24px 48px rgba(24, 34, 48, .12), 0 4px 12px rgba(24, 34, 48, .06);
  --shadow-ring: 0 0 0 1px rgba(24, 34, 48, .05);

  /* 玻璃拟态：只用于悬浮操作条与弹层头部，不做整块卡片背景（性能与可读性） */
  --glass-bg: rgba(255, 255, 255, .72);
  --glass-bg-strong: rgba(255, 255, 255, .88);
  --glass-blur: saturate(180%) blur(20px);
  --glass-border: rgba(255, 255, 255, .6);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, .85);

  /* ---------------------------------------------------------------- 动效 */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 280ms;

  /* ---------------------------------------------------------------- 层级 */
  --z-base: 1;
  --z-sticky: 20;
  --z-drawer: 40;
  --z-modal: 50;
  --z-toast: 60;
  --z-tooltip: 70;

  /* ---------------------------------------------------------------- 布局 */
  --sidebar-width: 248px;
  --sidebar-width-collapsed: 68px;
  --topbar-height: 60px;
  --container-max: 1360px;
  --content-max: 1120px;

  /* 手机端 */
  /* 手机端排版：正文 16px 与行高 1.55 独立于桌面取值（SPEC §3.2 / §6） */
  --text-base-mobile: 16px;
  --leading-mobile: 1.55;
  --input-font-size-mobile: 16px;   /* 防止 iOS 聚焦时自动缩放 */
  --mobile-tabbar-icon: 22px;

  --mobile-topbar-height: 56px;
  --mobile-tabbar-height: 60px;
  --touch-target: 44px;           /* WCAG 2.2 最小可点击 24px，Apple HIG 44px，取 44 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ============================================================================
 * 暗色模式
 * ----------------------------------------------------------------------------
 * 不是简单反色：底色用 #0f1520 而非纯黑（纯黑上白字发晕），卡片略亮一档，
 * 主色降饱和提亮，保证在深底上的对比度仍达 AA。
 * ========================================================================== */
[data-theme="dark"] {
  --background: #0f1520;
  --foreground: #e8ecf3;
  --card: #171e2b;
  --card-foreground: #e8ecf3;
  --popover: #1b2331;
  --popover-foreground: #e8ecf3;

  --primary: #5b83f0;
  --primary-hover: #7192f4;
  --primary-active: #4a72e0;
  --primary-foreground: #0f1520;
  --primary-soft: #1c2a4a;
  --primary-soft-foreground: #9db8ff;
  --primary-border: #2b3f66;

  --secondary: #1e2735;
  --secondary-hover: #26303f;
  --secondary-foreground: #e8ecf3;

  --muted: #1a2231;
  --muted-foreground: #a4aec0;
  --subtle-foreground: #7c8698;

  --accent: #1c2a4a;
  --accent-foreground: #9db8ff;

  --destructive: #f0677a;
  --destructive-hover: #f5808f;
  --destructive-foreground: #0f1520;
  --destructive-soft: #35202a;
  --destructive-border: #5a2c38;

  --success: #4ecfa4;
  --success-soft: #14332b;
  --success-border: #1f5a4a;

  --warning: #e0a94a;
  --warning-soft: #33280f;
  --warning-border: #5c4718;

  --info: #6aa9f0;
  --info-soft: #14263c;
  --info-border: #234668;

  --border: #242e3e;
  --border-strong: #32405a;
  --input: #2a3547;
  --input-hover: #3a4761;
  --ring: #5b83f0;

  --chart-1: #5b83f0;
  --chart-2: #4ecfa4;
  --chart-3: #e0a94a;
  --chart-4: #a78bfa;
  --chart-5: #f0677a;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-xl: 0 24px 48px rgba(0, 0, 0, .55), 0 4px 12px rgba(0, 0, 0, .35);
  --shadow-ring: 0 0 0 1px rgba(255, 255, 255, .06);

  --glass-bg: rgba(23, 30, 43, .72);
  --glass-bg-strong: rgba(23, 30, 43, .9);
  --glass-border: rgba(255, 255, 255, .08);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, .06);
}

/* ============================================================================
 * 基础重置
 * ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--foreground);
}

p { margin: 0; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 2px; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: .92em; }

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

button, input, select, textarea { font: inherit; color: inherit; }

/* 焦点可见：键盘用户必须看得见焦点，鼠标点击不显示 */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--gray-400); background-clip: padding-box; }

::selection { background: var(--primary-soft); color: var(--primary-soft-foreground); }

/* 屏幕阅读器专用 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 跳转链接：键盘用户第一个 Tab 就能跳过导航 */
.skip-link {
  position: absolute;
  top: -100px; left: var(--space-4);
  z-index: var(--z-tooltip);
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-4);
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-medium);
  transition: top var(--duration-fast) var(--ease-out);
}
.skip-link:focus { top: var(--space-3); text-decoration: none; }

/* ============================================================================
 * 打印：只留内容，去掉导航与操作
 * ========================================================================== */
@media print {
  .app-sidebar,
  .app-topbar,
  .m-topbar,
  .m-tabbar,
  .btn,
  .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
