/* APIRepublic — Swagger UI dark theme.
 *
 * ADDITIVE ONLY. Loaded *after* the upstream swagger-ui.css, solely by
 * templates/swagger.html (the custom /v1/docs route). It re-skins Swagger UI to
 * the APIRepublic brand — deep blue-black canvas, brand red accent, Space Grotesk prose with JetBrains Mono code, and
 * the same pills / cards / terminal-JSON palette as templates/api.html. Every
 * rule is scoped to `.swagger-ui` or `.page-swagger`, so the map, login, /api,
 * Data & sources, account menu and contact modal are byte-for-byte unaffected.
 * Reuses the brand design tokens (--bg*, --accent, --c-*, --radius*) defined on
 * :root in styles.css, so the theme can never drift from the rest of the site.
 *
 * Targets swagger-ui-dist 5.x (self-hosted swagger-ui-dist 5.33.0 in static/vendor/).
 */

/* ───────────────────────────────────────────────
   Page frame (slim brand header + Swagger mount)
─────────────────────────────────────────────── */
.page-swagger .swagger-hero { padding: 64px 0 22px; }
.page-swagger .swagger-hero .cta-actions { justify-content: flex-start; margin-top: 22px; }
.page-swagger .swagger-hero .map-hero-sub code {
  font-family: var(--font-mono);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--c-str);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}
.page-swagger .swagger-main { padding: 40px 0 96px; }   /* clear gap below the brand header */
.page-swagger .swagger-main .container { max-width: var(--content-max); }

/* ───────────────────────────────────────────────
   Base canvas + typography
─────────────────────────────────────────────── */
.swagger-ui,
.swagger-ui .wrapper,
.swagger-ui .scheme-container,
.swagger-ui section.models,
.swagger-ui .opblock-body {
  background: transparent;
}
.swagger-ui {
  color: var(--text);
  font-family: var(--font-mono);
}
.swagger-ui .topbar { display: none; }          /* BaseLayout omits it; belt + braces */

/* Brand type: a universal !important rule beats Swagger's many per-selector
   font-family declarations in one shot (prose in Space Grotesk), then code,
   paths, parameter names and models are pinned back to JetBrains Mono. Safe:
   swagger-ui 5.x uses SVG icons, not an icon font. */
.swagger-ui,
.swagger-ui * {
  font-family: var(--font-sans) !important;
}
.swagger-ui code,
.swagger-ui pre,
.swagger-ui .microlight,
.swagger-ui .opblock-summary-path,
.swagger-ui .opblock-summary-path *,
.swagger-ui .opblock-summary-method,
.swagger-ui .parameter__name,
.swagger-ui .parameter__type,
.swagger-ui .parameter__in,
.swagger-ui .prop-type,
.swagger-ui .prop-format,
.swagger-ui .model,
.swagger-ui .model *,
.swagger-ui .response-col_status,
.swagger-ui .version,
.swagger-ui input,
.swagger-ui select,
.swagger-ui textarea,
.swagger-ui .servers,
.swagger-ui .servers * {
  font-family: var(--font-mono) !important;
}

/* Headings + body text colours. */
.swagger-ui .info .title,
.swagger-ui h1, .swagger-ui h2, .swagger-ui h3,
.swagger-ui h4, .swagger-ui h5,
.swagger-ui .opblock-tag,
.swagger-ui .opblock .opblock-summary-path,
.swagger-ui .opblock .opblock-summary-path a,
.swagger-ui .parameter__name,
.swagger-ui .model-title,
.swagger-ui table thead tr th,
.swagger-ui .dialog-ux .modal-ux-header h3 {
  color: var(--text);
}
.swagger-ui p,
.swagger-ui li,
.swagger-ui .markdown p,
.swagger-ui .renderedMarkdown p,
.swagger-ui .opblock-summary-description,
.swagger-ui .opblock-description-wrapper p,
.swagger-ui .response-col_description,
.swagger-ui .parameter__type,
.swagger-ui table tbody tr td,
.swagger-ui .opblock-title,
.swagger-ui label {
  color: var(--text-2);
}
.swagger-ui .opblock-tag small,
.swagger-ui .parameter__in,
.swagger-ui .info .base-url,
.swagger-ui .info hgroup.main a span,
.swagger-ui .tab li,
.swagger-ui .col_header,
.swagger-ui .response-col_status .response-undocumented {
  color: var(--text-3);
}
.swagger-ui a,
.swagger-ui .info a,
.swagger-ui .info a.link,
.swagger-ui .markdown a,
.swagger-ui .renderedMarkdown a { color: var(--accent-2); }
@media (hover: hover) {
  .swagger-ui a:hover,
  .swagger-ui .info a:hover { color: var(--accent); }
}

/* Inline code chips (in descriptions / markdown) — match styles.css <code>. */
.swagger-ui .markdown code,
.swagger-ui .renderedMarkdown code,
.swagger-ui .info code,
.swagger-ui .response-col_description code {
  font-family: var(--font-mono);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--c-str);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ───────────────────────────────────────────────
   Info block (spec title + description)
─────────────────────────────────────────────── */
.swagger-ui .information-container {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin-bottom: 26px;
}
.swagger-ui .information-container .info { margin: 0; }
/* Lay the title + version stamp on one centred row so the pill sits beside the
   text instead of floating off the baseline of the big heading. */
.swagger-ui .info .title {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
/* Version stamp → a tidy accent pill (also covers Swagger's .version-stamp). */
.swagger-ui .info .title small,
.swagger-ui .info .title small.version-stamp {
  position: static;
  top: auto;
  display: inline-flex;
  align-items: center;
  background: var(--accent-dim);
  border: 1px solid rgba(var(--accent-rgb), 0.40);
  border-radius: var(--radius-pill);
  padding: 3px 11px;
  box-shadow: none;
}
.swagger-ui .info .title small pre,
.swagger-ui .info .title small .version {
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
/* Drop the resolved-spec URL link shown beside the OAS badge — it duplicates the
   "openapi.json" button in the brand header above. Targeted by href so the OAS
   pill and every description link (which live in .info .description) stay put. */
.swagger-ui .info a[href*="openapi.json"] { display: none; }

/* ───────────────────────────────────────────────
   Servers / authorize bar
─────────────────────────────────────────────── */
.swagger-ui .scheme-container {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 18px 22px;
  margin: 0 0 26px;
}
.swagger-ui .scheme-container .schemes-title,
.swagger-ui .servers-title { color: var(--text-3); }

/* ───────────────────────────────────────────────
   Tag groups (Discovery / Query / Operational)
─────────────────────────────────────────────── */
.swagger-ui .opblock-tag {
  border-bottom: 1px solid var(--border);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 16px 8px 12px;
  margin: 12px 0 0;
}
.swagger-ui .opblock-tag:hover { background: transparent; }
.swagger-ui .opblock-tag small {
  font-weight: 400;
  font-size: 12.5px;
  padding: 0 0 0 14px;
  line-height: 1.5;
}
.swagger-ui .opblock-tag small p { color: var(--text-3); }
/* Expand/collapse chevron on tag rows + operations. */
.swagger-ui .opblock-tag .expand-operation svg,
.swagger-ui .opblock-tag svg,
.swagger-ui .expand-methods svg,
.swagger-ui .opblock-control-arrow svg,
.swagger-ui .opblock-summary-control svg { fill: var(--text-3); }

/* ───────────────────────────────────────────────
   Operation cards (all GET here)
─────────────────────────────────────────────── */
.swagger-ui .opblock {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  margin: 0 0 14px;
}
.swagger-ui .opblock.opblock-get { border-color: var(--border); }
.swagger-ui .opblock.is-open { border-color: var(--border-2); }
.swagger-ui .opblock .opblock-summary {
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
}
.swagger-ui .opblock.is-open .opblock-summary { border-bottom-color: var(--border); }

/* Method pill typography (all verbs). */
.swagger-ui .opblock .opblock-summary-method {
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: none;
  min-width: 64px;
}
/* Brand red chip (mirrors styles.css .badge-accent). Raised to the
   .opblock.opblock-get specificity so it beats Swagger's default solid-blue
   GET rule instead of silently falling back to it. */
.swagger-ui .opblock.opblock-get .opblock-summary-method {
  background: var(--accent-dim);
  color: var(--accent-2);
  border: 1px solid rgba(var(--accent-rgb), 0.40);
}
.swagger-ui .opblock .opblock-summary-path { font-size: 14px; font-weight: 500; }
.swagger-ui .opblock .opblock-summary-path .opblock-summary-path__deprecated { color: var(--text-4); }

/* Section sub-headers (Parameters / Request body / Responses bars). */
.swagger-ui .opblock .opblock-section-header {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}
.swagger-ui .opblock .opblock-section-header h4,
.swagger-ui .opblock .opblock-section-header > label,
.swagger-ui .opblock .tab-header .tab-item.active h4 span { color: var(--text); }

/* ───────────────────────────────────────────────
   Tables (parameters + responses)
─────────────────────────────────────────────── */
.swagger-ui table { border-collapse: collapse; }
.swagger-ui table thead tr td,
.swagger-ui table thead tr th {
  border-bottom: 1px solid var(--border);
  color: var(--text-4);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.swagger-ui table tbody tr td { border-bottom: 1px solid var(--border); }
.swagger-ui .parameter__name { font-weight: 600; }
.swagger-ui .parameter__name.required:after { color: var(--accent); }
.swagger-ui .response-col_status { color: var(--text); }

/* ───────────────────────────────────────────────
   Buttons → brand pills
─────────────────────────────────────────────── */
.swagger-ui .btn {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-2);
  color: var(--text);
  background: transparent;
  box-shadow: none;
  font-weight: 500;
  transition: all 0.18s ease;
}
@media (hover: hover) {
  .swagger-ui .btn:hover { border-color: var(--text-3); background: var(--bg-2); }
}
/* Execute = primary coral. */
.swagger-ui .btn.execute {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-accent);
}
@media (hover: hover) {
  .swagger-ui .btn.execute:hover {
    background: var(--accent-hover);
    box-shadow: 0 8px 30px rgba(var(--accent-rgb), 0.32);
    transform: translateY(-1px);
  }
}
/* Authorize = ghost pill with a coral lock. */
.swagger-ui .btn.authorize { color: var(--text); border-color: var(--border-2); }
.swagger-ui .btn.authorize svg { fill: var(--accent); }
@media (hover: hover) {
  .swagger-ui .btn.authorize:hover { border-color: var(--accent); color: var(--accent); }
  .swagger-ui .btn.authorize:hover svg { fill: var(--accent); }
}
.swagger-ui .btn.cancel { border-color: var(--border-2); color: var(--text-2); }
.swagger-ui .authorization__btn svg { fill: var(--text-3); }
.swagger-ui .authorization__btn.unlocked svg { fill: var(--text-4); }

/* ───────────────────────────────────────────────
   Inputs / selects / textareas → .form-control look
─────────────────────────────────────────────── */
.swagger-ui input[type=text],
.swagger-ui input[type=password],
.swagger-ui input[type=search],
.swagger-ui input[type=email],
.swagger-ui textarea,
.swagger-ui select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.swagger-ui input::placeholder,
.swagger-ui textarea::placeholder { color: var(--text-4); font-style: italic; }
.swagger-ui input:focus,
.swagger-ui textarea:focus,
.swagger-ui select:focus { border-color: var(--accent); outline: none; }
.swagger-ui textarea.curl { background: var(--bg); color: var(--text-2); }

/* ───────────────────────────────────────────────
   Code / JSON samples → terminal palette
─────────────────────────────────────────────── */
.swagger-ui .highlight-code,
.swagger-ui .highlight-code > .microlight,
.swagger-ui .microlight,
.swagger-ui .curl-command,
.swagger-ui .responses-inner pre,
.swagger-ui .response .microlight {
  background: var(--bg) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
}
.swagger-ui .copy-to-clipboard {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-pill);
}
.swagger-ui .copy-to-clipboard button { background: transparent; }
.swagger-ui .copy-to-clipboard button:before { color: var(--text-2); }

/* ───────────────────────────────────────────────
   Models / schemas
─────────────────────────────────────────────── */
.swagger-ui section.models {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.swagger-ui section.models.is-open h4 { border-bottom: 1px solid var(--border); }
.swagger-ui section.models h4 { color: var(--text-2); }
.swagger-ui .model-box { background: var(--bg-2); border-radius: var(--radius-sm); }
.swagger-ui .model { color: var(--text-2); }
.swagger-ui .model-title { color: var(--text); }
.swagger-ui .prop-type { color: var(--c-bool); }
.swagger-ui .prop-format { color: var(--text-3); }
.swagger-ui .model-toggle:after { /* keep default chevron asset */ opacity: 0.7; }

/* ───────────────────────────────────────────────
   Authorize / dialog modal
─────────────────────────────────────────────── */
.swagger-ui .dialog-ux .modal-ux {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.swagger-ui .dialog-ux .modal-ux-header { border-bottom: 1px solid var(--border); }
.swagger-ui .dialog-ux .modal-ux-content h4,
.swagger-ui .dialog-ux .modal-ux-content p,
.swagger-ui .dialog-ux .modal-ux-content label { color: var(--text-2); }
.swagger-ui .dialog-ux .modal-ux-content code { color: var(--c-str); }
.swagger-ui .auth-btn-wrapper { justify-content: flex-start; gap: 10px; }
.swagger-ui .dialog-ux .modal-ux-header .close-modal svg { fill: var(--text-3); }

/* ───────────────────────────────────────────────
   Status / feedback
─────────────────────────────────────────────── */
.swagger-ui .errors-wrapper {
  background: var(--accent-dim);
  border: 1px solid rgba(var(--accent-rgb), 0.40);
  border-radius: var(--radius-sm);
}
.swagger-ui .errors-wrapper .errors h4,
.swagger-ui .errors-wrapper hgroup h4 { color: var(--accent); }
.swagger-ui .loading-container .loading:after { border-color: var(--accent) transparent transparent; }
.swagger-ui .opblock-body pre.microlight span { /* token colours stay as agate-on-dark */ }

/* Filter box (operations filter, if enabled). */
.swagger-ui .filter .operation-filter-input {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  color: var(--text);
}

/* ───────────────────────────────────────────────
   Scrollbars (match the dark canvas)
─────────────────────────────────────────────── */
.page-swagger ::-webkit-scrollbar { width: 11px; height: 11px; }
.page-swagger ::-webkit-scrollbar-track { background: var(--bg-1); }
.page-swagger ::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-1);
}
.page-swagger ::-webkit-scrollbar-thumb:hover { background: var(--text-4); }
