/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4D527F;
  --primary-light: #6b70a0;
  --primary-dark: #3a3e61;
  --accent: #F2A65A;
  --accent-light: #f5bc7e;
  --bg: #FAF9F7;
  --bg-card: #ffffff;
  --text: #3F3D55;
  --text-light: #6b6980;
  --text-muted: #9994ad;
  --code-bg: #1a1a2e;
  --code-text: #e0def4;
  --border: #e8e6e1;
  --border-light: #f0eeea;
  --sidebar-width: 280px;
  --topbar-height: 60px;
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ===== TOP BAR ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

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

.topbar-logo img {
  width: 28px;
  height: 28px;
}

.topbar-logo span {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 14px;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-link {
  color: var(--text-light);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s;
}

.topbar-link:hover { color: var(--primary); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover { background: var(--primary-light); }
.btn-primary:active { transform: scale(0.98); }

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

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0;
  z-index: 900;
  transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-section {
  padding: 0 16px;
  margin-bottom: 8px;
}

.sidebar-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  color: var(--text-light);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.12s;
  line-height: 1.4;
}

.sidebar-link:hover {
  color: var(--primary);
  background: rgba(77, 82, 127, 0.05);
}

.sidebar-link.active {
  color: var(--primary);
  background: rgba(77, 82, 127, 0.08);
  font-weight: 600;
}

.sidebar-link .method {
  font-size: 9px;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.method-get { background: #dff0d8; color: #3c763d; }
.method-post { background: #d9edf7; color: #31708f; }

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

/* ===== MAIN CONTENT ===== */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
}

.content {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 60px 0 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: rgba(77, 82, 127, 0.08);
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

.hero h1 {
  font-size: 42px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 14px;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero p {
  font-size: 18px;
  color: var(--text-light);
  max-width: 520px;
  margin: 0 auto 28px;
  line-height: 1.6;
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: rgba(77, 82, 127, 0.04);
}

.btn-hero {
  padding: 12px 28px;
  font-size: 15px;
  border-radius: 8px;
}

/* ===== SECTIONS ===== */
section {
  margin-bottom: 56px;
}

section:last-of-type {
  margin-bottom: 0;
}

h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
  letter-spacing: -0.015em;
  padding-top: 8px;
}

h2 .anchor {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  font-weight: 400;
}

h2:hover .anchor { opacity: 1; }

h3 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin-top: 36px;
  margin-bottom: 10px;
}

h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 8px;
}

p {
  margin-bottom: 14px;
  color: var(--text);
}

.section-desc {
  color: var(--text-light);
  font-size: 16px;
  margin-bottom: 24px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

/* ===== CODE ===== */
code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace;
  font-size: 0.88em;
}

:not(pre) > code {
  background: rgba(77, 82, 127, 0.07);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin: 16px 0 20px;
  position: relative;
}

pre code {
  display: block;
  padding: 20px 24px;
  font-size: 13px;
  line-height: 1.7;
  font-weight: 400;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.code-header + code {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.code-lang {
  font-size: 12px;
  font-weight: 600;
  color: rgba(224, 222, 244, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(224, 222, 244, 0.5);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 500;
  transition: all 0.15s;
}

.copy-btn:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.25);
}

/* Syntax highlighting tokens */
.tok-kw { color: #c4a7e7; }   /* keywords */
.tok-str { color: #f6c177; }  /* strings */
.tok-fn { color: #9ccfd8; }   /* functions */
.tok-cm { color: #6e6a86; }   /* comments */
.tok-num { color: #eb6f92; }  /* numbers */
.tok-op { color: #908caa; }   /* operators */
.tok-prop { color: #e0def4; } /* properties */
.tok-key { color: #9ccfd8; }  /* JSON keys */
.tok-bool { color: #eb6f92; } /* booleans */
.tok-type { color: #c4a7e7; } /* types */
.tok-const { color: #e0def4; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 16px 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.card-grid .card {
  margin: 0;
}

.card h4 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 14px;
}

.card p {
  font-size: 13.5px;
  color: var(--text-light);
  margin-bottom: 0;
}

.card .icon {
  width: 36px;
  height: 36px;
  background: rgba(77, 82, 127, 0.08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 16px;
}

/* ===== TABLES ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 20px;
  font-size: 14px;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  padding: 10px 16px;
  background: rgba(77, 82, 127, 0.04);
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

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

.param-name {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.param-type {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.param-required {
  font-size: 11px;
  font-weight: 700;
  color: #e05252;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.param-optional {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ===== ENDPOINT BLOCKS ===== */
.endpoint {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin: 24px 0;
  overflow: hidden;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
  cursor: default;
}

.endpoint-method {
  font-size: 12px;
  font-weight: 800;
  font-family: 'SF Mono', Menlo, monospace;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.endpoint-method.get { background: #dff0d8; color: #3c763d; }
.endpoint-method.post { background: #d9edf7; color: #31708f; }

.endpoint-path {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.endpoint-path .param {
  color: var(--accent);
}

.endpoint-desc {
  font-size: 14px;
  color: var(--text-light);
  margin-left: auto;
}

.endpoint-body {
  padding: 20px 24px;
}

.endpoint-body > h4:first-child {
  margin-top: 0;
}

/* ===== CALLOUT ===== */
.callout {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.callout-info {
  background: rgba(77, 82, 127, 0.06);
  border-left: 3px solid var(--primary);
  color: var(--text);
}

.callout-warn {
  background: rgba(242, 166, 90, 0.1);
  border-left: 3px solid var(--accent);
  color: var(--text);
}

.callout-icon {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1.5;
}

/* ===== TAG ===== */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.tag-green { background: #dff0d8; color: #3c763d; }
.tag-blue { background: #d9edf7; color: #31708f; }

/* ===== ERROR TABLE ===== */
.error-code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
}

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 40px 48px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.footer-links a {
  color: var(--text-light);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--primary); }

.footer-tagline {
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== INSTALL BOX ===== */
.install-box {
  background: var(--code-bg);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 20px;
}

.install-box code {
  color: var(--code-text);
  font-size: 14px;
}

.install-box .prefix {
  color: #6e6a86;
  margin-right: 8px;
  user-select: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .mobile-toggle {
    display: flex;
  }

  .content {
    padding: 32px 20px 60px;
  }

  .footer {
    padding: 32px 20px;
  }

  .hero h1 {
    font-size: 30px;
  }

  .hero {
    padding: 36px 0 32px;
  }

  .endpoint-desc {
    display: none;
  }

  .topbar-link.desktop-only {
    display: none;
  }
}

@media (max-width: 600px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }

  table {
    font-size: 13px;
  }

  th, td {
    padding: 8px 10px;
  }
}
