/* TRAI Studio. Farben und Maße stehen als Variablen ganz oben: Wer die Marke ändert,
   ändert nur diesen Block. */

@font-face {
  font-family: "Geist";
  src: url("/static/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --accent: #0b6e69;          /* Petrol: Akzentfarbe (Entscheidung X) */
  --accent-hover: #095a56;
  --accent-soft: #e3f1ef;
  --on-accent: #ffffff;

  --page: #f6f7f7;
  --surface: #ffffff;
  --surface-muted: #f0f2f2;
  --text: #17201f;
  --text-muted: #5b6766;
  --border: #dde3e2;
  --border-strong: #c3cccb;

  --success: #1e7a3c;  --success-soft: #e6f4ea;
  --info: #1d5fae;     --info-soft: #e7f0fb;
  --warning: #8a5a00;  --warning-soft: #fff4dc;
  --danger: #b42318;   --danger-soft: #fdecea;

  --radius: 10px;
  --radius-small: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 24, 0.06);
  --font: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--text-muted); }
.icon { width: 18px; height: 18px; flex: none; }

/* --- Marke ---------------------------------------------------------------- */

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 650; color: var(--text); text-decoration: none; letter-spacing: -0.01em;
}
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
}

/* --- Rahmen mit Navigation -------------------------------------------------- */

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 22px 16px; background: var(--surface); border-right: 1px solid var(--border);
}
.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-small);
  color: var(--text-muted); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface-muted); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.company { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: 36px 44px 64px; min-width: 0; }
.content > .notice { max-width: 960px; margin: 0 auto 24px; }
.page { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page.narrow { max-width: 680px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.page-actions { display: flex; gap: 8px; }

@media (max-width: 760px) {
  /* auto 1fr: Die Leiste ist nur so hoch wie nötig, der Inhalt bekommt den Rest.
     Ohne diese Zeile verteilt das Raster die freie Höhe auf beide Zeilen. */
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .nav-links { flex-direction: row; }
  .sidebar-footer { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .company { display: none; }
  .content { padding: 24px 16px 48px; }
}

/* --- Karten, Listen, Leerzustände -------------------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
a.card { color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
a.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.assistant-card { min-height: 120px; justify-content: space-between; }
.danger-zone { border-color: #f1c4bf; }

.empty {
  grid-column: 1 / -1; text-align: center; padding: 56px 24px;
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty p { max-width: 460px; }

.badge {
  align-self: flex-start; font-size: 12.5px; font-weight: 550; padding: 3px 10px; border-radius: 999px;
}
.badge.neutral { background: var(--surface-muted); color: var(--text-muted); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

.status-line { font-weight: 550; font-size: 14px; }
.status-line.success { color: var(--success); }
.status-line.warning { color: var(--warning); }

.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.assistant-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.assistant-card h2 { margin-bottom: 4px; }
.assistant-card p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.assistant-avatar {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}

/* --- Ein Assistent: Kopf, Reiter, Checkliste, Kennzahlen ------------------------ */

.back-link {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-size: 13.5px; color: var(--text-muted); text-decoration: none;
}
.back-link:hover { color: var(--text); }
.assistant-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.assistant-header .badge { align-self: center; }

.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none; margin-bottom: 4px;
}
.tab {
  padding: 10px 12px; color: var(--text-muted); text-decoration: none; font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.card-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.step {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-top: 1px solid var(--border);
}
.step:first-child { border-top: 0; }
.step > .icon { width: 22px; height: 22px; color: var(--border-strong); }
.step.done > .icon { color: var(--success); }
.step-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.step-title { font-weight: 550; }
.step.done .step-title { color: var(--text-muted); font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat strong { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }

/* --- Wissen: Quellen, Fortschritt, Seitenliste ---------------------------------- */

h3 { font-size: 15px; font-weight: 600; }
.stack-small { display: flex; flex-direction: column; gap: 10px; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.source-url {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere;
}
.source-url:hover { color: var(--accent); }
.source-url .icon { width: 15px; height: 15px; color: var(--text-muted); }

.progress { display: flex; flex-direction: column; gap: 8px; }
.progress-head { display: flex; align-items: center; gap: 10px; }
.progress .meter-bar span { transition: width 0.6s ease; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); text-decoration: none;
}
.chip:hover { color: var(--text); border-color: #a9b5b4; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.row-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-small); }
.row-list li + li { border-top: 1px solid var(--border); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; color: inherit; text-decoration: none;
}
a.row:hover { background: var(--surface-muted); }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .badge { flex: none; align-self: center; }

.fact-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 12px; }
.fact-list blockquote {
  margin: 4px 0 0; padding: 4px 0 4px 10px; border-left: 3px solid var(--border-strong); border-radius: 0;
  font-size: 13px; color: var(--text-muted);
}
details.chunk { border-top: 1px solid var(--border); padding: 10px 0; }
details.chunk summary { cursor: pointer; font-weight: 550; }
.chunk-text { white-space: pre-wrap; font-size: 14px; color: var(--text-muted); margin-top: 8px; }

/* --- Produkte ---------------------------------------------------------------- */

.search-field {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-small); background: var(--surface);
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-field .icon { color: var(--text-muted); }
.search-field input { border: 0; box-shadow: none; flex: 1; padding: 10px 0; background: transparent; }
.search-field input:focus { box-shadow: none; }

.attributes {
  display: grid; grid-template-columns: minmax(120px, max-content) 1fr; margin: 0;
  border: 1px solid var(--border); border-radius: var(--radius-small); overflow: hidden;
}
.attributes dt, .attributes dd { margin: 0; padding: 9px 14px; border-top: 1px solid var(--border); }
.attributes dt:first-of-type, .attributes dd:first-of-type { border-top: 0; }
.attributes dt { color: var(--text-muted); background: var(--surface-muted); font-size: 14px; }
@media (max-width: 520px) {
  .attributes { grid-template-columns: 1fr; }
  .attributes dd { border-top: 0; padding-top: 0; }
}

/* --- Testchat -------------------------------------------------------------------- */

.chat-log {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface-muted); border-radius: var(--radius-small);
  min-height: 240px; max-height: 560px; overflow-y: auto;
}
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); white-space: pre-wrap; }
.bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.bubble.typing { color: var(--text-muted); font-style: italic; }
.bubble.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.bubble p { margin: 0 0 6px; }
.bubble p:last-of-type { margin-bottom: 0; }
.bubble ul { margin: 4px 0 6px; padding-left: 20px; }
.marker { font-size: 0.72em; color: var(--accent); margin-left: 1px; font-weight: 600; }
.chat-sources { margin: 10px 0 0; padding: 8px 0 0 20px; border-top: 1px solid var(--border); font-size: 13px; }
.diagnosis { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border-strong); font-size: 13px; }
.diagnosis summary { cursor: pointer; color: var(--text-muted); }
.diagnosis ul { padding-left: 18px; margin: 6px 0; }

.chat-form { display: flex; gap: 8px; align-items: stretch; }
.chat-form textarea, .chat-form input { flex: 1; min-width: 0; }
.search-results { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 14px; }
.search-results li { display: flex; flex-direction: column; gap: 4px; }

/* --- Hinweise ----------------------------------------------------------------- */

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-small); font-size: 14px; border: 1px solid transparent;
}
.notice .icon { margin-top: 1px; }
.notice-info { background: var(--info-soft); color: var(--info); }
.notice-success { background: var(--success-soft); color: var(--success); }
.notice-warning { background: var(--warning-soft); color: var(--warning); border-color: #f3dfa9; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice a { color: inherit; font-weight: 600; }

/* --- Formulare und Knöpfe ------------------------------------------------------ */

.form { display: flex; flex-direction: column; gap: 16px; }
.form-message:empty { display: none; }
.form-actions { display: flex; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 550; font-size: 14px; }
.field-hint { font-size: 13px; color: var(--text-muted); }
.field-error { font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-small); padding: 10px 12px;
}
input:hover, textarea:hover { border-color: #a9b5b4; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
textarea { resize: vertical; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 550; font-size: 14px; text-decoration: none; cursor: pointer;
  padding: 10px 16px; border-radius: var(--radius-small);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.button:hover { background: var(--surface-muted); color: var(--text); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.danger:hover { background: #911c13; color: #fff; }
.button.ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.button.ghost:hover { background: var(--surface-muted); color: var(--text); }
.button.small { padding: 7px 10px; font-size: 13px; }
.button:disabled { opacity: 0.6; cursor: progress; }
.button[data-busy]::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}

/* --- Verbrauch ------------------------------------------------------------------ */

.meter { display: flex; flex-direction: column; gap: 6px; }
.meter-label { display: flex; justify-content: space-between; font-size: 14px; }
.meter-bar { height: 8px; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
.meter-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.meter-bar.warn span { background: var(--warning); }

/* --- Laden ---------------------------------------------------------------------- */

.loading { display: flex; align-items: center; gap: 10px; color: var(--text-muted); padding: 12px 0; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-right-color: var(--accent); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}

/* --- Anmeldeseiten ----------------------------------------------------------------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; box-shadow: 0 12px 32px rgba(16, 24, 24, 0.06);
  display: flex; flex-direction: column; gap: 18px;
}
.auth-card .brand { margin-bottom: 6px; }
.auth-card .form-actions .button { width: 100%; }
.auth-links { font-size: 14px; color: var(--text-muted); text-align: center; }

/* --- Einbinden ------------------------------------------------------------------ */

.domain-chip { display: inline-flex; align-items: center; gap: 4px; cursor: default; color: var(--text); padding-right: 4px; }
.chip-remove {
  font: inherit; font-size: 16px; line-height: 1; width: 22px; height: 22px; border-radius: 999px;
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.chip-remove:hover { background: var(--danger-soft); color: var(--danger); }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { flex: 1; min-width: 0; }

.color-row { display: flex; align-items: center; gap: 10px; }
input[type="color"] { width: 52px; height: 40px; padding: 3px; cursor: pointer; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
fieldset.field { border: 0; margin: 0; padding: 0; }
fieldset.field legend { font-weight: 550; font-size: 14px; margin-bottom: 6px; padding: 0; }
.radio-row { display: flex; flex-wrap: wrap; gap: 16px; }
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.radio input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }

/* Eine angedeutete Website, auf der das echte Widget sitzt (Maße wie in embed.js). */
.preview-stage {
  position: relative; height: 600px; overflow: hidden; margin-top: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--surface-muted);
}
.preview-page { display: flex; flex-direction: column; gap: 12px; padding: 28px 24px; }
.preview-line { display: block; height: 12px; width: 60%; border-radius: 6px; background: var(--border); }
.preview-line.wide { width: 80%; height: 20px; }
.preview-line.short { width: 40%; }
.preview-frame {
  position: absolute; bottom: 12px; right: 12px; width: 76px; height: 76px;
  border: 0; background: transparent; color-scheme: normal;
}
.preview-frame[hidden] { display: none; }
.preview-frame.left { right: auto; left: 12px; }
.preview-frame.open { width: min(400px, calc(100% - 24px)); height: calc(100% - 24px); }

.code-block {
  margin: 12px 0; padding: 14px 16px; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px;
  background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-small);
}
