/* TAAPI.IO v2 Documentation — single stylesheet */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f1117;
  --bg-sidebar:  #0a0c10;
  --bg-card:     #161b22;
  --bg-code:     #1c2130;
  --bg-code-hdr: #252d3d;
  --border:      #30363d;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-dim:    #6e7681;
  --accent:      #2f81f7;
  --accent-hover:#58a6ff;
  --green:       #3fb950;
  --yellow:      #d29922;
  --red:         #f85149;
  --orange:      #db6d28;
  --tag-get:     #1a7f37;
  --tag-post:    #9a3412;
  --tag-get-bg:  #0f3622;
  --tag-post-bg: #3a1a0a;
  --sidebar-w:   260px;
  --header-h:    52px;
  --font-mono:   'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius:      6px;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 100;
}
#topbar .logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
}
#topbar .logo span { color: var(--accent); }
#search-wrap {
  flex: 1;
  max-width: 360px;
  position: relative;
}
#search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  padding: 6px 10px 6px 30px;
  outline: none;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-dim); }
.search-icon {
  position: absolute;
  left: 8px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 13px;
  pointer-events: none;
}
#menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: 5px 9px;
  font-size: 18px;
  line-height: 1;
}

/* ── Layout ── */
#layout {
  display: flex;
  margin-top: var(--header-h);
  flex: 1;
}

/* ── Sidebar ── */
#sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 12px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  z-index: 90;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#search-results {
  display: none;
  position: absolute;
  top: calc(var(--header-h) + 4px);
  left: 16px;
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#search-results a {
  display: block;
  padding: 8px 14px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
#search-results a:hover, #search-results a.active { background: var(--bg-code); color: var(--accent); }
#search-results a:last-child { border-bottom: none; }
.sr-cat { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

.nav-section {
  padding: 4px 0;
}
.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 10px 16px 4px;
}
.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.nav-group-toggle:hover { color: var(--text); }
.nav-group-toggle .arrow { font-size: 10px; transition: transform 0.15s; }
.nav-group-toggle.open .arrow { transform: rotate(90deg); }
.nav-group-items { display: none; }
.nav-group-items.open { display: block; }
.nav-link {
  display: block;
  padding: 4px 16px 4px 24px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid transparent;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-link.active { color: var(--accent); border-left-color: var(--accent); background: rgba(47,129,247,0.06); }
.nav-link.top { padding-left: 16px; }

/* ── Main content ── */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
  max-width: 900px;
}

/* ── Page header ── */
.page-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.page-header .subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
}
.endpoint-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin-bottom: 10px;
}
.method {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.method.get  { background: var(--tag-get-bg);  color: var(--green); }
.method.post { background: var(--tag-post-bg); color: var(--orange); }
.path { color: var(--text); }

/* ── Prose ── */
h2 { font-size: 1.2rem; font-weight: 600; color: var(--text); margin: 32px 0 12px; }
h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin: 24px 0 10px; }
p  { color: var(--text-muted); margin-bottom: 14px; font-size: 0.92rem; }
ul, ol { color: var(--text-muted); padding-left: 20px; margin-bottom: 14px; font-size: 0.92rem; }
li { margin-bottom: 4px; }
a  { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
strong { color: var(--text); font-weight: 600; }
code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-code);
  color: #e6edf3;
  padding: 2px 5px;
  border-radius: 3px;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; margin: 16px 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead th {
  background: var(--bg-code-hdr);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }
td code { font-size: 0.8rem; }
.req-yes { color: var(--green); font-weight: 600; }
.req-no  { color: var(--text-dim); }

/* ── Code blocks ── */
.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
  overflow: hidden;
}
.code-block-header {
  background: var(--bg-code-hdr);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  gap: 8px;
}
.code-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.copy-btn {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.copy-btn:hover { color: var(--text); border-color: var(--text-muted); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }
.code-block pre {
  overflow-x: auto;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  color: #e6edf3;
  white-space: pre;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.code-block pre::-webkit-scrollbar { height: 6px; }
.code-block pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Tabbed code examples ── */
.tabs-wrap { margin: 16px 0; }
.tab-bar {
  display: flex;
  gap: 0;
  background: var(--bg-code-hdr);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}
.tab-btn {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.tab-btn.active { color: var(--accent); background: var(--bg-code); }
.tab-btn:last-child { border-right: none; }
.tab-panel {
  display: none;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  position: relative;
}
.tab-panel.active { display: block; }
.tab-panel pre {
  overflow-x: auto;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  color: #e6edf3;
  white-space: pre;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.tab-panel pre::-webkit-scrollbar { height: 6px; }
.tab-panel pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tab-copy {
  position: absolute;
  top: 8px; right: 10px;
}

/* ── Status tabs ── */
.status-tabs { margin: 16px 0; }
.status-tab-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.status-btn {
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.status-btn[data-code^="2"] { background: #0f3622; color: #3fb950; border-color: #1a7f37; }
.status-btn[data-code^="4"] { background: #3a1a0a; color: #f0883e; border-color: #9a3412; }
.status-btn.active { box-shadow: 0 0 0 2px currentColor; }
.status-panel { display: none; }
.status-panel.active { display: block; }

/* ── Callout boxes ── */
.callout {
  border-left: 3px solid var(--accent);
  background: rgba(47,129,247,0.07);
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.callout.warn { border-color: var(--yellow); background: rgba(210,153,34,0.07); }
.callout.danger { border-color: var(--red); background: rgba(248,81,73,0.07); }
.callout.todo {
  border-color: var(--orange);
  background: rgba(219,109,40,0.1);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--orange);
}
.callout strong { color: inherit; }

/* ── Steps ── */
.steps { counter-reset: step; padding-left: 0; list-style: none; }
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 36px;
  margin-bottom: 18px;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 24px; height: 24px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge.required { background: rgba(248,81,73,0.15); color: var(--red); }
.badge.optional { background: rgba(139,148,158,0.15); color: var(--text-dim); }

/* ── Indicator directory cards ── */
.cat-section { margin-bottom: 36px; }
.cat-section h2 { margin-bottom: 14px; }
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
}
.ind-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  transition: border-color 0.15s, color 0.15s;
  display: block;
}
.ind-card:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.ind-card .ind-name { font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent); display: block; }
.ind-card .ind-full { font-size: 0.75rem; color: var(--text-dim); display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Syntax highlight (simple) ── */
.tok-s { color: #a5d6ff; }  /* strings */
.tok-k { color: #ff7b72; }  /* keywords */
.tok-n { color: #d2a8ff; }  /* numbers */
.tok-c { color: #8b949e; }  /* comments */
.tok-p { color: #79c0ff; }  /* property keys */
.tok-b { color: #e6edf3; }  /* plain */
.tok-f { color: #ffa657; }  /* functions */

/* ── API key widget ── */
#api-key-wrap {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}
#api-key-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 10px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
#api-key-btn:hover { border-color: var(--accent); color: var(--text); }
#api-key-btn.has-key { border-color: var(--green); color: var(--green); }
#api-key-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
#api-key-btn.has-key #api-key-dot { background: var(--green); }

#api-key-popover {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 200;
}
#api-key-popover.open { display: block; }
#api-key-popover label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.api-key-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
#api-key-input {
  flex: 1;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 6px 10px;
  outline: none;
  min-width: 0;
}
#api-key-input:focus { border-color: var(--accent); }
.api-key-action {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  white-space: nowrap;
  transition: all 0.15s;
}
.api-key-action:hover { color: var(--text); border-color: var(--text-muted); }
.api-key-action.primary { border-color: var(--accent); color: var(--accent); }
.api-key-action.primary:hover { background: var(--accent); color: #fff; }
.api-key-action.danger:hover { border-color: var(--red); color: var(--red); }
.api-key-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin: 0;
}

/* ── Run button & response panel ── */
.run-btn {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green);
  background: rgba(63,185,80,0.08);
  border: 1px solid rgba(63,185,80,0.3);
  border-radius: 4px;
  padding: 2px 9px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.run-btn:hover { background: rgba(63,185,80,0.18); border-color: var(--green); }
.run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.run-result {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.run-result-header {
  background: var(--bg-code-hdr);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 0.72rem;
}
.run-result-status {
  font-weight: 700;
  font-family: var(--font-mono);
}
.run-result-status.ok  { color: var(--green); }
.run-result-status.err { color: var(--red); }
.run-result-status.pending { color: var(--yellow); }
.run-result pre {
  background: var(--bg-code);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: #e6edf3;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
.run-result-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
}
.run-result-close:hover { color: var(--text); }

/* ── Responsive ── */
@media (max-width: 820px) {
  #menu-toggle { display: block; }
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; padding: 24px 20px 60px; }
  #search-wrap { max-width: none; flex: 1; }
  #search-results { left: 8px; right: 8px; width: auto; }
}
@media (max-width: 500px) {
  #main { padding: 16px 14px 60px; }
  .page-header h1 { font-size: 1.3rem; }
}
