/* Import Modern Typography from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  color-scheme: light;
  
  /* Modern Slate/Zinc Palette - Light Theme */
  --bg: #fafafa;
  --bg-grid: #ffffff;
  --soft: #f4f4f5;
  --soft-2: #e4e4e7;
  --text: #09090b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: #e4e4e7;
  --code-bg: #09090b;
  --code-text: #f4f4f5;
  --panel: #ffffff;
  --panel-border: #e4e4e7;
  --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.04), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --header-bg: rgba(250, 250, 250, 0.85);
  
  /* Brand Green Theme */
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --accent-light: rgba(34, 197, 94, 0.06);
  --accent-glow: rgba(34, 197, 94, 0.18);
  
  --radius: 12px;
  --radius-sm: 8px;
  
  --green: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --glow: radial-gradient(circle at top right, rgba(34, 197, 94, 0.04), transparent 50%);
}

[data-theme="dark"] {
  color-scheme: dark;
  
  /* Premium Dark Theme */
  --bg: #09090b;
  --bg-grid: #09090b;
  --soft: #18181b;
  --soft-2: #27272a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --faint: #52525b;
  --line: #27272a;
  --code-bg: #0d0d10;
  --code-text: #f4f4f5;
  --panel: #18181b;
  --panel-border: #27272a;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --header-bg: rgba(9, 9, 11, 0.85);
  
  --accent-light: rgba(34, 197, 94, 0.15);
  --accent-glow: rgba(34, 197, 94, 0.25);
  --glow: radial-gradient(circle at top right, rgba(34, 197, 94, 0.08), transparent 50%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--glow);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  line-height: 1.625;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip; /* Fix layout overflow slides while keeping sticky positioning functional */
  transition: background-color 0.25s, color 0.25s;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

code,
pre {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* Site Header (Glassmorphic) */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 0 clamp(16px, 4vw, 48px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background-color 0.25s, border-color 0.25s;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  transition: transform 0.2s ease-in-out;
}

.brand:hover img {
  transform: scale(1.1);
}

.brand span {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 30%, var(--muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
  padding: 4px 8px;
  white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s;
}

.doc-search {
  flex: 0 1 340px;
  margin-left: 10px;
}

.doc-search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  padding: 0 16px;
  outline: none;
  font-size: .88rem;
  transition: all 0.2s ease-in-out;
}

.doc-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-grid);
}

.top-links {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}

.top-links a:hover {
  color: var(--accent);
}

/* Mobile Sidebar Trigger (Hamburger Button) */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-grid);
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.mobile-menu-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Mobile Sidebar Header */
.sidebar-header-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header-mobile span {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
}

.close-sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.close-sidebar-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Segmented Theme Switcher Control */
.theme-segmented-control {
  display: inline-flex;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.theme-control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-control-btn:hover {
  color: var(--text);
  background: var(--soft-2);
}

.theme-control-btn.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 2px 5px rgba(34, 197, 94, 0.25);
}

.theme-control-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-control-btn.active svg {
  stroke: #ffffff;
}

/* Page Layout Grid */
.docs-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  gap: 40px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px);
}

.docs-sidebar,
.on-this-page {
  position: sticky;
  top: 64px;
  align-self: start;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 32px 0;
}

.docs-sidebar {
  border-right: 1px solid var(--line);
  padding-right: 24px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-group {
  margin-bottom: 24px;
}

.sidebar-group p,
.on-this-page p {
  margin: 0 0 10px;
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-group a,
.on-this-page a {
  display: block;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.4;
  padding: 5px 0;
  transition: color 0.15s ease, padding-left 0.15s ease;
}

.sidebar-group a:hover,
.on-this-page a:hover {
  color: var(--accent);
  padding-left: 2px;
}

.sidebar-group a.active,
.on-this-page a.active {
  color: var(--accent);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}

.on-this-page {
  border-left: 1px solid var(--line);
  padding-left: 20px;
}

.on-this-page a.active {
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}

/* Article & Sections */
.doc-article {
  min-width: 0; /* Bind grid cell constraints */
  max-width: 820px;
  width: 100%;
  padding: 32px 0 80px;
}

.doc-article section {
  padding: 0 0 48px;
  margin-bottom: 48px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 80px;
}

.doc-article h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
}

.doc-article h2 {
  font-size: 1.75rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  margin: 32px 0 16px;
  border-bottom: none;
}

.doc-article h3 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 24px 0 10px;
}

.lead {
  font-size: 1.125rem;
  color: var(--muted);
  margin: 16px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.callout {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--text);
  padding: 14px 18px;
}

.callout strong {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  margin-bottom: 4px;
}

/* Code Blocks Styling */
pre {
  position: relative;
  margin: 20px 0;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  overflow-x: auto;
  max-width: 100%;
  padding: 16px 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

pre code {
  color: var(--code-text);
  font-size: .88rem;
  line-height: 1.6;
  white-space: pre;
  display: block;
}

:not(pre) > code {
  border-radius: 4px;
  background: var(--soft);
  color: var(--accent);
  padding: 2px 6px;
  font-size: .9em;
  font-weight: 600;
}

.copy-button {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid var(--faint);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--faint);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 8px;
  outline: none;
  transition: all 0.15s ease;
}

.copy-button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.mermaid {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 16px;
  overflow-x: auto;
  max-width: 100%;
}

.command-list {
  display: grid;
  gap: 8px;
  margin: 20px 0;
}

.command-list code {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--text);
  padding: 10px 14px;
}

/* API Tester Layout Box styling */
.tester-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 20px;
  margin: 24px 0;
  box-shadow: var(--shadow);
  transition: all 0.25s ease;
}

.tester-box:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.tester-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.tester-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tester-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: .7rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.input-field {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  font-size: .88rem;
  transition: all 0.2s;
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-grid);
}

.run-btn {
  height: 38px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  align-self: flex-start;
  transition: all 0.2s;
}

.run-btn:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* API Tester Result Display */
.tester-response {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.response-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  font-size: .8rem;
  font-weight: 600;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.status-dot.success { background: var(--green); }
.status-dot.warning { background: var(--warning); }
.status-dot.error { background: var(--error); }

.response-latency {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  margin-left: auto;
  margin-right: 14px;
}

/* Copy Response Button Styling */
.copy-response-btn {
  background: var(--bg-grid);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease-in-out;
}

.copy-response-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* API response pre formatted box setup (with vertical scrolling & max-height limit) */
.response-body-pre {
  margin: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  max-height: 380px; /* Limit block height to avoid page expansion */
  overflow-y: auto;  /* Enable vertical scrollbar */
  overflow-x: auto;  /* Enable horizontal scrollbar for long response lines */
  background: var(--code-bg);
}

/* Token Config Widget inside Sidebar */
.token-config-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.token-config-title {
  margin: 0 0 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.token-input-row {
  display: flex;
  gap: 8px;
}

.token-input-row .input-field {
  flex: 1;
}

.token-helper-text {
  margin-top: 8px;
  font-size: 11px;
}

.token-helper-text a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.token-helper-text a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Rate Limits Mini-Grid */
.limits-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.limit-cell {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px;
  text-align: center;
}

.limit-cell span {
  display: block;
  font-size: .65rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.limit-cell strong {
  display: block;
  font-size: .88rem;
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}

.faq h3 {
  color: var(--text);
  margin-top: 20px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--faint);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Responsive Overrides to prevent layout blowouts on tablets/mobiles */
@media (max-width: 1024px) {
  .docs-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
  }

  .on-this-page {
    display: none;
  }
}

@media (max-width: 768px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 12px;
    padding: 10px 16px;
  }
  
  .brand span {
    font-size: 1rem;
  }

  .top-links {
    display: none; /* Hide standard nav list on small screens */
  }
  
  .doc-search {
    flex: 1;
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: inline-flex;
    order: -1; /* Place hamburger on the far left */
  }

  .docs-layout {
    display: block;
    width: 100%;
    padding: 0 16px;
  }

  /* Transform Sidebar to Slide Drawer */
  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    width: 290px;
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--line);
    padding: 20px;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }

  .docs-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header-mobile {
    display: flex;
  }

  .doc-article {
    padding-top: 24px;
  }
  
  .tester-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .brand span {
    display: none; /* Hide brand label on very small devices to prioritize search */
  }
}
