/* ==========================================================================
   E-bike waardebepaling — licht thema (wit + blauw)

   Eén stylesheet voor zowel de chat (index.html) als het beheer
   (beheer.html). De beheer-pagina heeft een eigen <style>-blok dat op
   dezelfde variabelen leunt, dus de namen hieronder blijven ongewijzigd;
   alleen hun waarden zijn licht geworden.
   ========================================================================== */

/* Inter — variabel, self-hosted (SIL Open Font License).
   Eén bestand voor alle gewichten 100-900. */
@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Vlakken */
  --bg: #f4f6fa;        /* pagina-achtergrond en code-blokken */
  --panel: #ffffff;     /* kaarten, panelen */
  --panel-2: #f5f8fd;   /* subtiele vulling binnen een kaart */
  --line: #e3e8f0;      /* randen */

  /* Tekst */
  --text: #101828;
  --muted: #667085;

  /* Blauw */
  --accent: #2563eb;
  --accent-2: #1d4ed8;  /* donkerder: voor tekst op wit */
  --accent-soft: #eef4ff;
  --danger: #d92d20;
  --positive: #067647;

  /* Chatbubbels */
  --bot: #ffffff;
  --user: #e7effd;

  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .07);

  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.011em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -0.021em; font-weight: 600; }

::selection { background: var(--accent-soft); }

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

/* Topbar ---------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .85rem 1.75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .75rem; }

/* Woordmerk in plaats van een icoon: twee letters, rustig blauw. */
.logo {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: .82rem; font-weight: 600; letter-spacing: .02em;
}
.topbar h1 { font-size: .98rem; margin: 0; font-weight: 600; }
.sub { margin: 1px 0 0; color: var(--muted); font-size: .78rem; }

.tabs { display: flex; gap: .15rem; align-items: center; }
.tab {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: .45rem .8rem; border-radius: 7px;
  font: inherit; font-size: .86rem; font-weight: 500;
  text-decoration: none; white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }

/* Panels ---------------------------------------------------------------- */
.tabpanel { display: none; max-width: 780px; margin: 0 auto; padding: 2rem 1.5rem; }
.tabpanel.active { display: block; }
.hidden { display: none !important; }

/* Buttons --------------------------------------------------------------- */
button.primary {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: 8px; padding: .55rem 1.05rem;
  font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .12s ease, border-color .12s ease;
}
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
button.primary.big { padding: .7rem 1.5rem; font-size: .95rem; }
button.ghost {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem 1rem;
  font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .12s ease, background .12s ease;
}
button.ghost:hover { border-color: #cdd7e5; background: var(--panel-2); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* Chat setup ------------------------------------------------------------ */
.chat-setup {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2.75rem 2rem;
  text-align: center; box-shadow: var(--shadow-md);
}
.chat-setup label { display: block; font-weight: 500; margin-bottom: .5rem; }
.hero-icon { display: none; }   /* bewust geen icoon */
.setup-title { margin: 0 0 .5rem; font-size: 1.6rem; font-weight: 600; }
.setup-lead {
  margin: 0 auto 1.75rem; color: var(--muted);
  font-size: .95rem; line-height: 1.6; max-width: 46ch;
}

/* De vier onderwerpen: platte tekst, gescheiden door dunne lijnen. */
.setup-points {
  list-style: none; padding: 0;
  margin: 0 auto 1.75rem; max-width: 30rem;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.setup-points li {
  padding: .7rem .9rem;
  font-size: .86rem; font-weight: 500; color: var(--text);
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.setup-points li:nth-child(odd) { border-right: 1px solid var(--line); }
.setup-points li:nth-last-child(-n+2) { border-bottom: 0; }
.setup-points li span { display: none; }   /* de emoji-spans blijven leeg */

.setup-row { display: flex; gap: .6rem; justify-content: center; }

select, input, textarea {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .55rem .7rem; font: inherit; font-size: .9rem; flex: 1;
  box-shadow: var(--shadow-sm);
  transition: border-color .12s ease, box-shadow .12s ease;
}
select:hover, input:hover, textarea:hover { border-color: #cdd7e5; }
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
::placeholder { color: #98a2b3; }

.hint { color: var(--muted); font-size: .83rem; }
.hint code, code {
  background: var(--panel-2); border: 1px solid var(--line);
  padding: .5px 5px; border-radius: 5px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .88em;
}

/* Chat shell ------------------------------------------------------------ */
.chat-shell {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  height: calc(100vh - 190px);
  box-shadow: var(--shadow-md);
}
.chat-log {
  flex: 1; overflow-y: auto; padding: 1.5rem;
  display: flex; flex-direction: column; gap: .65rem;
  background: var(--bg);
}

.msg {
  max-width: 76%; padding: .65rem .9rem; border-radius: 12px;
  line-height: 1.5; font-size: .92rem; white-space: pre-wrap;
  animation: rise .16s ease;
}
.msg.bot {
  background: var(--bot); border: 1px solid var(--line);
  border-bottom-left-radius: 3px; align-self: flex-start;
  box-shadow: var(--shadow-sm);
}
.msg.user {
  background: var(--user); color: var(--accent-2);
  border: 1px solid #d3e0fb;
  border-bottom-right-radius: 3px; align-self: flex-end;
  font-weight: 500;
}
.msg.system {
  align-self: center; background: transparent; color: var(--muted);
  font-size: .81rem; text-align: center; max-width: 100%;
  padding: .25rem 0;
}
.msg .help { color: var(--muted); font-size: .82rem; margin-top: .35rem; }
@keyframes rise { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Resultaatkaart -------------------------------------------------------- */
.result-card {
  align-self: stretch; max-width: 100%;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem;
  box-shadow: var(--shadow-md);
}
.result-value {
  font-size: 2.1rem; font-weight: 600; color: var(--accent-2);
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.result-band { margin-top: .15rem; font-size: .85rem; color: var(--muted); }
.result-note {
  margin-top: .75rem; padding: .55rem .75rem;
  background: var(--accent-soft); border-radius: 8px;
  font-size: .86rem; color: var(--accent-2); font-weight: 500;
}
.breakdown { margin-top: 1rem; border-top: 1px solid var(--line); }
.brow {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .5rem 0; border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.brow:last-child { border-bottom: 0; }
.brow .amt { font-variant-numeric: tabular-nums; font-weight: 500; }
.brow .amt.neg { color: var(--danger); }
.brow .amt.pos { color: var(--positive); }
.brow.base { font-weight: 600; }

/* Pedal Pro: officieel bod en de laatste stap vóór het onomkeerbare ------- */
.quote-card { border-color: var(--accent); }
.confirm-card { border-color: var(--danger); }
.confirm-card .result-note {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

/* Chat-invoer ----------------------------------------------------------- */
.chat-input {
  border-top: 1px solid var(--line); padding: 1rem 1.25rem;
  min-height: 64px; background: var(--panel);
}
.options { display: flex; flex-wrap: wrap; gap: .45rem; }
.opt-btn {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .45rem .9rem; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.opt-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.opt-btn .val { color: var(--muted); font-weight: 400; font-size: .78rem; margin-left: .4rem; }
.text-row { display: flex; gap: .5rem; }
.text-row input { flex: 1; }

.chat-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .6rem 1.25rem;
  border-top: 1px solid var(--line); background: var(--panel);
}
.status { color: var(--muted); font-size: .81rem; }
.status.err { color: var(--danger); }

/* Flow-editor ----------------------------------------------------------- */
.editor-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: .5rem;
}
.editor-head h2 { margin: 0 0 .2rem; font-size: 1.2rem; }
.editor-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.editor-msg { min-height: 1.2rem; font-size: .86rem; margin: .3rem 0 1.1rem; }
.editor-msg.ok { color: var(--positive); }
.editor-msg.err { color: var(--danger); }

.question-list { display: flex; flex-direction: column; gap: .6rem; }
.qcard {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
}
.qcard.dragging { opacity: .4; }
.qcard.dragover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.qcard-head { display: flex; align-items: center; gap: .6rem; }
.drag-handle { cursor: grab; color: #98a2b3; font-size: 1rem; user-select: none; letter-spacing: -2px; }
.qcard-head .field { font-weight: 600; font-size: .92rem; }
.qcard-head .badge {
  font-size: .72rem; color: var(--muted);
  border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 999px; padding: 1px 8px; font-weight: 500;
}
.qcard-head .spacer { flex: 1; }
.icon-btn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  font: inherit; font-size: .84rem; padding: .2rem .45rem; border-radius: 6px;
}
.icon-btn:hover { color: var(--danger); background: #fef3f2; }
.qcard-body { margin-top: .8rem; display: grid; gap: .6rem; }
.qcard-body label { font-size: .78rem; color: var(--muted); display: block; margin-bottom: .25rem; font-weight: 500; }
.qcard-body .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.qcard-body input, .qcard-body select, .qcard-body textarea { width: 100%; }
.options-editor { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: .7rem; }
/* Vinkje in de vraagkaart (bv. 'optioneel'): label naast het hokje, niet erboven. */
.qcard-body label.check-line {
  display: flex; align-items: center; gap: .45rem; margin-bottom: 0;
}
.qcard-body label.check-line input { width: auto; }
.opt-line { display: flex; gap: .4rem; margin-bottom: .4rem; align-items: center; }
.opt-line input { flex: 1; }
.opt-line .icon-btn { flex: 0; }
.add-opt { font-size: .82rem; }
.collapsed .qcard-body { display: none; }

/* Chat-only toegangspunt (/chat): verberg de beheer-link ----------------- */
.chat-only .tabs { display: none; }

.src-note {
  margin-top: .75rem; font-size: .81rem; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: .6rem;
}

/* Mobiel ---------------------------------------------------------------- */
@media (max-width: 640px) {
  .topbar { padding: .75rem 1rem; }
  .tabpanel { padding: 1.25rem 1rem; }
  .chat-setup { padding: 2rem 1.25rem; }
  .setup-points { grid-template-columns: 1fr; }
  .setup-points li:nth-child(odd) { border-right: 0; }
  .setup-points li:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .msg { max-width: 88%; }
  .chat-shell { height: calc(100vh - 160px); }
}
