/* ── Reset & tokens ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 260px;
  --topbar-h:  52px;
  --bg:        #ffffff;
  --bg-sidebar:#0f172a;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --text-muted:#64748b;
  --link:      #2563eb;
  --link-hover:#1d4ed8;
  --active-bg: #1e3a5f;
  --active-txt:#60a5fa;
  --section-hdr:#94a3b8;
  --code-bg:   #f1f5f9;
  --code-border:#e2e8f0;
  --accent:    #2563eb;
  --radius:    6px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  display: flex;
}

/* ── Overlay ─────────────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 40;
}
.overlay.visible { display: block; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.logo-img {
  height: 28px;
  width: auto;
  display: block;
  /* Invert to white so logo reads well on the dark sidebar */
  filter: brightness(0) invert(1);
}

/* ── Nav tree ────────────────────────────────────────────────────── */
.nav-tree {
  padding: 12px 0 24px;
  overflow-y: auto;
  flex: 1;
}

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

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--section-hdr);
  cursor: pointer;
  user-select: none;
}
.nav-section-header:hover { color: #cbd5e1; }

.nav-arrow {
  transition: transform .2s;
  flex-shrink: 0;
}
.nav-section-header.open .nav-arrow { transform: rotate(90deg); }

.nav-children { overflow: hidden; }
.nav-children.collapsed { display: none; }

.nav-link {
  display: block;
  padding: 6px 20px 6px 28px;
  font-size: 13px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0;
  transition: color .15s, background .15s;
  line-height: 1.4;
}
.nav-link.top-level {
  padding-left: 20px;
  font-size: 13.5px;
  color: #cbd5e1;
}
.nav-link:hover { color: #f1f5f9; background: rgba(255,255,255,.05); }
.nav-link.active {
  color: var(--active-txt);
  background: var(--active-bg);
  font-weight: 600;
}

/* ── Layout ──────────────────────────────────────────────────────── */
.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.menu-btn {
  display: none;
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Content ─────────────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}
.content-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

.loading {
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 14px;
}

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 20px 24px;
  color: #991b1b;
}

/* ── Markdown content ────────────────────────────────────────────── */
.content-inner h1 {
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
  line-height: 1.25;
}
.content-inner h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1e293b;
  margin-top: 36px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.content-inner h3 {
  font-size: 16px;
  font-weight: 600;
  color: #334155;
  margin-top: 24px;
  margin-bottom: 8px;
}
.content-inner h4 {
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  margin-top: 18px;
  margin-bottom: 6px;
}

.content-inner p { margin-bottom: 14px; }

.content-inner ul, .content-inner ol {
  margin: 8px 0 14px 24px;
}
.content-inner li { margin-bottom: 5px; }

.content-inner a { color: var(--link); text-decoration: none; }
.content-inner a:hover { color: var(--link-hover); text-decoration: underline; }

.content-inner code {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 13px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 1px 6px;
  color: #0f172a;
}

.content-inner pre {
  background: #0f172a;
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 14px 0 20px;
}
.content-inner pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.6;
}

.content-inner table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 20px;
  font-size: 14px;
}
.content-inner thead tr { background: #f8fafc; }
.content-inner th {
  text-align: left;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 13px;
  color: #475569;
  border-bottom: 2px solid var(--border);
}
.content-inner td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.content-inner tr:last-child td { border-bottom: none; }

/* Home page nav tables — hide the empty header row */
.content-inner table thead tr th:empty,
.content-inner table thead tr:has(th:empty) {
  display: none;
}
.content-inner table thead tr th:empty ~ th {
  display: none;
}

.content-inner blockquote {
  border-left: 3px solid var(--accent);
  background: #eff6ff;
  padding: 12px 16px;
  margin: 14px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: #1e3a5f;
}

.content-inner hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* ── API Reference (Redoc full-width mode) ───────────────────────── */
.content-inner.redoc-mode {
  max-width: none;
  padding: 0;
  margin: 0;
}

/* Separator above API Reference nav link */
.nav-link-apiref {
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 14px !important;
  color: #60a5fa !important;
  font-weight: 600 !important;
}
.nav-link-apiref:hover { color: #93c5fd !important; }

/* ── Country toggle ──────────────────────────────────────────────── */
.country-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 20px;
}

.country-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border: 1.5px solid #cbd5e1;
  border-radius: 20px;
  background: #fff;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
  font-family: inherit;
}
.country-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}
.country-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  font-weight: 600;
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { display: block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    height: 100%;
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); }

  .layout { min-height: 100vh; }

  .menu-btn { display: block; }

  .content-inner { padding: 24px 20px 60px; }
}
