/* Codepaneel (codelezer.js, codepaneel.js; ADR 0117): code bekijken zonder agentbeurt.
   Leesvenster, codeverwijzing onder een agentbericht, de pagina Code (vorm B2), het
   leesvenster naast de volle chat en het paneel in de rij op het werkblad (V1). Alleen variabelen uit styles.css.
   Vaste regelhoogte: .cp-r is 20px hoog (REGEL_PX in codelezer.js); de lege stroken van
   een groot notebook krijgen hun hoogte daarmee vooraf, dus samen wijzigen. */

/* ── Knop Code in de kop van de volle chat ── */
#btn-code-paneel[aria-pressed="true"] { color: var(--accent); opacity: 1; background: var(--accent-tint); }

/* ── Codeverwijzing onder een agentbericht ── */
.cp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.cp-chip {
    display: inline-flex; align-items: center; gap: 7px; max-width: 100%; height: 30px; padding: 0 10px 0 9px;
    font: inherit; font-size: 12.5px; color: var(--fg); background: var(--accent-tint); cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--r-md);
}
.cp-chip:hover { background: var(--accent-tint-hi); }
.cp-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cp-chip svg { width: 14px; height: 14px; flex: none; }
.cp-chip-ic { display: inline-flex; color: var(--accent); }
.cp-chip-naam { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cp-chip-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cp-chip-pijl { display: inline-flex; color: var(--muted); }

/* ── Leesvenster ── */
.cp-lezer { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; background: var(--sidebar-bg); color: var(--fg); font-size: var(--fs); }
.cp-kop { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--sep); }
.cp-rij { display: flex; align-items: center; gap: 6px; min-height: 28px; min-width: 0; }
.cp-rij2 { flex-wrap: wrap; }
.cp-lezer .vp-knop { text-decoration: none; }
.cp-lezer .vp-knop svg, .cp-lezer .btn-primary svg, .cp-lezer .btn-secondary svg { width: 13px; height: 13px; }
.cp-lezer .btn-primary.btn-sm, .cp-lezer .btn-secondary.btn-sm { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.cp-lezer .split-iconbtn { width: 26px; height: 26px; }
.cp-lezer .split-iconbtn svg { width: 14px; height: 14px; }
.cp-lezer .split-iconbtn:disabled { opacity: .25; cursor: default; background: transparent; }
.cp-lezer :is(.vp-knop, .split-iconbtn, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; opacity: 1; }
.cp-terug, .cp-terug-chat { display: none; }

/* Itemwisselaar (naast het gesprek): zoekveld met uitklaplijst. */
.cp-wissel { position: relative; flex: 1; min-width: 160px; display: flex; align-items: center; height: 30px;
    background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--r-md); }
.cp-wissel:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.cp-wissel-ic { display: inline-flex; padding: 0 2px 0 8px; color: var(--accent); }
.cp-wissel-ic svg { width: 15px; height: 15px; }
.cp-wissel-in { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--fg); padding: 0 4px; }
.cp-wissel-chev { display: inline-flex; align-items: center; height: 100%; padding: 0 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.cp-wissel-chev svg { width: 14px; height: 14px; }
.cp-wissel-lijst { position: absolute; z-index: 30; left: -1px; right: -1px; top: calc(100% + 4px); max-height: 360px; overflow: auto; padding: 4px;
    background: var(--widget-bg); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.cp-wissel-groep { padding: 6px 8px 4px; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cp-wissel-optie { display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 8px 0 0; border-radius: var(--r-sm); font-size: 12.5px; color: var(--fg); cursor: pointer; }
.cp-wissel-optie:hover, .cp-wissel-optie.is-focus { background: var(--surface-hi); }
.cp-wissel-optie.is-actief { font-weight: 600; color: var(--accent); }
.cp-wissel-naam { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-wissel-soort { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 400; color: var(--muted); }
.cp-wissel-leeg { padding: 8px; color: var(--muted); font-size: 12px; }

.cp-pad { display: inline-flex; align-items: center; gap: 5px; min-width: 0; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.cp-pad svg { width: 13px; height: 13px; flex: none; }
.cp-pad span { overflow: hidden; text-overflow: ellipsis; }
.cp-dot { opacity: .6; }
.cp-titel-ic { display: inline-flex; color: var(--accent); }
.cp-titel-ic svg { width: 17px; height: 17px; }
.cp-titel { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.cp-titel:empty { display: none; }

/* Zoeken in het item */
.cp-zoekbalk { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--sep); background: var(--bg); }
.cp-zoek { flex: 1 1 260px; max-width: 420px; min-width: 120px; display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px;
    background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--r-md); color: var(--muted); }
.cp-zoek:focus-within { border-color: var(--accent); }
.cp-zoek svg { width: 14px; height: 14px; flex: none; }
.cp-zoek input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 12.5px; color: var(--fg); }
.cp-zoek-tel { font-size: 11.5px; color: var(--muted); white-space: nowrap; padding: 0 4px; font-variant-numeric: tabular-nums; }
.cp-alleen { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cp-alleen svg { width: 14px; height: 14px; }

/* Melding: regels verborgen door het geheimenfilter */
.cp-verborgen { display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px; font-size: 12px; color: var(--fg);
    background: color-mix(in srgb, var(--warn) 10%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.cp-verborgen svg { width: 14px; height: 14px; flex: none; margin-top: 1px; color: var(--warn); }

/* Cellen: het codeblok van de chat (.code-block) met regelnummers, inklapbaar. */
.cp-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 10px 24px; display: flex; flex-direction: column; gap: 10px; outline: none; }
.cp-cel { margin: 0; flex: none; }
.cp-cel > summary { list-style: none; cursor: pointer; gap: 8px; min-height: 30px; font-size: 11.5px; justify-content: flex-start; }
.cp-cel > summary::-webkit-details-marker { display: none; }
.cp-cel:not([open]) > summary { border-bottom: 0; }
.cp-chev { display: inline-flex; color: var(--muted); transition: transform .12s; }
.cp-chev svg { width: 12px; height: 12px; }
:is(.cp-cel, .cp-schema, .cp-wb-groep)[open] > summary .cp-chev { transform: rotate(90deg); }
.cp-cel-nr { font-family: var(--mono); color: var(--muted); }
.cp-taal { padding: 0 7px; height: 18px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--accent-tint); white-space: nowrap; }
.cp-taal.is-tekst { color: var(--muted); background: var(--surface-hi); }
.cp-cel-info { color: var(--muted); white-space: nowrap; }
.cp-prev { display: none; font-family: var(--mono); color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cp-cel:not([open]) .cp-prev { display: block; flex: 0 1 auto; }
.cp-treffers { padding: 0 7px; height: 18px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 10.5px; color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); white-space: nowrap; }
.cp-cel .btn-copy { display: inline-flex; padding: 3px 5px; }
.cp-cel .btn-copy svg { width: 13px; height: 13px; }
.cp-md-wissel { display: inline-flex; gap: 2px; }
.cp-md-wissel .vp-knop { height: 22px; padding: 0 7px; font-size: 11px; }

.cp-code { overflow: auto; padding: 8px 0; font-family: var(--mono); font-size: 12.5px; line-height: 20px; tab-size: 4; }
.cp-r { display: flex; height: 20px; min-width: max-content; }
.cp-r:hover { background: var(--surface); }
.cp-ln { flex: none; width: 3.6em; padding-right: 12px; text-align: right; color: var(--faint); user-select: none; }
.cp-t { white-space: pre; padding-right: 16px; }
.cp-r.is-verborgen .cp-t { color: var(--muted); font-style: italic; }
mark.cp-treffer { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 2px; }
mark.cp-treffer.is-nu { background: color-mix(in srgb, var(--accent) 45%, transparent); outline: 1px solid var(--accent); }
.cp-md { padding: 10px 14px 12px; background: var(--widget-bg); line-height: 1.55; overflow-wrap: anywhere; }
.cp-md > :first-child { margin-top: 0; }
.cp-md > :last-child { margin-bottom: 0; }
.cp-md pre { overflow: auto; }
.cp-md :is(ul, ol) { margin: 0 0 6px; padding-left: 22px; }
.cp-frontmatter { margin: 0 0 10px; padding: 8px 10px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--sep); border-radius: var(--r-sm); white-space: pre-wrap; }

/* Toestanden: leeg, laden, fout */
.cp-staat { margin: auto; max-width: 440px; padding: 28px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); }
.cp-staat.is-laden { flex-direction: row; gap: 10px; }
.cp-staat-ic { display: inline-flex; color: var(--faint); }
.cp-staat-ic svg { width: 28px; height: 28px; }
.cp-staat.is-fout .cp-staat-ic { color: var(--warn); }
.cp-staat.is-login .cp-staat-ic, .cp-staat.is-toegang .cp-staat-ic { color: var(--accent); }
.cp-staat-titel { margin: 4px 0 0; font-size: 14px; font-weight: 600; color: var(--fg); }
.cp-staat-tekst { margin: 0; font-size: 12.5px; line-height: 1.5; }
.cp-staat-acties { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.cp-spinner { width: 16px; height: 16px; border: 2px solid var(--sep); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

/* Objecten van een SQL-bron */
.cp-objecten { display: flex; flex-direction: column; gap: 4px; }
.cp-schema > summary { list-style: none; display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px; cursor: pointer; font-weight: 600; font-size: 12.5px; border-radius: var(--r-sm); }
.cp-schema > summary::-webkit-details-marker { display: none; }
.cp-schema > summary:hover { background: var(--surface-hi); }
.cp-object { display: flex; align-items: center; gap: 7px; width: 100%; height: 28px; padding: 0 8px 0 26px; border: 0; background: transparent; border-radius: var(--r-sm);
    font: inherit; font-size: 12.5px; color: var(--fg); text-align: left; cursor: pointer; }
.cp-object:hover { background: var(--surface-hi); }
.cp-object-ic { display: inline-flex; color: var(--accent); }
.cp-object-ic svg { width: 14px; height: 14px; }
.cp-object-naam { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-object-soort { font-size: 11px; color: var(--muted); }

/* Smal leesvenster: knoppen alleen als icoon. */
.cp-wb-lezerkol, .cp-naast, .cp-rijpaneel { container: cplezer / inline-size; }
@container cplezer (max-width: 620px) {
    .cp-lezer .vp-knop:not(.cp-md-knop) span, .cp-lezer .btn-primary.cp-vraag span, .cp-lezer .cp-alleen span { display: none; }
}
@container cplezer (max-width: 480px) {
    .cp-lezer.is-werkblad .cp-pad { display: none; }
}

/* ── Naast de volle chat: op de plek en met de breedte van het voorbeeldpaneel ── */
.cp-naast { display: none; }
body.code-open .cp-naast {
    position: relative; display: flex; flex-direction: column; flex-shrink: 0; min-width: 0;
    width: clamp(480px, 46vw, 1400px); max-width: calc(100vw - 420px);
    border-left: 1px solid var(--sep); background: var(--sidebar-bg);
}
@media (max-width: 1199px) {
    body.code-open .cp-naast { position: fixed; inset: 0; z-index: 10000; width: auto; max-width: none; border-left: 0; }
    .cp-lezer.is-naast .cp-terug-chat { display: inline-flex; }
}

/* ── Werkblad met meerdere sessies: paneel in de rij (V1) ──
   Knop Code in de paneelkop; met het paneel open staat er "Code" bij en krijgt de sessie de
   accentrand. In de stapel van Focus geen knop (de kaart is daar te klein). */
.pane-btn.pane-code { width: auto; gap: 3px; padding: 0 5px; font: inherit; font-size: 11px; font-weight: 600; }
.pane-btn.pane-code span { display: none; }
.pane.cp-is-bron { border-color: color-mix(in srgb, var(--accent) 60%, var(--sep)); }
.pane.cp-is-bron .pane-btn.pane-code { color: var(--accent); opacity: 1; background: var(--accent-tint); }
.pane.cp-is-bron .pane-btn.pane-code span { display: inline; }
.pane-stapel .pane-btn.pane-code { display: none; }
.pane-btn.pane-code:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; opacity: 1; }
/* Het paneel zelf: twee kolommen van het grid (bij 1920 px met zeven sessies ca. 730 px). */
.cp-rijpaneel {
    grid-column: span 2; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
    border: 1px solid var(--sep); border-radius: var(--r-lg); background: var(--sidebar-bg); box-shadow: var(--shadow-sm);
}
.cp-rij-bron { flex: none; display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 10px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--sep); }
.cp-rij-bron .pane-slot { background: var(--accent); color: #fff; }
.cp-rij-bij { flex: none; }
.cp-rij-titel { min-width: 0; color: var(--fg); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-rijpaneel .cp-lezer.is-naast .cp-terug-chat { display: none; }
/* Focus: brede sessie | code | stapel. Het paneel staat in de DOM achteraan (codepaneel.js). */
.home-layout.has-panes .home-panes[data-indeling="focus"].cp-in-rij { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) clamp(260px, 20%, 340px); }
.home-layout.has-panes .home-panes[data-indeling="focus"].cp-in-rij.stapel-leeg { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
.home-panes[data-indeling="focus"].cp-in-rij > .pane { grid-column: 1; grid-row: 1; }
.home-panes[data-indeling="focus"].cp-in-rij > .cp-rijpaneel { grid-column: 2; grid-row: 1; }
.home-panes[data-indeling="focus"].cp-in-rij > .pane-stapel { grid-column: 3; grid-row: 1; }

/* ── Pagina Code (vorm B2): Bronnen | Items | Leesvenster ── */
.view-panel.cp-view { overflow: hidden; }
.cp-wb-paginakop { display: flex; align-items: center; gap: 12px; padding: 12px 16px 10px; border-bottom: 1px solid var(--sep); }
.cp-wb-paginakop .page-heading { min-width: 0; }
.cp-wb-paginakop .page-title { font-size: 17px; }
.cp-wb-paginakop .page-desc { font-size: 12px; }
.cp-wb-paginakop .btn-secondary { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.cp-wb-paginakop .btn-secondary svg { width: 13px; height: 13px; }
.cp-wb { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px 270px minmax(0, 1fr); }
.cp-wb.bronnen-dicht { grid-template-columns: 40px 270px minmax(0, 1fr); }
.cp-wb-kol { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--sep); background: var(--sidebar-bg); }
.cp-wb-kolkop { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 6px 0; }
.cp-wb-kolkop .sb-nav-title { padding-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cp-wb .split-iconbtn { width: 26px; height: 26px; }
.cp-wb .split-iconbtn svg { width: 15px; height: 15px; }
.cp-wb .split-iconbtn.is-active { color: var(--accent); background: var(--accent-tint); opacity: 1; }
.cp-wb .split-iconbtn:focus-visible, .cp-wb .sb-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; opacity: 1; }
.cp-wb-strook { display: none; flex-direction: column; align-items: center; gap: 4px; padding-top: 6px; }
.cp-wb.bronnen-dicht .cp-wb-strook { display: flex; }
.cp-wb.bronnen-dicht .cp-wb-bronnen .cp-wb-lijst, .cp-wb.bronnen-dicht .cp-wb-bronnen .sb-nav-title,
.cp-wb.bronnen-dicht .cp-wb-bronnen .tb-spacer { display: none; }
.cp-wb.bronnen-dicht .cp-wb-bronnen .cp-wb-kolkop { justify-content: center; padding-inline: 0; }
.cp-wb-tel { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.cp-wb-filter { padding: 4px 8px 8px; }
.cp-wb-filter .cp-zoek { max-width: none; }
.cp-wb-lijst { flex: 1; min-height: 0; overflow: auto; padding: 0 6px 12px; }
.cp-wb .sb-item { height: 28px; gap: 7px; font-size: 12.5px; }
.cp-wb-groep > summary { list-style: none; }
.cp-wb-groep > summary::-webkit-details-marker { display: none; }
.cp-wb-groepkop { font-weight: 500; }
.cp-wb-groepkop .cp-chev { width: 12px; flex: none; }
.cp-wb-groep[data-leeg] > summary { opacity: .5; }
.cp-wb-kind { padding: 0 0 4px 19px; display: flex; flex-direction: column; gap: 1px; }
.cp-wb-rij .sb-text { font-weight: 400; }
.cp-wb-rij.is-active .sb-text { font-weight: 600; }
.cp-wb-klant { display: flex; flex-direction: column; gap: 3px; padding: 4px 8px 8px; }
.cp-wb-klantlabel { font-size: 11px; color: var(--muted); }
.cp-wb-klantkeuze { height: 28px; padding: 0 6px; font: inherit; font-size: 12.5px; color: var(--fg);
    background: var(--input-bg); border: 1px solid var(--input-border); border-radius: var(--r-sm); min-width: 0; }
.cp-wb-klantkeuze:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cp-wb-melding { display: flex; flex-direction: column; gap: 4px; margin: 2px 0; padding: 6px 8px; font-size: 12px; line-height: 1.45; color: var(--muted); }
.cp-wb-melding.is-fout { color: var(--fg); }
.cp-wb-melding.is-fout strong { font-weight: 600; }
.cp-wb-acties { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cp-wb-lezerkol { display: flex; min-height: 0; min-width: 0; }

/* Smal scherm: één kolom tegelijk (bronnen, dan items, dan het leesvenster). */
@media (max-width: 820px) {
    .cp-wb-paginakop { padding: 10px 12px 8px; }
    .cp-wb-paginakop .page-desc { display: none; }
    .cp-wb, .cp-wb.bronnen-dicht { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
    .cp-wb-kol { border-right: 0; }
    .cp-wb:not(.bronnen-dicht) .cp-wb-items, .cp-wb .cp-wb-lezerkol { display: none; }
    .cp-wb.bronnen-dicht { grid-template-rows: auto minmax(0, 1fr); }
    .cp-wb.bronnen-dicht .cp-wb-bronnen { flex-direction: row; align-items: center; border-bottom: 1px solid var(--sep); }
    .cp-wb.bronnen-dicht .cp-wb-bronnen .cp-wb-kolkop { padding: 4px 6px; }
    .cp-wb.bronnen-dicht .cp-wb-strook { flex-direction: row; padding: 0; }
    .cp-wb.is-lezen { grid-template-rows: minmax(0, 1fr); }
    .cp-wb.is-lezen .cp-wb-kol { display: none; }
    .cp-wb.is-lezen .cp-wb-lezerkol { display: flex; }
    .cp-lezer.is-werkblad .cp-terug { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
    .cp-chev, .cp-spinner { transition: none !important; animation: none !important; }
}
/* Na alle regels hierboven: een display-klasse mag het hidden-attribuut niet overstemmen. */
.cp-lezer [hidden], .cp-wb [hidden], .cp-chips [hidden], .cp-rijpaneel [hidden], #code-terug[hidden] { display: none !important; }

/* Code bekijken is voorlopig alleen voor Data Engineers (ADR 0117): ingangen verborgen. */
body.cp-geen-toegang .pane-btn.pane-code,
body.cp-geen-toegang .cp-chips { display: none !important; }
