/* ============================================================
   theme.css — 方案 H5 通用主题（Arco Design 风格 · 科技感）
   双主题（dark/light）由右上角按钮切换，data-theme 控制。
   设计语言：Arcoblue #165DFF 主色 / 渐变点缀 / 双色调状态徽标 /
   浅表头横线表格 / 卡片式图区 / 细滚动条。所有 class 名向后兼容。
   ============================================================ */

/* ---------- 1. 主题变量 ---------- */
:root, [data-theme="dark"] {
  --bg: #12141a;
  --fg: #e8eaf0;
  --panel: #1a1d26;
  --panel-2: #242833;
  --border: #323748;
  --accent: #4080ff;          /* Arcoblue-5（暗色下提亮一档） */
  --accent-deep: #165dff;     /* Arcoblue-6 主品牌色 */
  --muted: #9298a8;
  --tag-self: #4080ff;
  --tag-third: #a871e3;
  --tag-existing: #4cd263;
  /* 扩展变量（新增，旧页面不引用也无碍） */
  --accent-weak: rgba(64, 128, 255, .14);
  --row-hover: #242833;
  --grid-line: rgba(255, 255, 255, .028);
  --topbar-bg: rgba(26, 29, 38, .86);
  --ok: #4cd263; --warn: #ff9a2e; --info: #6aa1ff; --purple: #a871e3; --gray: #a9aeb8;
  --ok-bg: rgba(0, 180, 42, .16); --warn-bg: rgba(255, 125, 0, .16);
  --info-bg: rgba(22, 93, 255, .18); --purple-bg: rgba(114, 46, 209, .20);
  --gray-bg: rgba(134, 144, 156, .18);
  --shadow: 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .25);
}
[data-theme="light"] {
  --bg: #f2f3f5;
  --fg: #1d2129;
  --panel: #ffffff;
  --panel-2: #f2f3f5;
  --border: #e5e6eb;
  --accent: #165dff;
  --accent-deep: #165dff;
  --muted: #4e5969;
  --tag-self: #165dff;
  --tag-third: #722ed1;
  --tag-existing: #00b42a;
  --accent-weak: rgba(22, 93, 255, .08);
  --row-hover: #f7f8fa;
  --grid-line: rgba(29, 33, 41, .032);
  --topbar-bg: rgba(255, 255, 255, .86);
  --ok: #00b42a; --warn: #ff7d00; --info: #165dff; --purple: #722ed1; --gray: #86909c;
  --ok-bg: rgba(0, 180, 42, .10); --warn-bg: rgba(255, 125, 0, .10);
  --info-bg: rgba(22, 93, 255, .10); --purple-bg: rgba(114, 46, 209, .10);
  --gray-bg: rgba(134, 144, 156, .12);
  --shadow: 0 4px 10px rgba(29, 33, 41, .08);
  --shadow-sm: 0 1px 2px rgba(29, 33, 41, .06);
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  transition: background .25s ease, color .25s ease;
}
/* 科技感底纹：淡网格 + 右上角品牌色光晕（固定层，不随滚动、不响应鼠标） */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(720px 320px at 88% -12%, var(--accent-weak), transparent 70%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
}
.topbar, .layout { position: relative; z-index: 1; }
::selection { background: rgba(22, 93, 255, .30); }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}

/* ---------- 3. 顶栏：品牌 + 模块切换 + 主题切换 ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  transition: box-shadow .2s ease;
}
.topbar.scrolled { box-shadow: var(--shadow-sm); }
/* 底部渐变光带（Arcoblue → Cyan） */
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-deep), #14c9c9, transparent);
  opacity: .75; pointer-events: none;
}
.brand {
  font-weight: 700; white-space: nowrap;
  display: flex; align-items: center; gap: 9px;
  background: linear-gradient(120deg, var(--accent), #14c9c9);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--accent);
}
/* 品牌发光方块 */
.brand::before {
  content: ""; flex: none; width: 10px; height: 10px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent-deep), #14c9c9);
  box-shadow: 0 0 10px rgba(22, 93, 255, .55);
}
.module-switch { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.module-switch a {
  color: var(--muted); text-decoration: none;
  padding: 5px 13px; border-radius: 8px; font-size: 13px; white-space: nowrap;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.module-switch a:hover { background: var(--panel-2); color: var(--fg); }
.module-switch a.active {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: #fff; font-weight: 600;
  box-shadow: 0 2px 10px rgba(22, 93, 255, .35);
}
.theme-toggle {
  background: var(--panel-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
  width: 34px; height: 34px; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .18s ease, color .18s ease, transform .1s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:active { transform: scale(.94); }

/* ---------- 4. 布局：左侧导航 + 内容区（侧栏固定，不随页面滚动） ---------- */
.layout { display: flex; min-height: calc(100vh - 55px); }
.sidebar {
  width: 264px; flex: none;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky; top: 55px;
  align-self: flex-start;
  height: calc(100vh - 55px);
  overflow-y: auto;
}
/* 侧栏滚动条：与主题配色一致，细样式 */
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.sidebar-title {
  font-size: 11px; color: var(--muted);
  margin: 16px 8px 6px; letter-spacing: 2px; font-weight: 600;
}
.sidebar-title:first-child { margin-top: 0; }
.page-nav a {
  display: block; color: var(--fg); text-decoration: none;
  padding: 6px 10px; border-radius: 8px; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s ease, color .15s ease;
}
.page-nav a:hover { background: var(--panel-2); }
.page-nav a.cur {
  background: var(--accent-weak); color: var(--accent); font-weight: 600;
}
.content { flex: 1; padding: 24px 32px 40px; max-width: 1200px; }

/* ---------- 5. 标题 ---------- */
.content h2 {
  position: relative;
  margin: 8px 0 18px; padding: 2px 0 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 21px; line-height: 1.4;
}
/* 标题左侧渐变竖条 */
.content h2::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 13px;
  width: 4px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-deep), #14c9c9);
}
.content h3 { font-size: 17px; margin: 22px 0 10px; }
.content section { margin-bottom: 40px; }

/* ---------- 6. 数据表格（Arco 风格：浅表头 + 横线 + 悬停行 + 圆角外框） ---------- */
.data-table {
  width: 100%; margin: 12px 0;
  border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  font-size: 13.5px;
}
.data-table th, .data-table td {
  padding: 9px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--panel-2); font-weight: 600; white-space: nowrap;
}
.data-table tbody tr { transition: background .15s ease; }
.data-table tbody tr:nth-child(even) { background: var(--row-hover); }
.data-table tbody tr:hover { background: var(--accent-weak); }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; border-radius: 10px; }

/* ---------- 7. 折叠面板（details / summary：箭头图标 + 悬停反馈） ---------- */
/* 接口字段清单：默认收缩，点击展开（details 无 open 属性即收缩） */
details.api-fields {
  border: 1px solid var(--border); border-radius: 10px; margin: 10px 0;
  background: var(--panel); overflow: hidden;
}
details.api-fields > summary {
  cursor: pointer; padding: 9px 12px; background: var(--panel-2);
  user-select: none; list-style: none;
  display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px;
}
details.api-fields > summary::-webkit-details-marker { display: none; }
details.api-fields > summary::before {
  content: ""; flex: none; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .18s ease;
}
details.api-fields[open] > summary::before { transform: rotate(45deg); }
details.api-fields[open] > summary { border-bottom: 1px solid var(--border); }
details.api-fields .fields-body { padding: 10px 12px; }

/* 折叠面板统一美化：内容区所有 details 生效 */
.content details {
  border: 1px solid var(--border); border-radius: 10px;
  margin: 10px 0; background: var(--panel); overflow: hidden;
  transition: border-color .18s ease;
}
.content details > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px; background: var(--panel-2);
  font-weight: 600; font-size: 14px;
  transition: color .18s ease, background .18s ease;
}
.content details > summary::-webkit-details-marker { display: none; }
.content details > summary::before {
  content: ""; flex: none; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .18s ease;
}
.content details[open] > summary::before { transform: rotate(45deg); border-color: var(--accent); }
.content details > summary:hover { color: var(--accent); background: var(--accent-weak); }
.content details > summary:hover::before { border-color: var(--accent); }
.content details[open] { border-color: var(--accent); }
.content details[open] > summary { border-bottom: 1px solid var(--border); color: var(--accent); }
.content details > summary + * { margin-top: 0; }
.content details > *:not(summary) { padding-left: 4px; }
.content details > p { padding: 2px 14px 10px; }

/* ---------- 8. 图区（figure / mermaid）：卡片式画布 ---------- */
figure {
  margin: 16px 0; padding: 14px 16px 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
figure svg, figure img { max-width: 100%; display: block; margin: 0 auto; }
figcaption { color: var(--muted); font-size: 13px; margin-top: 8px; text-align: center; }
.diagram-note { margin: 8px 0 0; }
/* 暗色主题下，图表画布统一白底（SVG/Mermaid 均按白底绘制），呈现"图表卡片"效果 */
[data-theme="dark"] figure svg, [data-theme="dark"] figure img {
  background: #ffffff; border-radius: 8px; padding: 4px;
}
.content .mermaid { overflow-x: auto; border-radius: 8px; }
[data-theme="dark"] .content .mermaid {
  background: #ffffff; padding: 16px; border-radius: 8px;
}

/* ---------- 9. 图片点击放大（lightbox） ---------- */
.content img.zoomable { cursor: zoom-in; }
.lightbox-overlay {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: rgba(10, 12, 16, .82);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
  cursor: zoom-out; padding: 24px;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img {
  max-width: 96vw; max-height: 94vh; background: #fff;
  border-radius: 10px; box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
}

/* ---------- 10. 状态徽标（Arco 双色调：浅底 + 彩字） ---------- */
.status {
  display: inline-block; padding: 1px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 500; line-height: 20px;
  white-space: nowrap;
}
.st-active { color: var(--ok); background: var(--ok-bg); }
.st-doing  { color: var(--info); background: var(--info-bg); }
.st-wait   { color: var(--gray); background: var(--gray-bg); }
.st-plan   { color: var(--purple); background: var(--purple-bg); }
.st-hold   { color: var(--warn); background: var(--warn-bg); }
.st-out   { color: var(--gray); background: transparent; border: 1px dashed var(--gray); }

/* ---------- 11. 系统类型标签（自建/已有/第三方） ---------- */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; line-height: 19px; white-space: nowrap;
}
.tag-self { color: var(--tag-self); background: var(--accent-weak); }
.tag-existing { color: var(--tag-existing); background: var(--ok-bg); }
.tag-third { color: var(--tag-third); background: var(--purple-bg); }

/* ---------- 12. 响应式 ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto; border-right: none; border-bottom: 1px solid var(--border);
    position: static; height: auto;
  }
}
