/* ============================================================
 * theme.css — 全站主题变量（浅色 / 深色 / 跟随系统）
 * ------------------------------------------------------------
 * 说明：
 *  - 本文件通过 CSS 自定义属性覆盖各模板内联 :root 中硬编码的深色值。
 *  - 深色为默认基线（data-theme="dark" 与未设 data-theme 时一致，保证向后兼容）。
 *  - 浅色通过 html[data-theme="light"] 覆盖。
 *  - 跟随系统：theme.js 读取 prefers-color-scheme 并把解析结果写到
 *    html[data-theme="light"|"dark"]；本文件不直接依赖媒体查询，便于 JS 优先级统一。
 *  - 同时覆盖语义命名（--bg-primary…）与 seven_indicator 的短名（--bg0…）两套体系。
 *  - 文字/边框/强调色均按 WCAG AA（正文 ≥4.5:1，大字/组件 ≥3:1）选定。
 * ============================================================ */

/* ── 深色基线（默认；与未设主题时等价，保证既有页面无回退风险） ── */
:root,
html[data-theme="dark"] {
  color-scheme: dark;

  /* 语义名体系 */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2332;
  --bg-hover: #243044;
  --border: #1e2d3d;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --green: #10b981;
  --green-bg: rgba(16,185,129,0.15);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.15);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,0.15);
  --yellow: #eab308;
  --yellow-bg: rgba(234,179,8,0.15);
  --purple: #a855f7;
  --cyan: #06b6d4;
  --orange: #f97316;

  /* seven_indicator 短名体系（映射到同一套值） */
  --bg0: #0a0e17;
  --bg1: #111827;
  --bg2: #1a2332;
  --bg3: #243044;
  --bd: #1e2d3d;
  --t1: #e2e8f0;
  --t2: #94a3b8;
  --t3: #64748b;
  --g: #22c55e;
  --gb: rgba(34,197,94,0.12);
  --r: #ef4444;
  --rb: rgba(239,68,68,0.12);
  --b: #3b82f6;
  --bb: rgba(59,130,246,0.12);
  --y: #eab308;
  --yb: rgba(234,179,8,0.12);
  --p: #a855f7;
  --c: #06b6d4;
  --o: #f97316;
}

/* ── 浅色主题 ── */
html[data-theme="light"] {
  color-scheme: light;

  /* 语义名体系 */
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef2f7;
  --border: #d1d5db;
  --text-primary: #1a2332;
  --text-secondary: #475569;
  --text-muted: #5b6a7e;

  --green: #047857;
  --green-bg: rgba(4,120,87,0.12);
  --red: #dc2626;
  --red-bg: rgba(220,38,38,0.12);
  --blue: #2563eb;
  --blue-bg: rgba(37,99,235,0.12);
  --yellow: #b45309;
  --yellow-bg: rgba(180,83,9,0.14);
  --purple: #7c3aed;
  --cyan: #0e7490;
  --orange: #ea580c;

  /* seven_indicator 短名体系 */
  --bg0: #f5f7fa;
  --bg1: #ffffff;
  --bg2: #ffffff;
  --bg3: #eef2f7;
  --bd: #d1d5db;
  --t1: #1a2332;
  --t2: #475569;
  --t3: #5b6a7e;
  --g: #047857;
  --gb: rgba(4,120,87,0.12);
  --r: #dc2626;
  --rb: rgba(220,38,38,0.12);
  --b: #2563eb;
  --bb: rgba(37,99,235,0.12);
  --y: #b45309;
  --yb: rgba(180,83,9,0.14);
  --p: #7c3aed;
  --c: #0e7490;
  --o: #ea580c;
}

/* ============================================================
 * 主题切换控件（由 theme.js 注入到各页面导航区）
 * ============================================================ */
/* 容器：按钮 + 下拉菜单的定位锚点 */
.theme-switch {
  display: inline-flex;
  align-items: center;
  position: relative;
  margin-left: 10px;
  vertical-align: middle;
  font-size: 13px;
  user-select: none;
  white-space: nowrap;
  color: var(--text-primary);
}

/* 触发按钮 */
.theme-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
  transition: all .2s;
}
.theme-switch-btn:hover {
  background: var(--bg-hover);
  border-color: var(--cyan);
}
.theme-switch-btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.theme-switch-icon svg {
  display: block;
  fill: currentColor;
}
/* 图标随当前生效主题呈现明暗半圆，起状态引导 */
html[data-theme="light"] .theme-switch-btn .theme-switch-icon svg {
  fill: var(--text-primary);
}
.theme-switch-caret {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform .18s ease;
}
.theme-switch.theme-open .theme-switch-caret {
  transform: rotate(180deg);
}

/* 下拉菜单 */
.theme-switch-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 9999;
  min-width: 148px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
}
.theme-switch.theme-open .theme-switch-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 菜单项（含背景色块预览） */
.theme-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.theme-menu-item:hover {
  background: var(--bg-hover);
}
.theme-menu-item.is-selected {
  color: var(--cyan);
  font-weight: 700;
}
.theme-menu-item .theme-swatch {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.theme-menu-item .theme-menu-text {
  flex: 1 1 auto;
}
.theme-menu-item .theme-menu-check {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
}


/* 浅色下部分强调色背景类（若页面直接用硬编码 rgba 背景，在此微调） */

/* ── wallet_login.html：覆盖硬编码渐变/卡片背景 ── */
html[data-theme="light"] body {
  background: linear-gradient(160deg, #f8fafc 0%, #eef2f7 40%, #e2e8f0 100%);
  color: #1a2332;
}
html[data-theme="light"] .container {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(37, 99, 235, 0.2);
  box-shadow: 0 8px 40px rgba(15, 23, 42, 0.12), 0 0 60px rgba(37, 99, 235, 0.04);
}

/* ── 语言切换按钮（i18n.js 注入）——适配深浅主题 —— */
.i18n-btn {
  color: var(--text-primary);
}
.i18n-btn [data-lang] {
  color: var(--text-secondary);
}
.i18n-btn [data-lang]:hover {
  color: var(--text-primary);
}
.i18n-btn [data-lang].is-active {
  color: var(--text-primary);
  font-weight: 700;
  background: var(--bg-hover);
}
.i18n-btn .i18n-sep {
  color: var(--text-muted);
  opacity: .5;
  margin: 0 2px;
}
