/* ═══════════════════════════════════════════════════════
   MidnightService API — Documentation Theme
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #08080d;
  --bg-secondary: #0e0e16;
  --bg-tertiary: #15151f;
  --bg-card: #111119;
  --bg-code: #0c0c14;

  --text-primary: rgba(255, 255, 255, 0.92);
  --text-secondary: rgba(160, 170, 190, 0.85);
  --text-muted: rgba(120, 130, 150, 0.7);

  --accent: #667eea;
  --accent-dim: rgba(102, 126, 234, 0.15);
  --accent-glow: rgba(102, 126, 234, 0.25);
  --purple: #9f7aea;
  --green: #48d89b;
  --red: #f56565;
  --orange: #ed8936;
  --blue: #4fd1c5;
  --yellow: #ecc94b;

  --border: rgba(102, 126, 234, 0.12);
  --border-hover: rgba(102, 126, 234, 0.28);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-width: 280px;

  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  --gradient-subtle: linear-gradient(135deg, rgba(102,126,234,0.1), rgba(118,75,162,0.08));
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 2rem; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% -10%, rgba(102,126,234,0.12), transparent),
    radial-gradient(ellipse 50% 40% at 85% 110%, rgba(118,75,162,0.08), transparent);
  pointer-events: none;
  z-index: -1;
}

::selection { background: rgba(102,126,234,0.3); }
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: #8fa4f0; }
code { font-family: var(--mono); }

* { scrollbar-width: thin; scrollbar-color: rgba(102,126,234,0.25) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(102,126,234,0.3); border-radius: 10px; }

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon { font-size: 1.25rem; }
.logo-text { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.logo-accent { color: var(--accent); }

.version-badge {
  font-size: 0.7rem;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px 24px;
}

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

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-decoration: none;
}

.nav-link:hover {
  background: rgba(102,126,234,0.06);
  color: var(--text-primary);
  transform: translateX(2px);
}

.nav-link.active {
  background: rgba(102,126,234,0.1);
  color: var(--accent);
  font-weight: 500;
}

/* ─── Method badges ─── */
.method-badge {
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.method-badge.post { background: rgba(0,180,255,0.15); color: #4fd1f5; }
.method-badge.get { background: rgba(72,216,155,0.15); color: #48d89b; }
.method-badge.large { font-size: 0.75rem; padding: 4px 10px; border-radius: 6px; }

/* ─── Mobile header ─── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(8,8,13,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  align-items: center;
  gap: 12px;
  z-index: 90;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

.overlay.visible { display: block; }

/* ─── Main Content ─── */
.content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  max-width: 900px;
  padding: 0 48px 80px;
}

.section {
  padding-top: 64px;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.2;
  margin-bottom: 16px;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 12px;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 32px;
  margin-bottom: 12px;
}

p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  max-width: 680px;
}

/* ─── Hero ─── */
.hero-section { padding-top: 80px; }

.hero-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--mono);
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

.hero-desc {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-secondary);
  max-width: 560px;
}

.hero-cards {
  display: flex;
  gap: 16px;
  margin: 32px 0;
}

.stat-card {
  padding: 20px 28px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-width: 120px;
  transition: border-color 0.2s, transform 0.2s;
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--mono);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.base-url-block {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--bg-code);
  border: 1px solid var(--border);
  margin-top: 8px;
}

.base-url-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.base-url {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--accent);
}

/* ─── Steps ─── */
.steps {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 28px 0 32px;
}

.step {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(102,126,234,0.2);
}

.step-body h3 { margin-top: 0; margin-bottom: 4px; font-size: 1rem; }
.step-body p { margin-bottom: 0; font-size: 0.9rem; }

.step-body code {
  font-size: 0.82rem;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent-dim);
  color: var(--accent);
}

/* ─── Code blocks ─── */
.code-example { margin: 24px 0; }

.code-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: -1px;
  position: relative;
  z-index: 2;
}

.code-tab {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.code-tab:hover { color: var(--text-secondary); }
.code-tab.active {
  background: var(--bg-code);
  color: var(--accent);
  border-color: var(--border);
}

pre.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.7;
  position: relative;
}

.code-tabs + pre.code-block,
.code-tabs ~ pre.code-block:not(.hidden) {
  border-top-left-radius: 0;
}

pre.code-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(102,126,234,0.4), transparent);
}

pre.code-block code {
  color: var(--text-secondary);
  font-size: inherit;
  white-space: pre;
}

.hidden { display: none !important; }

pre.inline-code {
  display: inline-block;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  margin-top: 8px;
}

/* Inline code in paragraphs */
p code,
span code,
td code,
.param-row code {
  font-size: 0.82em;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent-dim);
  color: var(--accent);
}

/* ─── Endpoint header ─── */
.endpoint-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.endpoint-path {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: none;
  padding: 0;
}

/* ─── Params table ─── */
.params-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 16px 0 24px;
}

.param-row {
  display: grid;
  grid-template-columns: 140px 80px 60px 1fr;
  padding: 12px 16px;
  gap: 12px;
  align-items: center;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.param-row:last-child { border-bottom: none; }

.param-row.header {
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.param-row span { color: var(--text-secondary); }
.required { color: var(--red) !important; font-weight: 600; }
.optional { color: var(--text-muted) !important; }

/* ─── Info cards ─── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0 28px;
}

.info-card {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color 0.2s, transform 0.2s;
}

.info-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.info-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.info-icon { font-size: 1.3rem; }
.info-card h3 { margin: 0; font-size: 1rem; }
.info-card p { font-size: 0.85rem; margin-bottom: 0; }

/* ─── Warning block ─── */
.warning-block {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: rgba(237, 137, 54, 0.06);
  border: 1px solid rgba(237, 137, 54, 0.2);
  margin: 20px 0;
  align-items: flex-start;
}

.warning-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 2px; }
.warning-block strong { color: var(--orange); }
.warning-block code { font-size: 0.82em; }

/* ─── Errors table ─── */
.errors-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 16px 0 28px;
}

.error-row {
  display: grid;
  grid-template-columns: 70px 140px 1fr;
  padding: 12px 16px;
  gap: 16px;
  align-items: center;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.error-row:last-child { border-bottom: none; }

.error-row.header {
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.error-row span { color: var(--text-secondary); }

.error-code {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.9rem;
}

.c400 { color: var(--yellow) !important; }
.c401 { color: var(--orange) !important; }
.c403 { color: var(--red) !important; }
.c500 { color: var(--red) !important; }

/* ─── Model cards ─── */
.model-card {
  padding: 24px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.model-card h3 {
  margin-top: 0;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--accent);
}

.model-card p {
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.model-card pre.code-block {
  margin: 0;
  font-size: 0.8rem;
}

/* ─── Footer ─── */
.footer {
  margin-top: 64px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-sep { opacity: 0.4; }
.footer a { font-size: 0.8rem; }

/* ─── Responsive ─── */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open { transform: translateX(0); }
  .mobile-header { display: flex; }

  .content {
    margin-left: 0;
    padding: 72px 24px 64px;
    max-width: 100%;
  }

  h1 { font-size: 2rem; }
  .hero-section { padding-top: 40px; }

  .info-grid { grid-template-columns: 1fr; }

  .param-row {
    grid-template-columns: 120px 70px 50px 1fr;
    font-size: 0.8rem;
  }

  .error-row {
    grid-template-columns: 60px 120px 1fr;
    font-size: 0.8rem;
  }
}

@media (max-width: 600px) {
  .content { padding: 68px 16px 48px; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.25rem; }

  .hero-cards { flex-direction: column; }
  .stat-card { min-width: auto; }

  .base-url-block {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .base-url { font-size: 0.75rem; word-break: break-all; }

  .param-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .param-row.header { display: none; }

  .param-row code {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-primary);
  }

  .error-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .error-row.header { display: none; }

  pre.code-block { padding: 14px 16px; font-size: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}

@media print {
  .sidebar, .mobile-header, .overlay { display: none !important; }
  .content { margin-left: 0; }
  body { background: #fff; color: #000; }
  body::before { display: none; }
}
