/* KI-Assistent – Panel, Nachrichten, Aktionskarten, Eintrag der Seitenleiste, „Assistent fragen“ (CHAT).
   Geladen in base.html und telephony/shell.html.
   Klassen dieses Stylesheets (nur diese, Regel 11): .asst-panel*, .asst-msg*, .asst-card*, .asst-nav*, .asst-ask*, .asst-ctx*,
   .asst-hist*, .asst-start* und der Zustand .is-assistant-open am body des Gastgebers.
   Maße wie Close (E003): Panel rechts, 490 px breit, volle Höhe, weiße Fläche, 1 px Linie links; der Inhalt
   daneben wird schmaler (App-Rahmen: .shell-frame; ohne Rahmen: .app). Antworttext trägt die vorhandene Klasse .prose.
   Farben nur aus den Tokens in app.css – das Zeichen des Assistenten ist grau/blau wie jedes Icon, kein Lila (Regel A.6).

   Ebene: unter dem Telefon-Panel (z-index 1000) und der Anklopf-Karte (1001) – ein klingelnder Anruf liegt immer obenauf;
   das Telefon-Panel des Rahmens richtet sich nach dem Telefon-Knopf der (schmaleren) Seite: wp_assistant.js löst nach dem
   Öffnen/Schließen „resize“ aus, wp_telephony.js setzt es dann neu (Shell.place).

   Breite: Die Seite daneben behält immer mindestens 1100 px – darunter klappt app.js die Seitenleiste von selbst auf Symbole
   zusammen (NAV_AUTO_BELOW), sie spränge bei jedem Öffnen und Schließen (Prüfung 14.10.2026). Ab 1590 px Fensterbreite ist
   das Panel 490 px breit wie in Close, darunter wird es bis 320 px schmaler (1440 px → 340 px); unter 1420 px legt es sich
   mit 490 px über den Inhalt, statt die Seite in die schmale Form zu drücken. Ab 1420 px also min(490px, 100vw - 1100px).
   Keine eigene Variable für diese Breite: auf :root (oder am body) erbte sie jedes Bauteil jeder Seite, auch die der anderen
   Pakete (Regel 11, test_paketstile_regieren_nicht_ineinander) – sie steht deshalb ausgeschrieben an den vier Stellen unten. */

/* ---------- Rahmen: der Inhalt daneben wird schmaler (ab 1420 px; schmaler legt sich das Panel darüber) ---------- */
@media (min-width: 1420px) {
  .is-assistant-open .shell-frame { width: calc(100% - min(490px, 100vw - 1100px)); }
  .is-assistant-open .app { margin-right: min(490px, 100vw - 1100px); }
  .is-assistant-open .toasts { right: calc(min(490px, 100vw - 1100px) + 24px); }
}

/* ---------- Panel ---------- */
.asst-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 900; display: flex; flex-direction: column; width: 490px;
  max-width: 100%; background: var(--surface); border-left: 1px solid var(--border-default); color: var(--text-default);
  font: 400 14px/20px var(--font-sans);
}
@media (min-width: 1420px) { .asst-panel { width: min(490px, 100vw - 1100px); } }
.asst-panel[hidden] { display: none; }
.asst-panel__head {
  flex: none; display: flex; align-items: center; gap: 8px; height: 54px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border-light);
}
.asst-panel__title { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font: 600 14px/20px var(--font-sans); }
.asst-panel__title .icon { color: var(--blue-50); }
.asst-panel__tools { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.asst-panel__tools .btn-icon .icon { color: var(--icon-default); }
.asst-panel__tools [aria-pressed="true"] { background: var(--bg-pressed); }
.asst-panel__body {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 16px 12px; outline: 0;
}
.asst-panel__loading { margin: auto 0 0; color: var(--text-light); font-size: 13px; }
.asst-panel__compose { flex: none; padding: 0 16px 8px; }
.asst-panel__form { position: relative; margin: 0; }
.asst-panel__input {
  display: block; width: 100%; min-height: 84px; max-height: 200px; box-sizing: border-box; margin: 0; padding: 10px 48px 10px 12px;
  border: 1px solid var(--form-border); border-radius: var(--r-8); background: var(--surface); color: var(--text-default);
  font: 400 14px/20px var(--font-sans); resize: none; overflow-y: auto;
}
.asst-panel__input::placeholder { color: var(--text-light); }
.asst-panel__input:focus { outline: 0; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--border-focus-ring); }
.asst-panel__send {
  position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  padding: 0; border: 0; border-radius: var(--r-6); background: var(--btn-primary); color: #fff; cursor: pointer;
}
.asst-panel__send .icon { color: #fff; }
.asst-panel__send:hover { background: var(--btn-primary-hover); }
.asst-panel__send:disabled { background: var(--blue-20); cursor: default; }
.asst-panel__send:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.asst-panel__stop { display: none; }
.asst-panel__send.is-busy .asst-panel__go { display: none; }
.asst-panel__send.is-busy .asst-panel__stop { display: inline-block; }
.asst-panel__hint { margin: 0 0 6px; color: var(--text-danger); font-size: 13px; line-height: 18px; }
.asst-panel__foot { margin: 6px 0 0; color: var(--text-light); font-size: 12px; line-height: 16px; text-align: center; }

/* ---------- Anfang: Begrüßung und Vorschläge (unten im Panel wie Close E003) ---------- */
.asst-start { margin-top: auto; padding: 8px 0 4px; }
.asst-start__hello { margin: 0; font: 700 24px/32px var(--font-sans); text-align: center; color: var(--text-default); }
.asst-start__sub { margin: 2px 0 20px; font-size: 16px; line-height: 24px; text-align: center; color: var(--text-medium); }
.asst-start__list { margin: 0; padding: 0; list-style: none; }
.asst-start__item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-6); background: none;
  color: var(--text-medium); font: 400 13px/18px var(--font-sans); text-align: left; cursor: pointer;
}
.asst-start__item .icon { flex: none; color: var(--icon-light); }
.asst-start__item:hover { background: var(--bg-hover); color: var(--text-default); }
.asst-start__item:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.asst-start__item--briefing { margin-top: 4px; color: var(--link); }
.asst-start__item--briefing .icon { color: var(--blue-50); }

/* ---------- Nachrichten ---------- */
.asst-msgs { display: flex; flex-direction: column; gap: 16px; margin-top: auto; }
.asst-msg { margin: 0; }
.asst-msg--question { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.asst-msg__bubble {
  max-width: 85%; margin: 0; padding: 8px 12px; border-radius: 12px; background: var(--gray-5); color: var(--text-default);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.asst-msg__ctx { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 85%; margin: 0; padding: 0; list-style: none; }
.asst-msg__note { margin: 6px 0 0; color: var(--text-light); font-size: 13px; line-height: 18px; }
.asst-msg__note--error { max-width: 85%; color: var(--text-danger); text-align: right; }
.asst-msg__text { color: var(--text-default); }
.asst-msg__text:empty { display: none; }
.asst-msg__text h3, .asst-msg__text h4 { margin: 12px 0 4px; }
.asst-msg__text h3:first-child, .asst-msg__text h4:first-child { margin-top: 0; }
.asst-msg__text ul, .asst-msg__text ol { margin: 4px 0 8px; }
.asst-msg__text table { margin: 6px 0; font-size: 13px; }
.asst-msg__text th { background: var(--table-header); font-weight: 600; text-align: left; }
.asst-msg.is-streaming .asst-msg__text { white-space: pre-wrap; }
.asst-msg__status { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; color: var(--text-light); font-size: 13px; line-height: 18px; }
.asst-msg__status[hidden] { display: none; }
.asst-msg.has-text:not(.is-working) .asst-msg__status { display: none; }
.asst-msg.has-text.is-working .asst-msg__status { margin: 6px 0 0; }
.asst-msg__dots { display: inline-flex; gap: 3px; }
.asst-msg__dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--gray-40); animation: asst-dots 1.2s infinite ease-in-out; }
.asst-msg__dots i:nth-child(2) { animation-delay: .15s; }
.asst-msg__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes asst-dots { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .asst-msg__dots i { animation: none; opacity: .6; } }
.asst-msg__cards { display: flex; flex-direction: column; gap: 8px; }
.asst-msg__cards:not(:empty) { margin-top: 10px; }
.asst-msg__tools { display: flex; gap: 2px; margin-top: 4px; }
.asst-msg__tools[hidden] { display: none; }
.asst-msg__vote .icon { color: var(--icon-light); }
.asst-msg__vote.is-on .icon, .asst-msg__vote[aria-pressed="true"] .icon { color: var(--blue-50); }

/* ---------- Angeheftete Bausteine („Assistent fragen“) ---------- */
.asst-ctx { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.asst-ctx[hidden] { display: none; }
.asst-ctx__chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; padding: 4px 4px 4px 8px; border-radius: var(--r-6);
  background: var(--token-chip); color: var(--text-default);
}
.asst-ctx__chip--sent { padding-right: 8px; }
.asst-ctx__chip.is-pending { opacity: .7; }
.asst-ctx__icon { display: inline-flex; flex: none; }
.asst-ctx__icon[hidden] { display: none; }
.asst-ctx__icon .icon { color: var(--icon-info); }
.asst-ctx__text { display: flex; flex-direction: column; min-width: 0; }
.asst-ctx__label { overflow: hidden; font: 600 13px/18px var(--font-sans); text-overflow: ellipsis; white-space: nowrap; }
.asst-ctx__sub { overflow: hidden; color: var(--text-medium); font-size: 12px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
.asst-ctx__sub:empty { display: none; }
.asst-ctx__remove {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; padding: 0; border: 0;
  border-radius: var(--r-4); background: none; cursor: pointer;
}
.asst-ctx__remove .icon { color: var(--icon-default); }
.asst-ctx__remove:hover { background: var(--token-chip-hover); }

/* ---------- Aktionskarten ---------- */
.asst-card {
  margin: 0; padding: 12px; border: 1px solid var(--border-default); border-radius: var(--r-8); background: var(--surface);
  box-shadow: var(--shadow-1);
}
.asst-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 4px; }
.asst-card__kind { color: var(--text-medium); font: 600 12px/16px var(--font-sans); }
.asst-card__state {
  flex: none; padding: 1px 8px; border-radius: var(--r-pill); background: var(--bg-info-muted); color: var(--text-info);
  font: 600 12px/16px var(--font-sans);
}
.asst-card[data-state="accepted"] .asst-card__state { background: var(--bg-success-muted); color: var(--text-success); }
.asst-card[data-state="dismissed"] .asst-card__state, .asst-card[data-state="expired"] .asst-card__state { background: var(--gray-5); color: var(--text-medium); }
.asst-card[data-state="failed"] .asst-card__state { background: var(--bg-danger-muted); color: var(--text-danger); }
.asst-card__title { margin: 0 0 2px; font: 600 14px/20px var(--font-sans); }
.asst-card__lead { display: inline-block; margin: 0 0 8px; font-size: 13px; line-height: 18px; }
.asst-card__lead[hidden] { display: none; }
.asst-card__lines { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.asst-card__line { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; font-size: 13px; line-height: 18px; }
.asst-card__line dt { color: var(--text-medium); }
.asst-card__line dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.asst-card__line.is-warning dt, .asst-card__line.is-warning dd { color: var(--text-danger); }
.asst-card__result { margin: 8px 0 0; color: var(--text-medium); font-size: 13px; line-height: 18px; }
.asst-card[data-state="failed"] .asst-card__result { color: var(--text-danger); }
.asst-card__result[hidden], .asst-card__actions[hidden] { display: none; }
.asst-card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.asst-card[aria-busy="true"] { opacity: .8; }

/* ---------- Verlauf (Liste der Unterhaltungen) ---------- */
.asst-hist { display: flex; flex-direction: column; gap: 8px; }
.asst-hist__title { margin: 0 0 4px; font: 600 14px/20px var(--font-sans); }
.asst-hist__list { margin: 0; padding: 0; list-style: none; }
.asst-hist__row { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border-light); }
.asst-hist__open {
  display: flex; flex: 1; flex-direction: column; min-width: 0; padding: 8px; border: 0; border-radius: var(--r-6); background: none;
  color: var(--text-default); text-align: left; cursor: pointer;
}
.asst-hist__open:hover { background: var(--bg-hover); }
.asst-hist__name { overflow: hidden; font: 600 14px/20px var(--font-sans); text-overflow: ellipsis; white-space: nowrap; }
.asst-hist__meta { color: var(--text-light); font-size: 12px; line-height: 16px; }
.asst-hist__delete .icon { color: var(--icon-light); }
.asst-hist__delete:hover .icon { color: var(--icon-danger); }
.asst-hist__empty { margin: 0; color: var(--text-light); }
.asst-hist__new { align-self: flex-start; margin-top: 4px; }

/* ---------- Seitenleiste: Eintrag „Assistent“ über „Inbox“ (Close: CHLOE · Chat Ctrl J) ---------- */
.asst-nav { margin-bottom: 14px; }
.asst-nav__item { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; }
.asst-nav__item[aria-expanded="true"] { background: var(--nav-item-active); color: var(--nav-text-active); }
.asst-nav__item[aria-expanded="true"] .icon { color: #fff; }
.asst-nav__kbd { display: inline-flex; gap: 2px; margin-left: auto; }
.asst-nav__kbd kbd { min-width: 16px; height: 16px; padding: 0 3px; background: var(--gray-80); color: var(--gray-20); font-size: 10px; line-height: 16px; }
:root[data-theme="dark"] .asst-nav__kbd kbd { background: var(--nav-item-active); color: var(--nav-text); }   /* dunkle Taste in der dunklen Leiste */
.app.is-nav-collapsed .asst-nav__kbd { display: none; }

/* ---------- „Assistent fragen“ am Verlauf ---------- */
.asst-ask:hover .icon { color: var(--blue-50); }

/* ---------- schmale Fenster: Panel über dem Inhalt ---------- */
@media (max-width: 1383px) {
  .asst-panel { box-shadow: var(--shadow-4); }
}
@media (max-width: 560px) {
  .asst-panel { width: 100%; border-left: 0; }
}
@media print {
  .asst-panel { display: none !important; }
  .is-assistant-open .shell-frame { width: 100%; }
  .is-assistant-open .app { margin-right: 0; }
}
