/* ── Shared Variables (same as main site) ──────────────────────── */

:root {
  --bg: #FFFFFF;
  --bg-subtle: #F8FAFC;
  --card: #FFFFFF;
  --card-border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  --accent: #EF4444;
  --accent-hover: #DC2626;
  --code-bg: #F1F5F9;
  --code-border: #E2E8F0;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
  --sidebar-w: 240px;
  --transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0F172A;
  --bg-subtle: #1E293B;
  --card: #1E293B;
  --card-border: #334155;
  --text: #E2E8F0;
  --text-muted: #94A3B8;
  --accent: #EF4444;
  --accent-hover: #F87171;
  --code-bg: #1E293B;
  --code-border: #334155;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ──────────────────────────────────────────────────────── */

html { scroll-behavior: smooth; scroll-padding-top: 4rem; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: var(--transition);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Nav ───────────────────────────────────────────────────────── */

nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
  transition: var(--transition);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.125rem;
}

.nav-brand img { height: 24px; width: 24px; }

.nav-spacer { flex: 1; }

.nav-link {
  color: var(--text-muted);
  transition: color 0.15s;
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 500;
}

.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--accent); }

#theme-toggle {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1;
  transition: var(--transition);
  display: flex;
  align-items: center;
}

#theme-toggle:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Layout ────────────────────────────────────────────────────── */

.docs-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 3.5rem);
}

/* ── Sidebar ───────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 3.5rem;
  height: calc(100vh - 3.5rem);
  overflow-y: auto;
  border-right: 1px solid var(--card-border);
  padding: 1.5rem 1rem;
  transition: var(--transition);
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-heading {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
}

.sidebar a {
  display: block;
  padding: 0.25rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  border-radius: 4px;
  transition: color 0.15s, background-color 0.15s;
  line-height: 1.5;
}

.sidebar a:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.sidebar a.active {
  color: var(--accent);
  background: var(--bg-subtle);
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 30;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  align-items: center;
  justify-content: center;
}

/* ── Content ───────────────────────────────────────────────────── */

.docs-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem;
  max-width: 900px;
}

.docs-content section {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--card-border);
}

.docs-content section:last-child {
  border-bottom: none;
}

.docs-content h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.docs-content h1 + p {
  color: var(--text-muted);
  font-size: 1.0625rem;
  margin-bottom: 2rem;
}

.docs-content h2 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  padding-top: 0.5rem;
}

.docs-content h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
}

.docs-content h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  margin-top: 1.25rem;
  color: var(--text-muted);
}

.docs-content p {
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.docs-content ul, .docs-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.docs-content li {
  margin-bottom: 0.375rem;
  font-size: 0.9375rem;
}

/* ── Code ──────────────────────────────────────────────────────── */

pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  transition: var(--transition);
  margin-bottom: 1rem;
}

code {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

p code, li code, td code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.125rem 0.375rem;
  font-size: 0.8125rem;
  transition: var(--transition);
}

/* Syntax colors */
.kw { color: #8B5CF6; }
.str { color: #059669; }
.cm { color: var(--text-muted); font-style: italic; }
.fn { color: #2563EB; }
.op { color: var(--text-muted); }

[data-theme="dark"] .kw { color: #A78BFA; }
[data-theme="dark"] .str { color: #34D399; }
[data-theme="dark"] .fn { color: #60A5FA; }

/* ── Tables ────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-bottom: 1.5rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--card-border);
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--card-border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }

/* ── Config table variant ──────────────────────────────────────── */

.config-table {
  font-size: 0.8125rem;
}

.config-table td:first-child {
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: nowrap;
  color: var(--accent);
}

.config-table td:nth-child(2) {
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

.config-table td:nth-child(3) {
  font-family: var(--mono);
  font-size: 0.75rem;
}

/* ── Callout boxes ─────────────────────────────────────────────── */

.callout {
  padding: 0.875rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--bg-subtle);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.callout-title {
  font-weight: 600;
  font-size: 0.8125rem;
  margin-bottom: 0.25rem;
}

.callout-warn {
  border-color: #F59E0B;
  background: #FFFBEB;
}

[data-theme="dark"] .callout-warn {
  background: #451a0333;
  border-color: #B45309;
}

/* ── Tabs ──────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--card-border);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-family: var(--font);
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Footer ────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--card-border);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

footer a { color: var(--text-muted); }
footer a:hover { color: var(--accent); }

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar {
    display: none;
    position: fixed;
    top: 3.5rem;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100vh - 3.5rem);
    z-index: 15;
    background: var(--bg);
    border-right: none;
    border-bottom: 1px solid var(--card-border);
  }

  .sidebar.open { display: block; }

  .sidebar-toggle { display: flex; }

  .docs-content {
    padding: 1.5rem 1rem;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}

/* ── Icon toggle ───────────────────────────────────────────────── */

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
