/* ===========================================================================
   Steuersoft KI-Assistent — Oberflaeche
   Design-Tokens, Hell/Dunkel, keine externen Schriften (CSP: default-src self)
   =========================================================================== */

:root {
  /* Marke */
  --brand: #0b2545;
  --brand-600: #14396b;
  --accent: #f2b807;
  --accent-ink: #3d2c00;

  /* Flaechen (hell) */
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #eceff5;
  --border: #dde3ec;
  --border-strong: #c7d0de;

  /* Text */
  --text: #16202e;
  --text-muted: #5d6b7f;
  --text-faint: #8695a8;

  /* Signale */
  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --warn: #a16207;
  --warn-bg: #fdf6e3;
  --err: #b42318;
  --err-bg: #fdeceb;
  --info-bg: #e8effa;

  /* Form */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --ring: 0 0 0 3px rgba(20, 57, 107, .18);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --topbar-h: 58px;
  --panel-w: 258px;
  --aside-w: 340px;
}

/* Dunkelmodus: automatisch, per Schalter uebersteuerbar */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1420;
    --surface: #151d2b;
    --surface-2: #1b2434;
    --surface-3: #222d40;
    --border: #27334a;
    --border-strong: #35435e;
    --text: #e8edf6;
    --text-muted: #9dabc2;
    --text-faint: #7787a0;
    --brand: #101a2b;
    --brand-600: #1d2c47;
    --ok-bg: #10281a;
    --warn-bg: #2a2110;
    --err-bg: #2c1512;
    --info-bg: #16233a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --ring: 0 0 0 3px rgba(120, 160, 230, .28);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1420;
  --surface: #151d2b;
  --surface-2: #1b2434;
  --surface-3: #222d40;
  --border: #27334a;
  --border-strong: #35435e;
  --text: #e8edf6;
  --text-muted: #9dabc2;
  --text-faint: #7787a0;
  --brand: #101a2b;
  --brand-600: #1d2c47;
  --ok-bg: #10281a;
  --warn-bg: #2a2110;
  --err-bg: #2c1512;
  --info-bg: #16233a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --ring: 0 0 0 3px rgba(120, 160, 230, .28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

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

.hidden { display: none !important; }

/* Icons: einheitliche Strichzeichnung */
svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.ico { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- Grundgeruest */
.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #d99a05);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 19px; height: 19px; stroke-width: 2.1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: .95rem; font-weight: 650; letter-spacing: .01em; }
.brand-text small { font-size: .72rem; color: rgba(255, 255, 255, .68); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.pill {
  font-size: .76rem;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .13);
  color: #fff;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill:empty { display: none; }
.pill-quiet { background: transparent; color: rgba(255, 255, 255, .72); padding-right: 4px; }

.user-field {
  width: 116px;
  font: inherit;
  font-size: .82rem;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .1);
  color: #fff;
}
.user-field::placeholder { color: rgba(255, 255, 255, .5); }
.user-field:focus { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, .16); }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--aside-w);
  gap: 14px;
  padding: 14px;
}

/* ------------------------------------------------------------------- Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-title {
  font-size: .72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-faint);
}
.hint { font-size: .78rem; color: var(--text-muted); }
.list { display: flex; flex-direction: column; gap: 6px; }

/* ------------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font: inherit;
  font-size: .86rem;
  font-weight: 550;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand); }
:root[data-theme="dark"] .btn-primary,
:root:not([data-theme="light"]) .btn-primary { border-color: var(--border-strong); }

.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.08); background: var(--ok); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--err); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: .8rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(127, 145, 175, .16); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.topbar .icon-btn { color: rgba(255, 255, 255, .85); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }

/* -------------------------------------------------------------------- Suche */
.search-wrap { position: relative; display: flex; align-items: center; }
.search-ico { position: absolute; left: 10px; color: var(--text-faint); }
.search-wrap input {
  width: 100%;
  font: inherit;
  font-size: .84rem;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
}
.search-wrap input:focus { outline: none; border-color: var(--border-strong); box-shadow: var(--ring); }

/* -------------------------------------------------------------- Gespraechsliste */
.conversation {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: .83rem;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation:hover { background: var(--surface-2); }
.conversation:focus-visible { outline: none; box-shadow: var(--ring); }
.conversation.active {
  background: var(--info-bg);
  border-color: var(--border-strong);
  font-weight: 550;
}

/* --------------------------------------------------------------------- Chat */
.chat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px clamp(14px, 4vw, 38px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 10px; max-width: 100%; }
.msg .avatar {
  width: 28px; height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: .7rem;
  font-weight: 650;
}
.msg.bot .avatar { background: var(--brand-600); color: #fff; }
.msg.user .avatar { background: var(--surface-3); color: var(--text-muted); }
.msg.error .avatar { background: var(--err); color: #fff; }

.msg .bubble {
  min-width: 0;
  border-radius: var(--radius);
  padding: 11px 15px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }

.msg.user { flex-direction: row-reverse; }
.msg.user .bubble {
  background: var(--brand-600);
  border-color: transparent;
  color: #fff;
}
.msg.error .bubble { background: var(--err-bg); border-color: var(--err); color: var(--err); }

/* Zwischenstand ("… nutzt Werkzeug X") */
.msg.status .bubble {
  color: var(--text-muted);
  background: transparent;
  border-style: dashed;
  display: flex;
  align-items: center;
  gap: 9px;
}
.msg.status .body { font-size: .88rem; }
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .dots i { animation: none; opacity: .6; }
  .messages { scroll-behavior: auto; }
}

.msg .meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
}
.msg .sources {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-strong);
  font-size: .76rem;
  color: var(--text-muted);
}
.speak {
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  padding: 2px;
  border-radius: 6px;
  line-height: 1;
}
.speak:hover { color: var(--text); background: var(--surface-3); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.chip svg { width: 12px; height: 12px; }
.chip.err { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.chip.file { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

/* Leerer Chat */
.empty {
  margin: auto;
  text-align: center;
  max-width: 460px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty .empty-mark {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--info-bg);
  color: var(--brand-600);
  display: grid;
  place-items: center;
}
.empty h3 { font-size: 1rem; color: var(--text); font-weight: 600; }
.empty p { font-size: .86rem; }
.empty .examples { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 4px; }

/* ----------------------------------------------------------------- Composer */
.attachments { padding: 0 clamp(14px, 4vw, 38px) 4px; display: flex; flex-wrap: wrap; gap: 6px; }

.composer { padding: 12px clamp(14px, 4vw, 38px) 14px; border-top: 1px solid var(--border); }
.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 8px 8px 8px 14px;
  transition: box-shadow .15s, border-color .15s;
}
.composer-inner:focus-within { border-color: var(--brand-600); box-shadow: var(--ring); }
.composer-inner textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font: inherit;
  color: var(--text);
  max-height: 180px;
  padding: 5px 0;
}
.composer-inner textarea:focus { outline: none; }
.composer-tools { display: flex; align-items: center; gap: 4px; }
.btn-send { padding: 8px 14px; }
#mic-btn.recording { background: var(--err); color: #fff; }
.composer-hint { margin-top: 7px; font-size: .72rem; color: var(--text-faint); text-align: center; }

/* ---------------------------------------------------------------- Freigaben */
.approval {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.approval .desc { font-size: .86rem; font-weight: 600; }
.approval .meta { font-size: .73rem; color: var(--text-faint); }
.approval .flag {
  align-self: flex-start;
  font-size: .68rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--warn-bg);
  color: var(--warn);
}
.approval .fields { display: flex; flex-direction: column; gap: 7px; }
.approval .fields label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
}
.approval .fields input,
.approval .fields textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font: inherit;
  font-size: .83rem;
  text-transform: none;
  letter-spacing: normal;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.approval .fields input:focus,
.approval .fields textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--ring); }
.approval .buttons { display: flex; gap: 6px; flex-wrap: wrap; }

/* --------------------------------------------------------- Benachrichtigungen */
.notification {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 9px 11px;
}
.notification.read { border-left-color: var(--border-strong); opacity: .68; }
.notification .desc { font-size: .82rem; font-weight: 600; }
.notification .meta { font-size: .75rem; color: var(--text-muted); white-space: pre-wrap; }

/* --------------------------------------------------------------- Anmeldeseite */
body.login-page { display: grid; place-items: center; padding: 20px; }
.login-box {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 30px 28px;
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.login-brand .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.login-brand strong { display: block; font-size: 1rem; }
.login-brand small { color: var(--text-muted); font-size: .78rem; }
.login-box h1 { font-size: 1.1rem; margin-bottom: 8px; }
.login-box p { font-size: .87rem; color: var(--text-muted); margin-bottom: 18px; }
.login-box form { display: flex; flex-direction: column; gap: 8px; }
.login-box label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
}
.login-box input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
}
.login-box input:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--ring); }
.login-box .btn { margin-top: 4px; padding: 11px; }
#login-status { margin-top: 14px; font-size: .82rem; }
#login-status.ok { color: var(--ok); }
#login-status.err { color: var(--err); }
.login-foot { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); font-size: .74rem; color: var(--text-faint); }

/* ------------------------------------------------------------------ Responsiv */
.only-mobile { display: none; }

@media (max-width: 1180px) {
  :root { --aside-w: 300px; --panel-w: 224px; }
}

@media (max-width: 980px) {
  .only-mobile { display: grid; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  /* Seitenspalten werden zu Overlays */
  #left-panel, #side-panel {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    width: min(86vw, 340px);
    z-index: 30;
    border-radius: 0;
    box-shadow: var(--shadow);
    transform: translateX(-102%);
    transition: transform .22s ease;
  }
  #left-panel { left: 0; }
  #side-panel { right: 0; transform: translateX(102%); }
  #left-panel.open, #side-panel.open { transform: translateX(0); }
  .user-field { display: none; }
  .brand-text small { display: none; }
  .composer-hint { display: none; }
}

@media (max-width: 560px) {
  .messages { padding: 16px 12px; }
  .composer { padding: 10px 12px 12px; }
  .btn-send span { display: none; }
  .btn-send { padding: 9px 11px; }
}
