/* AventraGuard API Documentation — Nuvei-style 3-column layout */
/* Zero external dependencies — fully self-contained */

:root {
  /* Brand palette mirrors the dashboard tokens (web/src/styles/tokens.css):
     --accent #1d4ed8 / hover #1e40af / soft #eff3ff. Deep blue replaces the
     previous teal so the docs carry the same identity + stronger contrast. */
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --accent-light: #eff3ff;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --bg: #ffffff;
  --bg-subtle: #f4f6fa;
  --bg-sidebar: #f4f6fa;
  --border: #e2e5ed;
  --border-subtle: #f0f1f3;
  --code-bg: #0c1117;
  --code-text: #e2e8f0;
  --link: #1d4ed8;
  --nav-active-bg: #eff3ff;
  --nav-active-border: #1d4ed8;
  --callout-info-bg: #eff6ff;
  --callout-info-border: #3b82f6;
  --callout-warn-bg: #fffbeb;
  --callout-warn-border: #f59e0b;
  --callout-danger-bg: #fef2f2;
  --callout-danger-border: #ef4444;
  --sidebar-width: 260px;
  --toc-width: 220px;
  --content-max: 760px;
  --topbar-height: 56px;
  font-size: 16px;
}

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

html { scroll-behavior: smooth; }

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

/* ─── Top bar ────────────────────────────────────────────────────────────────── */

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  z-index: 100;
}

#topbar-wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

#topbar-wordmark .brand-dot {
  color: var(--accent);
  font-weight: 400;
}

/* Two-tone wordmark — matches the in-app BrandLogo lockup: bold lead +
   medium-weight muted tail, with a muted "API Documentation" suffix. */
#topbar-wordmark .wordmark-lead { font-weight: 700; color: var(--text); }
#topbar-wordmark .wordmark-tail { font-weight: 500; color: var(--text-muted); }
#topbar-wordmark .wordmark-sub  { font-weight: 500; color: var(--text-muted); }

#topbar-wordmark svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 6.5px;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.22);
}

/* ─── Environment badge (set at runtime by app.js from the hostname) ─────────── */
.env-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  margin-left: 2px;
  line-height: 1.4;
  border: 1px solid transparent;
}
.env-badge[hidden] { display: none; }
.env-badge.env-dev     { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.env-badge.env-staging { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.env-badge.env-prod    { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

#topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

#search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#search-wrapper svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px 7px 34px;
  font-size: 0.875rem;
  width: 220px;
  background: var(--bg-subtle);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
  background: var(--bg);
}

#search-input::placeholder { color: var(--text-light); }

/* ─── Search results dropdown ────────────────────────────────────────────────── */

#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 360px;
  max-width: 80vw;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.16);
  padding: 6px;
  z-index: 200;
}

#search-results[hidden] { display: none; }

.search-result {
  display: block;
  padding: 8px 10px;
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.search-result:hover,
.search-result.active {
  background: var(--accent-light);
}

.search-result .sr-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.search-result.active .sr-title { color: var(--accent); }

.search-result .sr-section {
  display: block;
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 1px;
}

.search-result mark {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.search-empty {
  padding: 14px 12px;
  font-size: 0.8375rem;
  color: var(--text-light);
  text-align: center;
}

/* ─── Environment banner (rendered by app.js on non-prod docs hosts) ─────────── */

.env-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--accent-light);
  border: 1px solid var(--accent-soft-border, #c7d5fc);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 28px;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.6;
}

.env-banner code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.82em;
  color: var(--accent-dark);
}

/* The active environment's row in the Base URLs table, marked at runtime. */
.content-inner tr.env-row-active td {
  background: var(--accent-light) !important;
  font-weight: 600;
}
.content-inner tr.env-row-active td:first-child::after {
  content: " ← you are here";
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78em;
}

.topbar-link {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

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

.topbar-link.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background 0.15s;
}

.topbar-link.btn-primary:hover { background: var(--accent-dark); }

#hamburger {
  display: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px;
  color: var(--text);
  border-radius: 6px;
}

#hamburger:hover { background: var(--bg-subtle); }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */

#layout {
  display: flex;
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

/* ─── Left sidebar ───────────────────────────────────────────────────────────── */

#sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

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

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

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 12px 20px 4px;
}

.nav-group > .nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: color 0.1s;
  list-style: none;
}

.nav-group > .nav-group-toggle:hover { color: var(--accent); }

.nav-group > .nav-group-toggle .toggle-icon {
  transition: transform 0.2s;
  color: var(--text-light);
  flex-shrink: 0;
}

.nav-group.open > .nav-group-toggle .toggle-icon {
  transform: rotate(90deg);
}

.nav-group-items {
  display: none;
  padding: 0 0 6px;
}

.nav-group.open > .nav-group-items { display: block; }

.nav-item {
  display: block;
  padding: 5px 20px 5px 32px;
  font-size: 0.8375rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.1s, background 0.1s;
  border-left: 2px solid transparent;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: var(--border-subtle);
}

.nav-item.active {
  color: var(--accent);
  background: var(--nav-active-bg);
  border-left-color: var(--nav-active-border);
  font-weight: 600;
}

/* ─── Main content ───────────────────────────────────────────────────────────── */

#main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-right: var(--toc-width);
  padding: 48px 56px;
  min-width: 0;
}

.content-inner {
  max-width: var(--content-max);
}

/* ─── Right TOC ──────────────────────────────────────────────────────────────── */

#toc-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  width: var(--toc-width);
  height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: 32px 20px 40px;
  border-left: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#toc-panel::-webkit-scrollbar { width: 4px; }
#toc-panel::-webkit-scrollbar-track { background: transparent; }
#toc-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#toc-panel h3 {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 10px;
}

#toc-list {
  list-style: none;
}

#toc-list li { margin-bottom: 2px; }

#toc-list a {
  display: block;
  padding: 4px 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
  border-left: 2px solid transparent;
}

#toc-list a:hover { color: var(--text); background: var(--bg-subtle); }

#toc-list a.active {
  color: var(--accent);
  background: var(--nav-active-bg);
  border-left-color: var(--nav-active-border);
  font-weight: 600;
}

#toc-list a.toc-h3 { padding-left: 18px; font-size: 0.78rem; }

/* ─── Typography ─────────────────────────────────────────────────────────────── */

.content-inner h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.25;
}

.content-inner .page-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 36px;
  line-height: 1.6;
}

.content-inner h2 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-top: 48px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
}

.content-inner h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 32px;
  margin-bottom: 10px;
  color: var(--text);
}

.content-inner h4 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 8px;
  color: var(--text);
}

.content-inner .anchor-heading {
  position: relative;
  text-decoration: none;
  color: inherit;
}

.content-inner .anchor-heading::after {
  content: " #";
  color: var(--accent);
  opacity: 0;
  font-weight: 400;
  font-size: 0.85em;
  transition: opacity 0.1s;
}

.content-inner h2:hover .anchor-heading::after,
.content-inner h3:hover .anchor-heading::after {
  opacity: 1;
}

.content-inner p {
  margin-bottom: 16px;
  color: var(--text);
  line-height: 1.7;
}

.content-inner ul, .content-inner ol {
  margin: 0 0 16px 24px;
}

.content-inner li {
  margin-bottom: 6px;
  line-height: 1.65;
}

.content-inner a {
  color: var(--link);
  text-decoration: none;
}

.content-inner a:hover { text-decoration: underline; }

.content-inner strong { font-weight: 700; }

.content-inner code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.8375em;
  color: var(--accent-dark);
}

/* ─── Tables ─────────────────────────────────────────────────────────────────── */

.content-inner table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.875rem;
}

.content-inner th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.content-inner td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.55;
}

.content-inner tr:nth-child(even) td { background: var(--bg-subtle); }

.content-inner td code {
  font-size: 0.8125em;
}

/* ─── Code blocks ────────────────────────────────────────────────────────────── */

.code-widget {
  background: var(--code-bg);
  border-radius: 10px;
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}

.code-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 0 16px;
  gap: 0;
}

.code-tab {
  padding: 10px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
  letter-spacing: 0.02em;
}

.code-tab:hover { color: rgba(255,255,255,0.7); }
.code-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.code-copy-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.code-copy-btn:hover {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
}

.code-copy-btn.copied {
  color: var(--accent);
  border-color: rgba(29,78,216,0.35);
}

.code-panel {
  display: none;
  padding: 20px;
  overflow-x: auto;
}

.code-panel.active { display: block; }

.code-panel pre {
  font-family: "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--code-text);
  white-space: pre;
  tab-size: 2;
}

/* Syntax colouring — hand-rolled, no external lib */
.tok-kw  { color: #c084fc; } /* keywords/methods */
.tok-str { color: #86efac; } /* strings */
.tok-num { color: #fb923c; } /* numbers */
.tok-cmt { color: #6b7280; } /* comments */
.tok-fn  { color: #67e8f9; } /* function calls */
.tok-typ { color: #fbbf24; } /* types */
.tok-hd  { color: #94a3b8; } /* HTTP header names */
.tok-url { color: #a5b4fc; } /* URLs */
.tok-key { color: #f9a8d4; } /* JSON keys */
.tok-var { color: #e2e8f0; } /* variables */

/* ─── Callouts ───────────────────────────────────────────────────────────────── */

.callout {
  border-left: 4px solid;
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.callout-info {
  background: var(--callout-info-bg);
  border-color: var(--callout-info-border);
  color: #1e40af;
}

.callout-warn {
  background: var(--callout-warn-bg);
  border-color: var(--callout-warn-border);
  color: #92400e;
}

.callout-danger {
  background: var(--callout-danger-bg);
  border-color: var(--callout-danger-border);
  color: #991b1b;
}

.callout-label {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* ─── Method badges ──────────────────────────────────────────────────────────── */

.method-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-family: "SF Mono", Consolas, monospace;
  margin-right: 6px;
  vertical-align: middle;
}

.method-get    { background: #dcfce7; color: #166534; }
.method-post   { background: #eff6ff; color: #1d4ed8; }
.method-patch  { background: #fef3c7; color: #92400e; }
.method-delete { background: #fee2e2; color: #991b1b; }

.endpoint-path {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── Step list ──────────────────────────────────────────────────────────────── */

.step-list {
  list-style: none;
  margin: 0 0 20px;
}

.step-list > li {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  margin-top: 1px;
}

.step-body { flex: 1; }

/* ─── Status code table ──────────────────────────────────────────────────────── */

.status-ok   { color: #166534; font-weight: 700; }
.status-err  { color: #991b1b; font-weight: 700; }
.status-warn { color: #92400e; font-weight: 700; }

/* ─── Section intro ──────────────────────────────────────────────────────────── */

.section-intro {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-subtle);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  line-height: 1.65;
}

/* ─── Resource section ───────────────────────────────────────────────────────── */

.resource-section {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
}

.resource-section:last-child { border-bottom: none; }

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* ─── Search no-results overlay ─────────────────────────────────────────────── */

.nav-no-results {
  padding: 12px 20px;
  font-size: 0.8375rem;
  color: var(--text-light);
}

/* ─── Hidden by search ───────────────────────────────────────────────────────── */
.nav-hidden { display: none !important; }

/* ─── Mobile responsive ──────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  #toc-panel { display: none; }
  #main-content { margin-right: 0; }
}

@media (max-width: 720px) {
  #hamburger { display: flex; }
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s;
    z-index: 90;
  }
  #sidebar.open { transform: translateX(0); }
  #main-content {
    margin-left: 0;
    padding: 32px 20px;
  }
  #search-input { width: 160px; }
  .topbar-link.btn-primary { display: none; }
}

@media (max-width: 440px) {
  #topbar-wordmark span.wordmark-text { display: none; }
  #search-input { width: 120px; }
}

/* ─── Anchor offset for fixed header ─────────────────────────────────────────── */

[id] {
  scroll-margin-top: calc(var(--topbar-height) + 20px);
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */

.page-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.page-footer a { color: var(--text-muted); text-decoration: none; }
.page-footer a:hover { color: var(--accent); }
