/* TradeDoc 用户手册 - 主题色
   经典蓝色 + 素雅黑白灰双主题，通过 [data-theme] 切换 */

:root {
  --primary: #1a4fa8;
  --primary-light: #2563eb;
  --primary-bg: #eef4ff;
  --primary-text: #ffffff;

  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-soft: #f1f3f5;

  --text: #1f2328;
  --text-soft: #57606a;
  --text-muted: #8b949e;

  --border: #e5e7eb;
  --border-strong: #d0d7de;

  --code-bg: #f6f8fa;
  --code-text: #1f2328;
  --link: #1a4fa8;
  --link-hover: #1f6feb;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.10);

  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 56px;
  --sidebar-w: 280px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

/* 素雅主题 */
[data-theme="minimal"] {
  --primary: #2c2c2c;
  --primary-light: #3d3d3d;
  --primary-bg: #f4f4f4;
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --bg-soft: #f0f0f0;
  --border: #e0e0e0;
  --border-strong: #b8b8b8;
  --link: #2c2c2c;
  --link-hover: #000;
  --radius: 2px;
  --radius-sm: 2px;
}

/* ================== 重置 ================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}
kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 3px;
  line-height: 1.4;
}

/* ================== 顶部栏 ================== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.menu-btn {
  display: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
}
.menu-btn:hover { background: var(--bg-soft); }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--radius-sm);
  letter-spacing: 1px;
}
.search-box {
  flex: 1;
  max-width: 360px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--text-muted);
  transition: all .2s;
}
.search-box:focus-within {
  background: var(--bg-elev);
  border-color: var(--primary);
  color: var(--text);
}
.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ================== 布局 ================== */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 12px;
  z-index: 50;
  transition: transform .3s;
}
.sidebar-nav { padding: 0 4px; }
.nav-section {
  margin-bottom: 20px;
}
.nav-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 0 12px 8px;
  margin: 0;
}
.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.nav-item a {
  display: block;
  padding: 7px 12px;
  font-size: 14px;
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: all .15s;
  text-decoration: none;
}
.nav-item a:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}
.nav-item a.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 500;
  border-left-color: var(--primary);
}

/* 内容区 */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 48px 80px;
  max-width: 980px;
}
.article {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 48px;
  box-shadow: var(--shadow-sm);
}
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

/* 文档排版 */
.article h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.article h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 36px 0 16px;
  color: var(--text);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.article h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--text);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.article h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 8px;
}
.article p {
  margin: 12px 0;
  color: var(--text);
}
.article ul, .article ol {
  margin: 12px 0;
  padding-left: 24px;
}
.article li { margin: 4px 0; }
.article blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.article blockquote p { margin: 4px 0; }
.article code {
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 3px;
}
.article pre {
  margin: 16px 0;
  padding: 16px;
  background: var(--code-bg) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.5;
}
.article pre code {
  padding: 0;
  background: transparent;
  font-size: 13px;
  color: var(--text);
}
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.article thead {
  background: var(--primary-bg);
}
.article th, .article td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.article th {
  font-weight: 600;
  color: var(--text);
}
.article td { color: var(--text-soft); }
.article hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 32px 0;
}
.article img {
  display: block;
  max-width: 100%;
  margin: 16px auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.article strong { font-weight: 600; color: var(--text); }

/* 搜索结果浮层 */
.search-results {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  right: 16px;
  width: 420px;
  max-height: 70vh;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  z-index: 200;
  display: none;
}
.search-results.show { display: block; }
.search-result {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-soft); }
.search-result-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.search-result-section {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 4px;
}
.search-result-snippet {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}
.search-result-snippet mark {
  background: #fff3a0;
  color: #5a4a00;
  padding: 0 2px;
  border-radius: 2px;
}
.search-empty {
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* 移动端遮罩 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ================== 响应式 ================== */
@media (max-width: 1024px) {
  .content { padding: 24px 28px 60px; }
  .article { padding: 32px; }
}

@media (max-width: 768px) {
  .menu-btn { display: inline-flex; }
  .brand-name { display: none; }
  .search-box { max-width: 200px; }
  .search-box kbd { display: none; }

  .layout { padding-top: var(--header-h); }
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .content {
    margin-left: 0;
    padding: 16px 12px 60px;
  }
  .article { padding: 24px 18px; }
  .article h1 { font-size: 24px; }
  .article h2 { font-size: 19px; }
  .article h3 { font-size: 16px; }
  .article table { font-size: 13px; }
  .article th, .article td { padding: 8px 10px; }

  .search-results {
    right: 8px;
    left: 8px;
    width: auto;
    max-height: 60vh;
  }
}

@media (max-width: 480px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .search-box { max-width: 160px; padding: 5px 10px; }
  .search-box input { font-size: 13px; }
  .article { padding: 20px 14px; border-radius: var(--radius-sm); }
  .article h1 { font-size: 22px; margin-bottom: 16px; }
  .article h2 { font-size: 18px; margin: 24px 0 12px; }
  .article pre { font-size: 12px; }
  .content { padding: 12px 8px 60px; }
}

/* ================== 滚动条 ================== */
.sidebar::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.article pre::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.sidebar::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb,
.article pre::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
