/* ========================================
   Hermes Agent 中文文档 - 样式表
   支持浅色/深色双主题
   ======================================== */

/* CSS 变量定义 */
:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-bg-tertiary: #f1f5f9;
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-accent: #06b6d4;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-code-bg: #1e293b;
  --color-code-text: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: 'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  --sidebar-width: 280px;
  --header-height: 64px;
  --sidebar-scrollbar-size: 6px;
  --sidebar-scrollbar-thumb: rgba(37, 99, 235, 0.28);
  --sidebar-scrollbar-thumb-hover: rgba(37, 99, 235, 0.42);
  --sidebar-scrollbar-track: rgba(148, 163, 184, 0.12);
  --transition: all 0.2s ease;
}

/* 深色主题 */
[data-theme="dark"] {
  --color-bg: #0a0a0f;
  --color-bg-secondary: #12121a;
  --color-bg-tertiary: #1a1a25;
  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-border: #27273a;
  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-light: rgba(59, 130, 246, 0.15);
  --color-accent: #22d3ee;
  --color-code-bg: #0f1117;
  --sidebar-scrollbar-thumb: rgba(96, 165, 250, 0.28);
  --sidebar-scrollbar-thumb-hover: rgba(96, 165, 250, 0.42);
  --sidebar-scrollbar-track: rgba(30, 41, 59, 0.36);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  font-size: 15px;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 链接 */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* 字体 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ========================================
   布局结构
   ======================================== */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部导航栏 */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(var(--color-bg), 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  transition: var(--transition);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
}

.menu-toggle:hover {
  background: var(--color-bg-tertiary);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--color-text);
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
  color: var(--color-text);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
}

.version-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-bg-tertiary);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.header-btn:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  text-decoration: none;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 主内容区 */
.main {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* 左侧侧边栏 */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 0;
  z-index: 900;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: transform 0.3s ease, var(--transition);
}

.sidebar:hover,
.sidebar:focus-within {
  scrollbar-color: var(--sidebar-scrollbar-thumb) transparent;
}

.sidebar::-webkit-scrollbar {
  width: var(--sidebar-scrollbar-size);
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
  transition: background-color 0.2s ease;
}

.sidebar:hover::-webkit-scrollbar-track,
.sidebar:focus-within::-webkit-scrollbar-track {
  background: var(--sidebar-scrollbar-track);
}

.sidebar:hover::-webkit-scrollbar-thumb,
.sidebar:focus-within::-webkit-scrollbar-thumb {
  background: var(--sidebar-scrollbar-thumb);
}

.sidebar:hover::-webkit-scrollbar-thumb:hover,
.sidebar:focus-within::-webkit-scrollbar-thumb:hover {
  background: var(--sidebar-scrollbar-thumb-hover);
}

.sidebar-nav {
  padding: 0 16px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-list {
  list-style: none;
}

.nav-item {
  margin-bottom: 2px;
}

.nav-link {
  display: block;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-text-secondary);
  font-weight: 450;
  transition: var(--transition);
  text-decoration: none;
}

.nav-link:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

/* 内容区域 */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px 48px;
  max-width: 900px;
  min-width: 0;
}

/* 右侧目录（大屏幕显示） */
.toc-sidebar {
  position: fixed;
  top: calc(var(--header-height) + 40px);
  right: 24px;
  width: 220px;
  display: none;
}

@media (min-width: 1400px) {
  .toc-sidebar {
    display: block;
  }
}

.toc-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.toc-list {
  list-style: none;
  border-left: 1px solid var(--color-border);
  padding-left: 0;
}

.toc-item {
  padding-left: 16px;
  border-left: 1px solid transparent;
  margin-bottom: 4px;
  margin-left: -1px;
}

.toc-item.active {
  border-left-color: var(--color-primary);
}

.toc-link {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  display: block;
  padding: 3px 0;
  text-decoration: none;
}

.toc-link:hover {
  color: var(--color-text);
  text-decoration: none;
}

.toc-item.active .toc-link {
  color: var(--color-primary);
  font-weight: 500;
}

/* ========================================
   排版样式
   ======================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
  margin-top: 0;
  margin-bottom: 16px;
  scroll-margin-top: calc(var(--header-height) + 24px);
}

h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

h2 {
  font-size: 28px;
  margin-top: 48px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

h3 {
  font-size: 22px;
  margin-top: 36px;
}

h4 {
  font-size: 18px;
  margin-top: 28px;
}

p {
  margin-bottom: 16px;
}

strong {
  font-weight: 600;
  color: var(--color-text);
}

/* 列表 */
ul, ol {
  margin-bottom: 20px;
  padding-left: 24px;
}

li {
  margin-bottom: 8px;
}

li > ul, li > ol {
  margin-top: 8px;
  margin-bottom: 8px;
}

/* 代码 */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg-tertiary);
  color: var(--color-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 20px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: 24px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  font-weight: 400;
}

/* 代码高亮颜色 - 通用 */
.code-keyword { color: #c678dd; }
.code-string { color: #98c379; }
.code-comment { color: #5c6370; font-style: italic; }
.code-function { color: #61afef; }
.code-number { color: #d19a66; }
.code-operator { color: #56b6c2; }

[data-theme="dark"] .code-comment { color: #7f848e; }

/* 表格 */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:hover {
  background: var(--color-bg-secondary);
}

/* 引用块 */
blockquote {
  border-left: 3px solid var(--color-primary);
  background: var(--color-bg-secondary);
  padding: 16px 20px;
  margin-bottom: 24px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text-secondary);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* 水平线 */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 48px 0;
}

/* 图片 */
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

/* ========================================
   组件
   ======================================== */

/* 提示框 */
.callout {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  border: 1px solid var(--color-border);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.callout-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.callout-content {
  flex: 1;
}

.callout-content p:last-child {
  margin-bottom: 0;
}

.callout-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}

.callout-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
}

.callout-info .callout-title { color: var(--color-primary); }

.callout-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
}

.callout-success .callout-title { color: var(--color-success); }

.callout-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.2);
}

.callout-warning .callout-title { color: var(--color-warning); }

.callout-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}

.callout-danger .callout-title { color: var(--color-danger); }

/* 按钮 */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

.button-primary {
  background: var(--color-primary);
  color: white;
}

.button-primary:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
  color: white;
}

.button-secondary {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.button-secondary:hover {
  background: var(--color-border);
  text-decoration: none;
  color: var(--color-text);
}

/* 卡片网格 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.card-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: 0;
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-right: 6px;
}

.tag-blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-primary);
}

.tag-green {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.tag-orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

/* 步骤列表 */
.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.steps > li {
  position: relative;
  padding-left: 48px;
  margin-bottom: 24px;
  min-height: 32px;
}

.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.steps > li::after {
  content: '';
  position: absolute;
  left: 13px;
  top: 32px;
  bottom: -8px;
  width: 2px;
  background: var(--color-border);
}

.steps > li:last-child::after {
  display: none;
}

/* 英雄区 */
.hero {
  padding: 48px 0 32px;
  margin-bottom: 16px;
}

.hero-title {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .hero-title {
  background: linear-gradient(135deg, #f1f5f9 0%, var(--color-accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 20px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  max-width: 720px;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* 特性列表 */
.feature-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.feature-item {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.feature-icon {
  width: 40px;
  height: 40px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.feature-content h4 {
  font-size: 15px;
  margin-bottom: 4px;
  margin-top: 0;
}

.feature-content p {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 0;
  line-height: 1.5;
}

/* 命令表格 */
.cmd-table td:first-child {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-primary);
  white-space: nowrap;
}

/* 搜索框 */
.search-box {
  position: relative;
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  width: 16px;
  height: 16px;
}

/* 搜索弹窗 */
.search-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
}

.search-modal.active {
  display: flex;
}

.search-modal-content {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 60vh;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.search-modal-input {
  width: 100%;
  padding: 16px 20px;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: 16px;
  outline: none;
  border-bottom: 1px solid var(--color-border);
}

.search-results {
  max-height: calc(60vh - 60px);
  overflow-y: auto;
  padding: 8px;
}

.search-result-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.search-result-item:hover {
  background: var(--color-bg-secondary);
}

.search-result-title {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
}

.search-result-desc {
  font-size: 13px;
  color: var(--color-text-muted);
}

.search-empty {
  padding: 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* 快捷键提示 */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 6px;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-secondary);
  box-shadow: 0 1px 0 var(--color-border);
}

/* 页脚 */
.footer {
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 16px;
}

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 1024px) {
  .content {
    margin-left: 0;
    padding: 24px;
    max-width: 100%;
  }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .menu-toggle {
    display: flex;
  }
  
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 850;
    display: none;
  }
  
  .overlay.active {
    display: block;
  }
}

@media (max-width: 640px) {
  .header {
    padding: 0 16px;
  }
  
  .content {
    padding: 20px 16px;
  }
  
  h1 {
    font-size: 30px;
  }
  
  h2 {
    font-size: 22px;
  }
  
  .hero-title {
    font-size: 34px;
  }
  
  .hero-desc {
    font-size: 17px;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
  }
  
  .feature-list {
    grid-template-columns: 1fr;
  }
}

/* 平滑滚动和选中高亮 */
::selection {
  background: var(--color-primary-light);
  color: var(--color-text);
}

[data-theme="dark"] ::selection {
  background: rgba(59, 130, 246, 0.3);
  color: #f1f5f9;
}

/* 打印样式 */
@media print {
  .header, .sidebar, .toc-sidebar, .overlay {
    display: none !important;
  }
  .content {
    margin-left: 0;
    max-width: 100%;
  }
}
