/**
 * OpenStock Lab 统一主题（辅助样式）
 * CSS 变量由 lab_theme.js 以 html inline style 写入（压过各页 :root 硬编码）。
 * 本文件提供 data-theme 兜底变量 + 通用覆盖。
 */

/* 分段切换按钮组：把一组 .btn 连成一体（如 分时/日K/周K、指数/市场切换等） */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.seg .btn {
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: var(--card);
}
.seg .btn.active {
  background: var(--accent-soft, rgba(229, 72, 77, 0.12));
  color: var(--accent);
  border-left: 1px solid var(--border);
}
.seg .btn:first-child { border-left: 0; }
.seg .btn:hover:not(.active) { background: var(--hover, rgba(255, 255, 255, 0.04)); }

/* 兜底：即使用户禁用 JS，也尽量按 data-theme 出颜色（!important 压过页内 :root） */
html[data-theme="dark"] {
  color-scheme: dark !important;
  --bg: #0f1115 !important;
  --card: #1a1d24 !important;
  --card-hover: #222630 !important;
  --text: #e6e8ec !important;
  --muted: #9aa1ad !important;
  --border: #2a2e37 !important;
  --accent: #e5484d !important;
  --accent-soft: rgba(229, 72, 77, 0.14) !important;
  --link: #7aa2ff !important;
  --th: #12161e !important;
  --row: #1a1d24 !important;
  --row2: #161a22 !important;
  --hover: rgba(255, 255, 255, 0.045) !important;
  --ok: #86efac !important;
  --err: #f87171 !important;
  --em: #fbbf24 !important;
  --tab: #151821 !important;
  --tab-active: #1f2430 !important;
  --shell: #12151c !important;
  --topbar-bg: rgba(18, 21, 28, 0.94) !important;
  --surface-soft: rgba(255, 255, 255, 0.03) !important;
  --surface-soft-2: rgba(255, 255, 255, 0.04) !important;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35) !important;
  --up: #ef4444 !important;
  --down: #22c55e !important;
  --flat: #94a3b8 !important;
  --th-hover: #1a2030 !important;
  --warn: #f59e0b !important;
  --code-bg: rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="light"] {
  color-scheme: light !important;
  --bg: #f3f6fb !important;
  --card: #ffffff !important;
  --card-hover: #f8fafc !important;
  --text: #1f2937 !important;
  --muted: #64748b !important;
  --border: #e6ebf2 !important;
  --accent: #e5484d !important;
  --accent-soft: rgba(229, 72, 77, 0.1) !important;
  --link: #2563eb !important;
  --th: #f1f5f9 !important;
  --row: #ffffff !important;
  --row2: #f8fafc !important;
  --hover: rgba(37, 99, 235, 0.06) !important;
  --ok: #059669 !important;
  --err: #dc2626 !important;
  --em: #d97706 !important;
  --tab: #eef2f7 !important;
  --tab-active: #ffffff !important;
  --shell: #f8fafc !important;
  --topbar-bg: rgba(255, 255, 255, 0.92) !important;
  --surface-soft: rgba(15, 23, 42, 0.03) !important;
  --surface-soft-2: rgba(15, 23, 42, 0.05) !important;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06) !important;
  --up: #dc2626 !important;
  --down: #059669 !important;
  --flat: #64748b !important;
  --th-hover: #e8eef7 !important;
  --warn: #d97706 !important;
  --code-bg: rgba(15, 23, 42, 0.06) !important;
}

/* 全局底色（各页 body 已用 var(--bg) 的可直接生效） */
html[data-theme] {
  background: var(--bg);
  color: var(--text);
}
html[data-theme] body {
  background: var(--bg);
  color: var(--text);
}

/* 常见 sticky 顶栏：用变量，避免写死深色 rgba */
html[data-theme] .top,
html[data-theme] .page-head,
html[data-theme] header.top {
  background: var(--topbar-bg);
}

/* 浅色不再给卡片加阴影（市场分析等页会显脏边/假阴影） */
html[data-theme="light"] .card,
html[data-theme="light"] .pane-block,
html[data-theme="light"] .section,
html[data-theme="light"] .em-panel {
  box-shadow: none;
}

/* code 块在浅色下可读 */
html[data-theme] code {
  background: var(--code-bg);
}

/* 新闻类旧页多为写死浅色；深色时给一套覆盖（不影响浅色默认观感） */
html[data-theme="dark"] body.lab-news-legacy {
  background: var(--bg) !important;
  color: var(--text) !important;
}
html[data-theme="dark"] body.lab-news-legacy .wrap,
html[data-theme="dark"] body.lab-news-legacy .tablebox,
html[data-theme="dark"] body.lab-news-legacy .card,
html[data-theme="dark"] body.lab-news-legacy table {
  background: var(--card) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
html[data-theme="dark"] body.lab-news-legacy th,
html[data-theme="dark"] body.lab-news-legacy td {
  border-color: var(--border) !important;
  color: var(--text) !important;
}
html[data-theme="dark"] body.lab-news-legacy th {
  background: var(--th) !important;
  color: var(--accent) !important;
}
html[data-theme="dark"] body.lab-news-legacy tbody tr:hover {
  background: var(--hover) !important;
}
html[data-theme="dark"] body.lab-news-legacy .title a,
html[data-theme="dark"] body.lab-news-legacy a:not(.btn):not(.link a) {
  color: var(--link) !important;
}
html[data-theme="dark"] body.lab-news-legacy .time,
html[data-theme="dark"] body.lab-news-legacy footer,
html[data-theme="dark"] body.lab-news-legacy .sub {
  color: var(--muted) !important;
}
html[data-theme="dark"] body.lab-news-legacy .pager button {
  background: var(--card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
html[data-theme="dark"] body.lab-news-legacy .btn {
  /* 顶栏红底上的白按钮保持可读，不强制改 */
}
