/* API reference: three panes (navigation tree, reference, dark code column), like DataForSEO's v3 docs. */
:root {
  --docs-side: 272px;
  --docs-split: 56%;
  --docs-dark: #0f1b2a;
  --docs-dark-2: #172638;
  --docs-dark-border: #24364b;
  --docs-dark-text: #dbe4ef;
  --docs-dark-muted: #8796ab;
  --hl-key: #7dd3fc;
  --hl-str: #a5e3a1;
  --hl-num: #f9c97c;
  --hl-lit: #f0a3d0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --docs-dark: #0a111b; --docs-dark-2: #111c2a; --docs-dark-border: #1f2f42; }
}
:root[data-theme="dark"] { --docs-dark: #0a111b; --docs-dark-2: #111c2a; --docs-dark-border: #1f2f42; }

.docs-page { background: var(--surface); }
.docs-page .nav { background: var(--surface); backdrop-filter: none; }
.docs-page .nav .container.docs-topbar { max-width: none; padding: 0 20px; }
.docs-page main { display: block; }

.docs { display: grid; grid-template-columns: var(--docs-side) minmax(0, 1fr); min-height: calc(100vh - var(--nav-h)); }

/* ----- left: navigation tree ----- */
.docs-sidebar {
  position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--border); background: var(--bg); padding: 0 0 32px;
}
.docs-search { position: sticky; top: 0; z-index: 1; padding: 14px 14px 10px; background: var(--bg); }
.docs-search input {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: 13.5px Inter, sans-serif;
}
.docs-search input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.tree-group { padding: 4px 8px; }
.tree-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 8px 6px;
  background: none; border: 0; cursor: pointer; color: var(--text); text-align: left;
  font: 700 11.5px Inter, sans-serif; text-transform: uppercase; letter-spacing: .07em;
}
.tree-head .chev::before { content: "▾"; display: inline-block; color: var(--text-muted); transition: transform .15s; }
.tree-group.collapsed .chev::before { transform: rotate(-90deg); }
.tree-group.collapsed ul { display: none; }
.tree-group ul { list-style: none; margin: 0 0 6px; padding: 0; }
.tree-group a {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; color: var(--text-muted);
  font-size: 13.5px; line-height: 1.35; border-left: 2px solid transparent;
}
.tree-group a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tree-group a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; border-left-color: var(--brand); }
.tree-label { min-width: 0; overflow-wrap: anywhere; }
.mb {
  flex: 0 0 38px; text-align: center; font: 700 9.5px "JetBrains Mono", monospace; padding: 2px 0; border-radius: 4px;
  letter-spacing: .02em;
}
.mb-get { background: var(--info-bg); color: var(--info); }
.mb-post { background: var(--good-bg); color: var(--good); }
.mb-delete { background: var(--bad-bg); color: var(--bad); }
.tree-empty { padding: 8px 16px; color: var(--text-muted); font-size: 13px; }

/* ----- middle + right: one row per section, the code column continuous behind them ----- */
.docs-content {
  min-width: 0;
  background: linear-gradient(to right, var(--surface) 0 var(--docs-split), var(--docs-dark) var(--docs-split) 100%);
}
.doc, .doc-group-head { display: grid; grid-template-columns: minmax(0, var(--docs-split)) minmax(0, 1fr); }
.doc { border-top: 1px solid var(--border); }
.doc-text { min-width: 0; padding: 36px 40px 40px; }
.doc-code { min-width: 0; padding: 36px 28px 40px; color: var(--docs-dark-text); }
.doc-group-head .doc-text { padding: 40px 40px 0; }
.doc-group-head .eyebrow { font-size: 13px; margin: 0; }
.doc-group-head + .doc { border-top: 0; }
.doc-text h1 { font-size: clamp(28px, 3vw, 38px); }
.doc-text h2 { font-size: 24px; margin-bottom: 12px; }
.doc-text h3 { font-size: 15.5px; margin: 28px 0 10px; }
.doc-text ul, .doc-text ol { padding-left: 20px; margin: 0 0 1em; }
.doc-text li { margin-bottom: 6px; }
.doc-text .lead { font-size: 17px; color: var(--text-muted); }
.doc-text code.wrap, .doc-text td code { overflow-wrap: anywhere; }
.small { font-size: 13.5px; }
.callout { border-left: 3px solid var(--brand); background: var(--brand-soft); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 14px; }
.table-wrap.spaced { margin-top: 16px; }
.doc-text .table-wrap { margin-bottom: 8px; }

.endpoint-line {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 4px; padding: 10px 12px; margin: 0 0 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.endpoint-line .method { margin-right: 4px; }
.ep-path { flex: 1 1 200px; min-width: 0; font: 500 14px "JetBrains Mono", monospace; overflow-wrap: anywhere; }
.endpoint-line code.ep-path { background: none; border: 0; padding: 0; }
.copy-mini {
  font: 600 12px Inter, sans-serif; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.copy-mini:hover { color: var(--text); background: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.chip { font-size: 13px; padding: 5px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.chip b { color: var(--text); font-weight: 600; margin-right: 4px; }
.chip-async b { color: var(--warn); }
.chip-sync b { color: var(--good); }

table.fields td:first-child { white-space: nowrap; }
table.fields td:first-child code { white-space: normal; overflow-wrap: anywhere; }
table.fields td.type { color: var(--text-muted); font: 12.5px "JetBrains Mono", monospace; white-space: nowrap; }
table.fields tr.child td:first-child { padding-left: 28px; }
table.fields tr.child td:first-child code { font-size: 12px; }
.req, .opt { display: block; font-size: 11px; font-weight: 600; margin-top: 3px; }
.req { color: var(--bad); }
.opt { color: var(--text-muted); font-weight: 500; }
.pnote { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.pnote code { font-size: 11.5px; }
.error-codes { display: flex; flex-wrap: wrap; gap: 6px; }
.err { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; font-size: 12px; color: var(--text); }
.err:hover { text-decoration: none; border-color: var(--brand); }
.err span { padding: 2px 6px; background: var(--surface-2); color: var(--text-muted); font-weight: 600; }
.err code, .error-codes .err code { border: 0; border-radius: 0; background: none; padding: 2px 7px; font-size: 12px; }
.errors-table code { display: inline-block; margin: 1px 2px 1px 0; }

/* ----- right: code samples ----- */
.sample { margin-bottom: 22px; border: 1px solid var(--docs-dark-border); border-radius: 10px; background: var(--docs-dark-2); overflow: hidden; }
.sample-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--docs-dark-border); font-size: 12.5px; color: var(--docs-dark-muted);
}
.sample-title { font-weight: 600; color: var(--docs-dark-text); min-width: 0; overflow-wrap: anywhere; }
.sample-status { font: 600 11.5px "JetBrains Mono", monospace; padding: 1px 7px; border-radius: 5px; background: rgba(134, 239, 172, .14); color: #86efac; }
.sample-status.s-4, .sample-status.s-5 { background: rgba(252, 165, 165, .14); color: #fca5a5; }
.sample-status.s-p { background: rgba(147, 197, 253, .14); color: #93c5fd; }
.sample-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.lang-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.lang-tabs button {
  font: 600 12px Inter, sans-serif; padding: 4px 9px; border-radius: 6px; border: 0; cursor: pointer;
  background: none; color: var(--docs-dark-muted);
}
.lang-tabs button:hover { color: var(--docs-dark-text); }
.lang-tabs button.active { background: rgba(255, 96, 31, .18); color: #ffb08f; }
.copy-dark {
  font: 600 12px Inter, sans-serif; color: #c9d4e3; background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 6px; padding: 3px 10px; cursor: pointer;
}
.copy-dark:hover { background: rgba(255, 255, 255, .15); }
.sample pre {
  margin: 0; padding: 14px 16px; overflow: auto; max-height: 560px; background: transparent; color: var(--docs-dark-text);
  font: 12.5px/1.6 "JetBrains Mono", ui-monospace, monospace; tab-size: 2;
}
.sample-label { font-size: 12px; color: var(--docs-dark-muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; font-weight: 600; }
.hl-k { color: var(--hl-key); }
.hl-s { color: var(--hl-str); }
.hl-n { color: var(--hl-num); }
.hl-l { color: var(--hl-lit); }
.hl-c { color: var(--docs-dark-muted); }

.docs-mobilebar, .docs-backdrop { display: none; }

/* ----- narrower: code under each section ----- */
@media (max-width: 1099px) {
  .docs-content { background: var(--surface); }
  .doc, .doc-group-head { grid-template-columns: minmax(0, 1fr); }
  .doc-text { padding: 32px 28px 8px; }
  .doc-code { margin: 0 28px 32px; padding: 18px 16px 2px; background: var(--docs-dark); border-radius: 14px; }
  .doc-group-head .doc-code { display: none; }
  .doc-group-head .doc-text { padding-bottom: 0; }
}

/* ----- phones: the tree becomes a drawer ----- */
@media (max-width: 819px) {
  .docs { grid-template-columns: minmax(0, 1fr); }
  .docs-page .nav .container.docs-topbar { padding: 0 16px; }
  .docs-sidebar {
    position: fixed; top: var(--nav-h); left: 0; bottom: 0; height: auto; width: min(300px, 86vw); z-index: 40;
    transform: translateX(-100%); transition: transform .2s; box-shadow: none;
  }
  .docs-sidebar.open { transform: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
  .docs-backdrop { display: block; position: fixed; inset: var(--nav-h) 0 0 0; background: rgba(5, 10, 20, .45); z-index: 39; }
  .docs-backdrop[hidden] { display: none; }
  .docs-mobilebar {
    display: block; position: sticky; top: var(--nav-h); z-index: 20; padding: 10px 16px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  }
  .docs-mobilebar .btn { padding: 7px 14px; font-size: 13.5px; }
  .doc-text { padding: 26px 16px 4px; }
  .doc-group-head .doc-text { padding: 28px 16px 0; }
  .doc-code { margin: 0 16px 28px; padding: 14px 12px 2px; border-radius: 12px; }
  .doc-text h2 { font-size: 21px; }
  /* field tables as stacked rows: name and type on one line, the description under them */
  table.fields thead { display: none; }
  table.fields, table.fields tbody, table.fields tr { display: block; }
  table.fields tr { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  table.fields tr:last-child { border-bottom: 0; }
  table.fields td { display: inline; padding: 0; border: 0; font-size: 13.5px; }
  table.fields td:first-child { white-space: normal; }
  table.fields td:last-child { display: block; margin-top: 6px; }
  table.fields td.type { margin-left: 6px; }
  table.fields tr.child td:first-child { padding-left: 0; }
  table.fields tr.child { padding-left: 24px; }
  .req, .opt { display: inline; margin: 0 0 0 6px; }
  .sample pre { font-size: 12px; padding: 12px; max-height: 420px; }
}
@media (max-width: 819px) { html { scroll-padding-top: calc(var(--nav-h) + 64px); } }
@media (min-width: 820px) { table.fields td:first-child { min-width: 168px; } table.fields td:first-child code { white-space: nowrap; } }
