/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  color: #e0e0e0; background: #0d1117; line-height: 1.7;
  display: flex; min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────── */
#sidebar {
  width: 300px; min-width: 300px; background: #161b22;
  border-right: 1px solid #30363d; overflow-y: auto;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  display: flex; flex-direction: column;
}
#sidebar-header {
  padding: 20px 16px 12px; border-bottom: 1px solid #30363d;
  background: #0d1117; position: sticky; top: 0; z-index: 10;
}
#sidebar-header h1 { font-size: 1.15rem; color: #58a6ff; font-weight: 700; letter-spacing: 0.5px; }
#sidebar-header .subtitle { font-size: 0.75rem; color: #8b949e; margin-top: 2px; }
#sidebar-search {
  width: 100%; padding: 7px 10px; margin-top: 10px;
  background: #0d1117; border: 1px solid #30363d; border-radius: 6px;
  color: #c9d1d9; font-size: 0.85rem; outline: none;
}
#sidebar-search:focus { border-color: #58a6ff; }
#sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }

.nav-group { margin-bottom: 2px; }
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; font-size: 0.75rem; font-weight: 700;
  color: #8b949e; text-transform: uppercase; letter-spacing: 1px;
  cursor: pointer; user-select: none; transition: color 0.15s;
}
.nav-group-title:hover { color: #c9d1d9; }
.nav-group-title .arrow { transition: transform 0.2s; font-size: 0.65rem; }
.nav-group.collapsed .arrow { transform: rotate(-90deg); }
.nav-group.collapsed .nav-items { display: none; }
.nav-items { list-style: none; }
.nav-item a {
  display: block; padding: 5px 16px 5px 28px; font-size: 0.85rem;
  color: #8b949e; text-decoration: none; transition: all 0.15s;
  border-left: 2px solid transparent;
}
.nav-item a:hover { color: #c9d1d9; background: rgba(88,166,255,0.06); }
.nav-item a.active { color: #58a6ff; background: rgba(88,166,255,0.1); border-left-color: #58a6ff; }

/* ── Main Content ─────────────────────────────────────── */
#content { margin-left: 300px; flex: 1; padding: 40px 60px 80px; max-width: 960px; }

.doc-section { margin-bottom: 60px; scroll-margin-top: 20px; }
.doc-section h2 {
  font-size: 1.6rem; color: #f0f6fc; font-weight: 700;
  border-bottom: 1px solid #21262d; padding-bottom: 10px; margin-bottom: 20px;
}
.doc-section h3 { font-size: 1.2rem; color: #c9d1d9; font-weight: 600; margin: 28px 0 12px; }
.doc-section h4 { font-size: 1rem; color: #8b949e; font-weight: 600; margin: 20px 0 8px; }
.doc-section p { margin-bottom: 14px; color: #c9d1d9; }
.doc-section ul, .doc-section ol { margin: 0 0 14px 24px; color: #c9d1d9; }
.doc-section li { margin-bottom: 4px; }
.doc-section strong { color: #f0f6fc; }
.doc-section em { color: #8b949e; font-style: italic; }

pre {
  background: #161b22; border: 1px solid #30363d; border-radius: 6px;
  padding: 16px; overflow-x: auto; margin: 12px 0 18px;
  font-family: 'Fira Code','Cascadia Code','JetBrains Mono','Consolas',monospace;
  font-size: 0.85rem; line-height: 1.5; color: #c9d1d9;
}
code {
  font-family: 'Fira Code','Cascadia Code','JetBrains Mono','Consolas',monospace;
  font-size: 0.85em;
}
p code, li code, td code {
  background: #1c2129; padding: 2px 6px; border-radius: 4px;
  color: #79c0ff; font-size: 0.85em;
}

table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 0.9rem; }
th, td { padding: 10px 14px; text-align: left; border: 1px solid #21262d; }
th { background: #161b22; color: #f0f6fc; font-weight: 600; }
td { color: #c9d1d9; }
tr:nth-child(even) td { background: rgba(22,27,34,0.5); }

.callout {
  padding: 14px 18px; border-radius: 6px; margin: 14px 0 18px;
  border-left: 4px solid; font-size: 0.9rem;
}
.callout.info { background: rgba(88,166,255,0.08); border-color: #58a6ff; }
.callout.warn { background: rgba(210,153,34,0.08); border-color: #d29922; }
.callout.tip { background: rgba(63,185,80,0.08); border-color: #3fb950; }
.callout.danger { background: rgba(248,81,73,0.08); border-color: #f85149; }
.callout-title { font-weight: 700; margin-bottom: 4px; }
.callout.info .callout-title { color: #58a6ff; }
.callout.warn .callout-title { color: #d29922; }
.callout.tip .callout-title { color: #3fb950; }
.callout.danger .callout-title { color: #f85149; }

.diagram {
  background: #0d1117; border: 1px solid #30363d; border-radius: 6px;
  padding: 20px; margin: 14px 0 18px; overflow-x: auto;
  font-family: 'Fira Code',monospace; font-size: 0.8rem;
  line-height: 1.4; color: #7ee787; white-space: pre;
}

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 0.72rem; font-weight: 600; margin-right: 4px;
}
.badge-blue { background: rgba(88,166,255,0.15); color: #58a6ff; }
.badge-green { background: rgba(63,185,80,0.15); color: #3fb950; }
.badge-orange { background: rgba(210,153,34,0.15); color: #d29922; }
.badge-red { background: rgba(248,81,73,0.15); color: #f85149; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin: 16px 0 24px;
}
.stat-card {
  background: #161b22; border: 1px solid #30363d; border-radius: 8px;
  padding: 16px; text-align: center;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: #58a6ff; }
.stat-card .stat-label { font-size: 0.78rem; color: #8b949e; margin-top: 2px; }

.tool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px; margin: 12px 0 18px;
}
.tool-card {
  background: #161b22; border: 1px solid #21262d; border-radius: 6px;
  padding: 10px 12px; font-size: 0.82rem;
}
.tool-card .tool-name { color: #79c0ff; font-weight: 600; font-family: monospace; }
.tool-card .tool-desc { color: #8b949e; font-size: 0.78rem; margin-top: 2px; }

#scroll-top {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: #58a6ff; color: #0d1117; border: none; border-radius: 50%;
  width: 40px; height: 40px; cursor: pointer; font-size: 1.2rem;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
#scroll-top:hover { background: #79c0ff; }

@media (max-width: 768px) {
  #sidebar { width: 260px; min-width: 260px; transform: translateX(-260px); transition: transform 0.3s; }
  #sidebar.open { transform: translateX(0); }
  #content { margin-left: 0; padding: 20px; }
  #mobile-toggle { display: block; }
}
@media (min-width: 769px) { #mobile-toggle { display: none; } }
#mobile-toggle {
  position: fixed; top: 12px; left: 12px; z-index: 200;
  background: #161b22; border: 1px solid #30363d; border-radius: 6px;
  color: #c9d1d9; padding: 8px 12px; cursor: pointer; font-size: 1.1rem;
}

/* ── Glossary Tooltips ────────────────────────────────── */
.glossary {
  border-bottom: 1px dashed #58a6ff; cursor: help; position: relative;
  color: #79c0ff;
}
.glossary:hover::after {
  content: attr(data-def);
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #1c2129; border: 1px solid #30363d; border-radius: 6px;
  padding: 8px 12px; font-size: 0.8rem; color: #c9d1d9;
  white-space: normal; width: 260px; z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4); line-height: 1.5;
  pointer-events: none;
}

/* ── Expandable Details ───────────────────────────────── */
details.expand {
  background: #161b22; border: 1px solid #30363d; border-radius: 6px;
  margin: 12px 0 18px; overflow: hidden;
}
details.expand summary {
  padding: 12px 16px; cursor: pointer; font-weight: 600;
  color: #58a6ff; font-size: 0.9rem; user-select: none;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.expand summary::before { content: "\\25B6"; font-size: 0.7rem; transition: transform 0.2s; }
details.expand[open] summary::before { transform: rotate(90deg); }
details.expand .expand-content { padding: 0 16px 16px; }

/* ── Try-It Terminal Boxes ────────────────────────────── */
.try-it {
  background: #0d1117; border: 1px solid #30363d; border-radius: 8px;
  margin: 14px 0 18px; overflow: hidden;
}
.try-it-header {
  background: #161b22; padding: 8px 14px; display: flex;
  align-items: center; justify-content: space-between;
  border-bottom: 1px solid #21262d;
}
.try-it-header .dots { display: flex; gap: 6px; }
.try-it-header .dot { width: 10px; height: 10px; border-radius: 50%; }
.try-it-header .dot.red { background: #f85149; }
.try-it-header .dot.yellow { background: #d29922; }
.try-it-header .dot.green { background: #3fb950; }
.try-it-header .label { font-size: 0.72rem; color: #8b949e; font-weight: 600; }
.try-it-body {
  padding: 14px 16px; font-family: 'Fira Code', monospace;
  font-size: 0.82rem; line-height: 1.6; color: #c9d1d9;
  white-space: pre-wrap;
}
.try-it-body .prompt { color: #3fb950; }
.try-it-body .output { color: #8b949e; }
.try-it-body .highlight { color: #79c0ff; }
.try-it-copy {
  background: none; border: 1px solid #30363d; border-radius: 4px;
  color: #8b949e; padding: 3px 8px; font-size: 0.7rem; cursor: pointer;
}
.try-it-copy:hover { color: #c9d1d9; border-color: #58a6ff; }

/* ── Dark/Light Toggle ────────────────────────────────── */
#theme-toggle {
  position: fixed; top: 12px; right: 24px; z-index: 200;
  background: #161b22; border: 1px solid #30363d; border-radius: 6px;
  color: #c9d1d9; padding: 6px 10px; cursor: pointer; font-size: 1rem;
}
#theme-toggle:hover { border-color: #58a6ff; }

/* Light mode overrides */
body.light { background: #ffffff; color: #1f2328; }
body.light #sidebar { background: #f6f8fa; border-color: #d0d7de; }
body.light #sidebar-header { background: #ffffff; border-color: #d0d7de; }
body.light #sidebar-header h1 { color: #0969da; }
body.light #sidebar-search { background: #fff; border-color: #d0d7de; color: #1f2328; }
body.light .nav-group-title { color: #656d76; }
body.light .nav-item a { color: #656d76; }
body.light .nav-item a:hover { color: #1f2328; background: rgba(9,105,218,0.06); }
body.light .nav-item a.active { color: #0969da; background: rgba(9,105,218,0.08); border-left-color: #0969da; }
body.light #content { color: #1f2328; }
body.light .doc-section h2 { color: #1f2328; border-color: #d0d7de; }
body.light .doc-section h3 { color: #1f2328; }
body.light .doc-section p, body.light .doc-section li, body.light td { color: #1f2328; }
body.light .doc-section strong { color: #1f2328; }
body.light pre { background: #f6f8fa; border-color: #d0d7de; color: #1f2328; }
body.light p code, body.light li code, body.light td code { background: #eff1f3; color: #0550ae; }
body.light th { background: #f6f8fa; color: #1f2328; }
body.light th, body.light td { border-color: #d0d7de; }
body.light .callout.info { background: rgba(9,105,218,0.06); }
body.light .callout.tip { background: rgba(26,127,55,0.06); }
body.light .callout.warn { background: rgba(154,103,0,0.06); }
body.light .callout.danger { background: rgba(207,34,46,0.06); }
body.light .diagram { background: #f6f8fa; border-color: #d0d7de; color: #1a7f37; }
body.light .stat-card { background: #f6f8fa; border-color: #d0d7de; }
body.light .stat-card .stat-value { color: #0969da; }
body.light .tool-card { background: #f6f8fa; border-color: #d0d7de; }
body.light .glossary { color: #0550ae; border-color: #0969da; }
body.light .glossary:hover::after { background: #fff; border-color: #d0d7de; color: #1f2328; }
body.light details.expand { background: #f6f8fa; border-color: #d0d7de; }
body.light .try-it { background: #f6f8fa; border-color: #d0d7de; }
body.light .try-it-header { background: #eff1f3; border-color: #d0d7de; }
body.light .try-it-body { color: #1f2328; }
body.light #theme-toggle { background: #f6f8fa; border-color: #d0d7de; color: #1f2328; }
body.light #scroll-top { background: #0969da; }
body.light tr:nth-child(even) td { background: rgba(246,248,250,0.5); }

/* ── Animated Flow Arrow ──────────────────────────────── */
.flow-step {
  display: flex; align-items: center; gap: 12px; margin: 8px 0;
  padding: 10px 14px; background: #161b22; border: 1px solid #21262d;
  border-radius: 6px; font-size: 0.88rem;
}
.flow-step .step-num {
  background: #58a6ff; color: #0d1117; width: 28px; height: 28px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.flow-step .step-text { color: #c9d1d9; }
.flow-step .step-text strong { color: #f0f6fc; }
.flow-arrow { text-align: center; color: #30363d; font-size: 1.2rem; margin: 2px 0; }
body.light .flow-step { background: #f6f8fa; border-color: #d0d7de; }
body.light .flow-step .step-text { color: #1f2328; }

/* ── Scenario conversation ────────────────────────────── */
.convo { margin: 12px 0 18px; }
.convo-msg {
  display: flex; gap: 10px; margin: 6px 0; align-items: flex-start;
}
.convo-avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 0.9rem;
  flex-shrink: 0; font-weight: 700;
}
.convo-avatar.user { background: #1f6feb; color: #fff; }
.convo-avatar.bot { background: #238636; color: #fff; }
.convo-bubble {
  background: #161b22; border: 1px solid #21262d; border-radius: 8px;
  padding: 8px 12px; font-size: 0.85rem; color: #c9d1d9; max-width: 80%;
}
.convo-bubble code { background: #1c2129; padding: 1px 4px; border-radius: 3px; color: #79c0ff; }
body.light .convo-bubble { background: #f6f8fa; border-color: #d0d7de; color: #1f2328; }
body.light .convo-avatar.user { background: #0969da; }
body.light .convo-avatar.bot { background: #1a7f37; }
