/* Chat window. Every colour, the font, the corner shape and the logo come from
   /chat/theme.css (generated from configuration, see theme.py); this file only uses the
   variables. Text never sits on --accent: an accent colour may be too light to read. */

:root {
  --text: var(--ink);
  --muted: #6b7280;
  --line: #dddddd;
  --surface: #ffffff;
  --tint: color-mix(in srgb, var(--accent) 14%, #ffffff);
  --error: #a94442;
  --maxw: 820px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--page);
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar { background: var(--header); color: var(--on-header); position: sticky; top: 0; z-index: 10; }
.topbar-inner {
  max-width: 1170px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-logo {
  display: block; width: var(--logo-width, 42px); height: 42px; flex: none;
  background-position: center; background-size: contain; background-repeat: no-repeat;
}
.brand-name { font-weight: var(--heading-weight); font-size: 20px; letter-spacing: .01em; }
.accent-bar { height: 4px; background: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.user { font-weight: 600; }
.link-button {
  background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-weight: 600;
  color: inherit; opacity: .85;
}
.link-button:hover { opacity: 1; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }

/* ── General ─────────────────────────────────────────────────────────── */
main { flex: 1; display: flex; min-height: 0; }
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.eyebrow {
  margin: 0 0 12px; color: var(--muted); font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .16em;
  display: flex; align-items: center; gap: 10px;
}
.eyebrow::before { content: ""; width: 28px; height: 3px; background: var(--accent); flex: none; }
h1 { margin: 0 0 12px; color: var(--ink); font-weight: var(--heading-weight); font-size: 38px; line-height: 1.1; }
.lead { margin: 0; color: var(--muted); font-size: 18px; }

.button {
  display: inline-block; margin-top: 28px; padding: 12px 30px;
  background: var(--button); color: var(--on-button);
  border: 2px solid var(--button); border-radius: var(--radius); text-decoration: none;
  font-size: 18px; font-weight: 800;
  transition: background .15s, color .15s;
}
.button:hover, .button:focus-visible { background: transparent; color: var(--button); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.alert { margin: 18px 0 0; padding: 10px 14px; border-left: 4px solid var(--error); background: #f9eaea; color: var(--error); font-size: 15px; }

.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ───────────────────────────────────────────────────────────── */
.login-card {
  background: var(--surface); max-width: 540px; width: 100%;
  padding: 48px 44px; border-radius: min(var(--radius), 18px);
  border-top: 4px solid var(--accent);
  box-shadow: 0 2px 18px rgba(0, 0, 0, .07);
}

/* ── Chat ────────────────────────────────────────────────────────────── */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; }
.conversation {
  flex: 1; overflow-y: auto; padding: 32px 16px 16px;
  display: flex; flex-direction: column; gap: 18px;
}
.conversation > * { width: 100%; max-width: var(--maxw); margin-left: auto; margin-right: auto; }
.intro { padding: 48px 0 8px; }
.privacy-note {
  margin: 24px 0 0; padding: 12px 16px; max-width: 640px;
  background: var(--tint); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
  color: var(--ink); font-size: 15px; line-height: 1.5;
}
.privacy-note strong { font-weight: 700; display: block; margin-bottom: 2px; }

.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.bubble { max-width: 85%; padding: 12px 16px; border-radius: min(var(--radius), 16px); overflow-wrap: anywhere; }
.msg-user .bubble { background: var(--ink); color: var(--on-ink); white-space: pre-wrap; }
.msg-assistant .bubble {
  max-width: 100%; width: 100%; background: var(--surface);
  border-left: 3px solid var(--accent); box-shadow: 0 1px 6px rgba(0, 0, 0, .05);
}
.msg-assistant { flex-direction: column; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin: 4px 0 0 2px; }
.copy-button {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  cursor: pointer; opacity: .55; transition: opacity .15s, color .15s, background .15s;
}
.msg-assistant:hover .copy-button, .copy-button:focus-visible { opacity: 1; }
.copy-button:hover { color: var(--ink); background: rgba(0, 0, 0, .05); }
.copy-button.copied { color: var(--ink); opacity: 1; }
@media (hover: none) { .copy-button { opacity: 1; } }
.feedback-link {
  margin-left: 6px; font-size: 13px; color: var(--muted); text-decoration: none;
  opacity: .55; transition: opacity .15s, color .15s;
}
.msg-assistant:hover .feedback-link, .feedback-link:focus-visible { opacity: 1; }
.feedback-link:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
@media (hover: none) { .feedback-link { opacity: 1; } }
a.link-button { text-decoration: none; }
.msg-error .bubble { background: #f9eaea; color: var(--error); border-left: 3px solid var(--error); }

.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 10px; }
.bubble h2, .bubble h3, .bubble h4 { color: var(--ink); font-weight: var(--heading-weight); margin: 16px 0 8px; line-height: 1.25; }
.bubble h2 { font-size: 21px; } .bubble h3 { font-size: 19px; } .bubble h4 { font-size: 17px; }
.bubble ul, .bubble ol { margin: 0 0 10px; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.bubble code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; background: var(--page); padding: 1px 5px; border-radius: 3px; }
.bubble pre { background: #1f2328; color: #f2f2f2; padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 0 0 10px; }
.bubble pre code { background: none; color: inherit; padding: 0; }
.bubble blockquote { margin: 0 0 10px; padding: 4px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.table-wrap { overflow-x: auto; margin: 0 0 10px; }
.bubble table { border-collapse: collapse; font-size: 15px; min-width: 50%; }
.bubble th { background: var(--ink); color: var(--on-ink); font-weight: 700; text-align: left; }
.bubble th, .bubble td { padding: 7px 10px; border: 1px solid var(--line); overflow-wrap: normal; vertical-align: top; }
.bubble tr:nth-child(even) td { background: #fafafa; }

.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tool-chip { font-size: 13px; color: var(--ink); background: var(--tint); border-radius: 12px; padding: 2px 10px; }
.tool-chip.running::after { content: " …"; }
.tool-chip.error { background: #f9eaea; color: var(--error); }
.notice { color: var(--muted); font-style: italic; font-size: 14px; }

.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ── Eerdere gesprekken ──────────────────────────────────────────────── */
.history {
  flex: none; width: 270px; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line); padding: 20px 10px 14px;
}
.history-heading {
  margin: 0 8px 10px; color: var(--muted); font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
}
.history-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.history-item { display: flex; align-items: center; border-radius: 8px; }
.history-item:hover { background: rgba(0, 0, 0, .04); }
.history-item.active { background: var(--tint); }
.history-open {
  flex: 1; min-width: 0; padding: 7px 8px; border: 0; background: none; cursor: pointer;
  font: inherit; text-align: left; color: var(--ink);
}
.history-title { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-date { display: block; font-size: 12px; color: var(--muted); }
.history-delete {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-right: 4px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; opacity: 0;
}
.history-item:hover .history-delete, .history-item.active .history-delete, .history-delete:focus-visible { opacity: 1; }
.history-delete:hover { color: var(--error); background: rgba(0, 0, 0, .05); }
@media (hover: none) { .history-delete { opacity: 1; } }
.history-empty { margin: 0 8px; color: var(--muted); font-size: 14px; flex: 1; }
.history-foot { margin: 10px 8px 0; font-size: 12px; color: var(--muted); }
.history-foot p { margin: 0 0 6px; }
.history-foot .link-button { font-size: 13px; }
.history-toggle { display: none; }

/* ── Composer ────────────────────────────────────────────────────────── */
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  width: calc(100% - 32px); max-width: var(--maxw); margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--control-radius);
  padding: 8px 8px 8px 20px; box-shadow: 0 2px 14px rgba(0, 0, 0, .06);
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; border: 0; resize: none; outline: none; font: inherit; color: var(--text);
  padding: 8px 0; max-height: 220px; background: transparent;
}
.send {
  flex: none; width: 42px; height: 42px; border: 0; border-radius: var(--control-radius); cursor: pointer;
  background: var(--button); color: var(--on-button); display: grid; place-items: center;
}
.send:hover { filter: brightness(1.15); }
.send:disabled { background: var(--line); color: var(--muted); cursor: default; filter: none; }
.footnote { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 16px 14px; }

/* Smal scherm: de lijst klapt uit over het gesprek, via de knop Gesprekken. */
@media (max-width: 900px) {
  .history-toggle { display: inline; }
  .history { display: none; }
  body.history-open .history:not([hidden]) {
    /* onder de (sticky) topbalk door, die z-index 10 heeft */
    display: flex; position: fixed; left: 0; bottom: 0; top: 0; padding-top: 90px; z-index: 9;
    width: min(320px, 85vw); box-shadow: 4px 0 18px rgba(0, 0, 0, .12);
  }
}

@media (max-width: 600px) {
  .brand-logo { height: 34px; max-width: 40vw; }   /* a wide word mark must leave room for the menu */
  .brand-name { font-size: 18px; }
  .topbar-right { gap: 12px; }
  .user { display: none; }
  h1 { font-size: 28px; }
  .login-card { padding: 32px 22px; }
  .bubble { max-width: 92%; }
}
