/*
 * Klantly Developers — stijl van de developer-portal (docs/PUBLIEKE_API.md §4.10).
 * Bewust één eigen bestand zonder build-stap en zonder inline stijlen: de portal draait met een strikte
 * Content-Security-Policy (style-src 'self').
 */

:root {
    --bg: #ffffff;
    --surface: #f8fafc;
    --surface-strong: #f1f5f9;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --accent: #2563eb;
    --accent-strong: #1d4ed8;
    --accent-soft: #eff6ff;
    --code-bg: #0f172a;
    --code-bar: #1e293b;
    --code-text: #e2e8f0;
    --inline-code-bg: #f1f5f9;
    --ok: #15803d;
    --ok-soft: #dcfce7;
    --error: #b91c1c;
    --error-soft: #fee2e2;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --radius: 10px;
    --topbar: 60px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120;
        --surface: #111827;
        --surface-strong: #1f2937;
        --text: #e5e7eb;
        --muted: #94a3b8;
        --border: #1f2937;
        --accent: #60a5fa;
        --accent-strong: #93c5fd;
        --accent-soft: #172554;
        --inline-code-bg: #1f2937;
        --ok: #4ade80;
        --ok-soft: #14532d;
        --error: #f87171;
        --error-soft: #450a0a;
        --warning: #fbbf24;
        --warning-soft: #451a03;
        color-scheme: dark;
    }
}

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

html { scroll-padding-top: calc(var(--topbar) + 16px); }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.65 var(--font);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd, pre { font-family: var(--mono); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: 16px; top: -48px;
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    z-index: 100;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Topbalk ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--topbar);
    padding: 0 20px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar__menu {
    display: none;
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.topbar__menu-icon,
.topbar__menu-icon::before,
.topbar__menu-icon::after {
    display: block;
    width: 18px; height: 2px;
    margin: 0 auto;
    background: currentColor;
    border-radius: 2px;
    content: "";
    position: relative;
}
.topbar__menu-icon::before { position: absolute; top: -6px; }
.topbar__menu-icon::after { position: absolute; top: 6px; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand__mark {
    display: grid;
    place-items: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 16px;
}
.brand__sub { color: var(--muted); font-weight: 500; }

.search {
    position: relative;
    flex: 1;
    max-width: 440px;
    margin-left: 24px;
}
.search__input {
    width: 100%;
    height: 38px;
    padding: 0 40px 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 15px;
}
.search__input:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.search__hint {
    position: absolute;
    right: 10px; top: 9px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 18px;
}
.search__results {
    position: absolute;
    top: 44px; left: 0; right: 0;
    max-height: 70vh;
    overflow-y: auto;
    padding: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgb(15 23 42 / 0.16);
}
.search__result {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text);
}
.search__result:hover,
.search__result[aria-selected="true"] { background: var(--accent-soft); text-decoration: none; }
.search__result-title { display: block; font-weight: 600; }
.search__result-section { display: block; color: var(--muted); font-size: 13px; }
.search__empty { margin: 0; padding: 10px; color: var(--muted); }

.topbar__links {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}
.topbar__app { font-weight: 600; white-space: nowrap; }

.language { position: relative; }
.language summary {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    list-style: none;
    font-size: 14px;
    font-weight: 600;
}
.language summary::-webkit-details-marker { display: none; }
.language ul {
    position: absolute;
    right: 0; top: 36px;
    min-width: 160px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgb(15 23 42 / 0.16);
}
.language a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text); }
.language a:hover { background: var(--surface-strong); text-decoration: none; }
.language a[aria-current="true"] { font-weight: 700; color: var(--accent); }

/* ---------- Opbouw ---------- */

.shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 220px;
    max-width: 1440px;
    margin: 0 auto;
}

.sidebar {
    position: sticky;
    top: var(--topbar);
    height: calc(100vh - var(--topbar));
    overflow-y: auto;
    padding: 24px 16px 40px 24px;
    border-right: 1px solid var(--border);
}
.sidebar__heading {
    margin: 20px 0 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.sidebar__heading:first-child { margin-top: 0; }
.sidebar__list { margin: 0; padding: 0; list-style: none; }
.sidebar__link {
    display: block;
    padding: 5px 10px;
    border-radius: 6px;
    color: var(--text);
    font-size: 15px;
}
.sidebar__link:hover { background: var(--surface-strong); text-decoration: none; }
.sidebar__link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.content {
    min-width: 0;
    padding: 40px 56px 32px;
}
.content:focus { outline: none; }

.toc {
    position: sticky;
    top: var(--topbar);
    height: calc(100vh - var(--topbar));
    overflow-y: auto;
    padding: 40px 20px;
    font-size: 14px;
}
.toc__heading {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.toc__list { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--border); }
.toc__item a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); }
.toc__item a:hover { color: var(--text); text-decoration: none; }
.toc__item a.is-active { border-left-color: var(--accent); color: var(--accent); }
.toc__item--sub a { padding-left: 24px; }

/* ---------- Inhoud ---------- */

.prose { max-width: 780px; }
.prose h1 { margin: 0 0 12px; font-size: 36px; line-height: 1.2; letter-spacing: -0.02em; }
.prose h2 { margin: 48px 0 12px; padding-top: 8px; font-size: 24px; line-height: 1.3; letter-spacing: -0.01em; }
.prose h3 { margin: 32px 0 10px; font-size: 18px; }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose li { margin: 4px 0; }
.prose .lead { font-size: 19px; color: var(--muted); }
.prose .eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.prose hr { margin: 40px 0; border: 0; border-top: 1px solid var(--border); }
.prose :not(pre) > code {
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--inline-code-bg);
    font-size: 0.88em;
    overflow-wrap: anywhere;
}
.prose .h1-code { font-size: 0.9em; }
.prose blockquote { margin: 0 0 16px; padding: 4px 16px; border-left: 3px solid var(--border); color: var(--muted); }

.heading-anchor {
    margin-left: 8px;
    color: var(--muted);
    font-weight: 400;
    opacity: 0;
    text-decoration: none;
}
h2:hover .heading-anchor, h3:hover .heading-anchor, .heading-anchor:focus { opacity: 1; }

.updated, .muted { color: var(--muted); font-size: 14px; }
.updated { margin-top: 40px; }

.table-wrap { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface); font-size: 13px; font-weight: 700; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.type { color: var(--muted); font-family: var(--mono); font-size: 13px; white-space: nowrap; }
td:first-child code { white-space: nowrap; }
.field--nested { padding-left: 32px; }
.constraints { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
}
.badge--required { background: var(--warning-soft); color: var(--warning); }

.button {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}
.button:hover { background: var(--accent-strong); text-decoration: none; }

/* ---------- Kaders ---------- */

.callout {
    margin: 0 0 20px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: var(--surface);
}
.callout > p:last-child { margin-bottom: 0; }
.callout__title { margin: 0 0 4px; font-weight: 700; }
.callout--note { border-left-color: var(--accent); }
.callout--note .callout__title { color: var(--accent); }
.callout--tip { border-left-color: var(--ok); }
.callout--tip .callout__title { color: var(--ok); }
.callout--warning { border-left-color: var(--warning); background: var(--warning-soft); }
.callout--warning .callout__title { color: var(--warning); }

/* ---------- Code ---------- */

.code-block {
    margin: 0 0 20px;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--code-bg);
    color: var(--code-text);
}
.code-block__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    padding: 0 8px 0 14px;
    background: var(--code-bar);
    font-size: 13px;
}
.code-block__label { color: #94a3b8; font-weight: 600; }
.code-block__copy {
    padding: 3px 10px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: transparent;
    color: #cbd5e1;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.code-block__copy:hover { background: #334155; }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; }
.code-block code { background: none; padding: 0; color: inherit; }

.code-tabs { margin: 0 0 20px; }
.code-tabs.is-enhanced { overflow: hidden; border-radius: var(--radius); background: var(--code-bg); }
.code-tabs.is-enhanced .code-block { margin: 0; border-radius: 0; }
.code-tabs.is-enhanced .code-block[hidden] { display: none; }
.code-tabs__nav {
    display: flex;
    gap: 2px;
    padding: 6px 6px 0;
    overflow-x: auto;
    background: var(--code-bar);
    border-bottom: 1px solid #334155;
}
.code-tabs__tab {
    padding: 6px 12px;
    border: 0;
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: #94a3b8;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.code-tabs__tab[aria-selected="true"] { background: var(--code-bg); color: #f8fafc; }

/* In de tabbladen staat het label al in de tab: de eigen balk van elk blok verdwijnt en de
   kopieerknop zweeft rechtsboven in de code. */
.code-tabs.is-enhanced .code-block { position: relative; }
.code-tabs.is-enhanced .code-block__bar {
    position: absolute;
    top: 8px; right: 8px;
    min-height: 0;
    padding: 0;
    background: transparent;
}
.code-tabs.is-enhanced .code-block__label { display: none; }
.code-tabs.is-enhanced .code-block pre { padding-top: 16px; padding-right: 80px; }

/* Kleuren van de server-side gekleurde code (highlight.php). */
.hljs-comment, .hljs-quote { color: #64748b; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-type { color: #c792ea; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta-string { color: #c3e88d; }
.hljs-number, .hljs-literal, .hljs-symbol { color: #f78c6c; }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-params { color: #82aaff; }
.hljs-title, .hljs-section, .hljs-function .hljs-title { color: #82aaff; }
.hljs-variable, .hljs-template-variable { color: #f07178; }
.hljs-meta, .hljs-deletion { color: #ff9cac; }

/* ---------- Referentie ---------- */

.method {
    display: inline-block;
    min-width: 58px;
    padding: 1px 8px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}
.method--get { background: var(--ok-soft); color: var(--ok); }
.method--post { background: var(--accent-soft); color: var(--accent); }
.method--patch, .method--put { background: var(--warning-soft); color: var(--warning); }
.method--delete { background: var(--error-soft); color: var(--error); }

.endpoint-list { margin: 0 0 32px; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius); }
.endpoint-list li + li { border-top: 1px solid var(--border); }
.endpoint-list a { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; color: var(--text); }
.endpoint-list a:hover { background: var(--surface); text-decoration: none; }
.endpoint-list__summary { margin-left: auto; color: var(--muted); font-size: 14px; }

.endpoint { padding-top: 8px; border-top: 1px solid var(--border); margin-top: 48px; }
.endpoint > h2 { margin-top: 24px; }
.endpoint__line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.endpoint__path { font-size: 15px; overflow-wrap: anywhere; }

.facts { margin: 0 0 20px; }
.facts > div { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.facts dt { min-width: 160px; color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; }

.status {
    display: inline-block;
    padding: 0 8px;
    border-radius: 999px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    vertical-align: middle;
}
.status--ok { background: var(--ok-soft); color: var(--ok); }
.status--error { background: var(--error-soft); color: var(--error); }

.error-list { padding-left: 0; list-style: none; }
.error-list li { padding: 4px 0; }

/* ---------- Vorige / volgende en voettekst ---------- */

.pager { display: flex; gap: 16px; max-width: 780px; margin-top: 56px; }
.pager__link {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}
.pager__link:hover { border-color: var(--accent); text-decoration: none; }
.pager__link--next { text-align: right; }
.pager__label { display: block; color: var(--muted); font-size: 13px; }
.pager__title { display: block; font-weight: 600; color: var(--accent); }

.footer { max-width: 780px; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }
.footer p { margin: 0 0 6px; }

/* ---------- Eenvoudige pagina's (404, binnenkort) ---------- */

.plain { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.plain__main { max-width: 520px; }
.plain__main h1 { margin: 28px 0 8px; font-size: 30px; }
.plain__main p { color: var(--muted); }

/* ---------- Kleinere schermen ---------- */

@media (max-width: 1200px) {
    .shell { grid-template-columns: 240px minmax(0, 1fr); }
    .toc { display: none; }
}

@media (max-width: 860px) {
    .topbar { gap: 10px; padding: 0 14px; }
    .topbar__menu { display: inline-block; }
    .topbar__app, .brand__sub { display: none; }
    .search { margin-left: 0; }
    .search__hint { display: none; }
    .shell { display: block; }
    .sidebar {
        position: fixed;
        top: var(--topbar);
        left: 0; bottom: 0;
        width: min(300px, 86vw);
        height: auto;
        background: var(--bg);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 40;
    }
    .sidebar.is-open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgb(15 23 42 / 0.4); }
    .content { padding: 28px 18px 24px; }
    .prose h1 { font-size: 28px; }
    /* Tabellen schuiven liever opzij dan dat woorden midden in de code afbreken. */
    .table-wrap table { min-width: 560px; }
    .pager { flex-direction: column; }
    .endpoint-list__summary { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}
