/* ==========================================================================
   DIE FENSTEREI — ui.css
   Overlay-Bausteine: Live-Chat und Cookie-Einwilligung.
   Bewusst getrennt von main.css, weil beides fixiert über der Seite liegt und
   unabhängig vom Seitenlayout ist. Nutzt dieselben Design-Tokens (:root aus
   main.css), damit nichts wie ein Fremdkörper wirkt.
   ========================================================================== */

/* --------------------------------------------------------------------------
   WICHTIG: Das HTML-Attribut "hidden" blendet nur deshalb aus, weil der
   Browser [hidden]{display:none} mitbringt. Jede eigene Regel wie
   .chat-panel{display:flex} ist staerker und hebt das wieder auf — das
   Element bleibt dann im Layout stehen. Unsichtbar (opacity:0), aber
   anklickbar: es lag ueber dem Startknopf und hat alle Klicks geschluckt.
   Diese Zeile stellt sicher, dass "hidden" immer gewinnt.
   -------------------------------------------------------------------------- */
[hidden]{display:none!important}

/* Nur für Screenreader — sichtbare Beschriftung wäre hier überflüssig. */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip:rect(0 0 0 0);white-space:nowrap;border:0}


/* ==========================================================================
   LIVE-CHAT
   ========================================================================== */

/* ---------- Launcher: rundes Symbol unten rechts -------------------------- */
.chat-launcher{position:fixed;right:22px;bottom:22px;z-index:1000;width:60px;height:60px;border-radius:50%;
  display:grid;place-items:center;background:var(--accent);color:var(--accent-ink);
  box-shadow:0 16px 40px -12px var(--accent-glow),0 8px 20px -8px rgba(0,0,0,.55);
  transition:transform .3s var(--ease),box-shadow .3s var(--ease)}
.chat-launcher:hover{transform:scale(1.07)}
.chat-launcher:active{transform:scale(.96)}
/* Zwei Symbole übereinander: Chat <-> Schließen, weich überblendet. */
.chat-launcher__icon{grid-area:1/1;display:grid;place-items:center;
  transition:opacity .25s var(--ease),transform .3s var(--ease)}
.chat-launcher__icon svg{width:27px;height:27px}
.chat-launcher__icon--close{opacity:0;transform:rotate(-45deg) scale(.5)}
.chat-launcher.is-active .chat-launcher__icon--chat{opacity:0;transform:rotate(45deg) scale(.5)}
.chat-launcher.is-active .chat-launcher__icon--close{opacity:1;transform:none}
/* Zähler ungelesener Nachrichten. */
.chat-launcher__badge{position:absolute;top:-3px;right:-3px;min-width:22px;height:22px;padding:0 6px;
  border-radius:999px;background:#ff4d4d;color:#fff;font:700 12px/22px var(--font-text);text-align:center;
  border:2px solid var(--bg);box-shadow:0 3px 10px rgba(0,0,0,.45)}

/* ---------- Teaser: kleine Begrüßungsblase über dem Launcher -------------- */
.chat-teaser{position:fixed;right:26px;bottom:96px;z-index:999;width:min(250px,calc(100vw - 52px));
  display:flex;align-items:flex-start;gap:8px;padding:13px 15px;background:var(--surface);
  border:1px solid var(--line-2);border-radius:16px 16px 4px 16px;box-shadow:var(--shadow-lg);
  color:var(--text);font-size:13.5px;line-height:1.5;text-align:left;cursor:pointer;
  opacity:0;transform:translateY(12px) scale(.94);transform-origin:bottom right;
  transition:opacity .35s var(--ease),transform .35s var(--ease)}
.chat-teaser.is-visible{opacity:1;transform:none}
.chat-teaser__close{flex:none;width:20px;height:20px;margin:-4px -4px 0 0;border-radius:50%;
  color:var(--text-3);font-size:17px;line-height:1;display:grid;place-items:center}
.chat-teaser__close:hover{background:var(--surface-3);color:var(--text)}
@keyframes chatPulse{0%,100%{transform:scale(1)}50%{transform:scale(1.3)}}
@media (max-width:560px){
  .chat-launcher{right:16px;bottom:16px}
  .chat-teaser{right:16px;bottom:88px}
}

/* ---------- Fenster ------------------------------------------------------- */
.chat-panel{position:fixed;right:22px;bottom:22px;z-index:1001;width:min(388px,calc(100vw - 32px));
  height:min(620px,calc(100dvh - 44px));display:flex;flex-direction:column;
  background:var(--surface);border:1px solid var(--line-2);border-radius:var(--r-lg);
  box-shadow:var(--shadow-lg);overflow:hidden;
  opacity:0;transform:translateY(20px) scale(.96);transform-origin:bottom right;
  transition:opacity .26s var(--ease),transform .26s var(--ease)}
.chat-panel.is-open{opacity:1;transform:none}
@media (max-width:560px){
  .chat-panel{right:0;bottom:0;left:0;top:0;width:100%;height:100dvh;max-height:none;border-radius:0;border:0}
}

/* Kopfzeile mit Avatar, Name und Erreichbarkeits-Punkt. */
.chat-panel__head{display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:15px 16px;background:linear-gradient(180deg,var(--surface-2),var(--surface));
  border-bottom:1px solid var(--line)}
.chat-panel__id{display:flex;align-items:center;gap:12px;min-width:0}
.chat-panel__avatar{position:relative;display:grid;place-items:center;width:42px;height:42px;
  border-radius:50%;background:var(--bg);flex:none;overflow:hidden;border:1px solid var(--line)}
.chat-panel__avatar svg{width:20px;height:20px;color:var(--accent)}
.chat-panel__avatar img{width:100%;height:100%;object-fit:cover}
.chat-panel__title{font:600 15.5px/1.2 var(--font-display);color:var(--text)}
.chat-panel__status{display:flex;align-items:center;gap:6px;font-size:12.5px;color:var(--text-3);margin-top:3px}
.chat-panel__dot{width:8px;height:8px;border-radius:50%;background:var(--text-3);flex:none;transition:background .3s}
.chat-panel__dot.is-online{background:#3ddc84;box-shadow:0 0 8px #3ddc84;animation:chatPulse 2s ease-in-out infinite}
.chat-panel__close{display:grid;place-items:center;width:34px;height:34px;border-radius:50%;
  color:var(--text-2);flex:none;transition:background .2s,color .2s}
.chat-panel__close:hover{background:var(--surface-3);color:var(--text)}
.chat-panel__close svg{width:19px;height:19px}

/* ---------- Gesprächsverlauf ---------------------------------------------- */
.chat-log{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;
  padding:16px 14px 8px;display:flex;flex-direction:column;gap:2px;scrollbar-width:thin;
  scrollbar-color:var(--line-2) transparent}
.chat-log::-webkit-scrollbar{width:8px}
.chat-log::-webkit-scrollbar-thumb{background:var(--line-2);border-radius:8px;border:2px solid var(--surface)}

/* Eine Nachricht = Avatar (bei eingehenden) + Blase. */
.chat-msg{display:flex;gap:8px;align-items:flex-end;margin-top:12px;max-width:100%}
.chat-msg--you{flex-direction:row-reverse}
.chat-msg__avatar{width:26px;height:26px;border-radius:50%;flex:none;overflow:hidden;
  background:var(--bg);border:1px solid var(--line);display:grid;place-items:center}
.chat-msg__avatar svg{width:14px;height:14px;color:var(--accent)}
.chat-msg__avatar img{width:100%;height:100%;object-fit:cover}
.chat-msg__col{display:flex;flex-direction:column;min-width:0;max-width:80%}
.chat-msg--you .chat-msg__col{align-items:flex-end}
.chat-msg__bubble{padding:10px 14px;border-radius:16px;font-size:14.5px;line-height:1.55;
  white-space:pre-wrap;overflow-wrap:anywhere;animation:msgIn .3s var(--ease)}
.chat-msg--in .chat-msg__bubble{background:var(--surface-2);border:1px solid var(--line);color:var(--text);
  border-bottom-left-radius:5px}
.chat-msg--agent .chat-msg__bubble{background:rgba(94,200,191,.13);border-color:rgba(94,200,191,.42)}
.chat-msg--you .chat-msg__bubble{background:var(--accent);color:var(--accent-ink);font-weight:500;
  border-bottom-right-radius:5px}
.chat-msg__time{font-size:10.5px;color:var(--text-3);margin-top:4px;padding:0 5px}
/* Zusammengehörige Nachrichten desselben Absenders rücken enger, Avatar nur
   bei der ersten. */
.chat-msg.is-grouped{margin-top:3px}
.chat-msg.is-grouped .chat-msg__avatar{visibility:hidden}
@keyframes msgIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}

/* Tipp-Anzeige (drei Punkte). */
.chat-typing .chat-msg__bubble{padding:12px 15px}
.chat-dots{display:inline-flex;gap:5px}
.chat-dots i{width:7px;height:7px;border-radius:50%;background:var(--text-3);
  animation:chatDot 1.3s ease-in-out infinite}
.chat-dots i:nth-child(2){animation-delay:.18s}
.chat-dots i:nth-child(3){animation-delay:.36s}
@keyframes chatDot{0%,60%,100%{opacity:.28;transform:translateY(0)}30%{opacity:1;transform:translateY(-4px)}}

/* ---------- Schnellantworten (Chips) ------------------------------------- */
.chat-quick{display:flex;flex-wrap:wrap;gap:8px;padding:4px 16px 12px;animation:msgIn .3s var(--ease)}
.chat-quick__chip{border:1px solid var(--line-3);color:var(--text);background:var(--surface-2);
  border-radius:999px;padding:8px 14px;font-size:13px;line-height:1;transition:all .18s var(--ease)}
.chat-quick__chip:hover{border-color:var(--accent);color:var(--accent-2);transform:translateY(-1px)}
.chat-quick__chip--human{border-color:var(--accent);color:var(--accent-2)}
.chat-quick__chip--human:hover{background:var(--accent);color:var(--accent-ink)}

/* ---------- Übergabe-Karte (Name + E-Mail) im Verlauf -------------------- */
.chat-card{background:var(--surface-2);border:1px solid var(--line-2);border-radius:16px;
  border-bottom-left-radius:5px;padding:14px;margin-top:8px;animation:msgIn .3s var(--ease)}
.chat-card__title{font:600 14px/1.3 var(--font-display);color:var(--text);margin-bottom:3px}
.chat-card__lead{font-size:12.5px;color:var(--text-3);line-height:1.5;margin-bottom:11px}
.chat-card input,.chat-card textarea{width:100%;padding:10px 12px;border-radius:10px;background:var(--bg-2);
  border:1px solid var(--line);color:var(--text);font-size:14px;margin-bottom:8px;resize:none}
.chat-card input:focus,.chat-card textarea:focus{outline:none;border-color:var(--accent)}
.chat-card__actions{display:flex;align-items:center;gap:12px;margin-top:2px}
.chat-card__cancel{font-size:13px;color:var(--text-3);text-decoration:underline}
.chat-card__error{font-size:12.5px;color:#ff8a8a;margin-top:8px}

/* ---------- Eingabezeile -------------------------------------------------- */
.chat-composer{display:flex;align-items:flex-end;gap:10px;padding:12px 14px 10px;
  border-top:1px solid var(--line);background:var(--surface)}
.chat-composer__field{flex:1;display:flex;align-items:flex-end;background:var(--bg-2);
  border:1px solid var(--line);border-radius:22px;padding:2px 4px 2px 16px;transition:border-color .2s}
.chat-composer__field:focus-within{border-color:var(--accent)}
.chat-composer textarea{flex:1;resize:none;max-height:110px;background:transparent;border:0;
  color:var(--text);font-size:14.5px;line-height:1.5;padding:9px 0;outline:none}
.chat-composer textarea::placeholder{color:var(--text-3)}
.chat-composer__send{display:grid;place-items:center;width:40px;height:40px;border-radius:50%;flex:none;
  background:var(--accent);color:var(--accent-ink);transition:transform .18s var(--ease),opacity .18s}
.chat-composer__send:hover:not(:disabled){transform:scale(1.08)}
.chat-composer__send:disabled{opacity:.4}
.chat-composer__send svg{width:19px;height:19px}

/* ---------- Fußzeile: dezenter Datenschutz-Hinweis ----------------------- */
.chat-panel__foot{padding:0 16px 10px;font-size:10.5px;color:var(--text-3);text-align:center}
.chat-panel__foot a{color:var(--text-2);text-decoration:underline}

/* ==========================================================================
   COOKIE- / EINWILLIGUNGSBANNER
   ========================================================================== */
.consent{position:fixed;left:0;right:0;bottom:0;z-index:1200;padding:16px;
  display:flex;justify-content:center;pointer-events:none}
.consent__box{pointer-events:auto;width:min(760px,100%);background:var(--surface);
  border:1px solid var(--line-2);border-radius:var(--r-lg);box-shadow:var(--shadow-lg);
  padding:22px 24px;transform:translateY(14px);opacity:0;
  transition:opacity .3s var(--ease),transform .3s var(--ease)}
.consent.is-visible .consent__box{transform:none;opacity:1}
.consent__title{font:700 17px/1.3 var(--font-display);color:var(--text);margin-bottom:8px}
.consent__text{font-size:13.5px;line-height:1.65;color:var(--text-2)}
.consent__actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:18px;align-items:center}
.consent__actions .btn{flex:1 1 auto;min-width:150px;justify-content:center}
.consent__link{font-size:12.5px;color:var(--text-3);text-decoration:underline;margin-left:auto}
.consent__options{margin-top:16px;display:none;flex-direction:column;gap:12px;
  padding-top:16px;border-top:1px solid var(--line)}
.consent.is-detailed .consent__options{display:flex}
.consent-option{display:flex;gap:12px;align-items:flex-start}
.consent-option input{margin-top:4px;width:17px;height:17px;accent-color:var(--accent);flex:none}
.consent-option input:disabled{opacity:.55}
.consent-option__name{font-weight:600;font-size:14px;color:var(--text)}
.consent-option__desc{font-size:12.5px;color:var(--text-3);line-height:1.55;margin-top:2px}
@media (max-width:560px){
  .consent{padding:0}
  .consent__box{border-radius:var(--r-lg) var(--r-lg) 0 0;padding:20px 18px}
  .consent__actions .btn{flex:1 1 100%}
  .consent__link{margin:4px auto 0}
}

/* Link in der Fußzeile, um die Auswahl später zu ändern. */
.consent-reopen{background:none;border:0;color:inherit;text-decoration:underline;
  cursor:pointer;font:inherit;padding:0}

/* Solange das Banner steht, ist der Chat-Knopf ausgeblendet. Auf schmalen
   Bildschirmen nimmt das Banner die ganze Breite ein und läge sonst genau
   über dem Knopf — der Besucher würde ins Leere klicken. Erst entscheiden,
   dann chatten. (Das Banner steht im HTML vor dem Knopf, daher „~“.) */
.consent:not([hidden]) ~ .chat-launcher{display:none}

/* --------------------------------------------------------------------------
   Reduzierte Bewegung — MUSS am Dateiende stehen!
   Chatfenster und Banner starten auf opacity:0 und werden per Klasse
   eingeblendet. Ohne laufenden Übergang bliebe der Startwert stehen und beide
   wären unsichtbar. Diese Regel hat dieselbe Spezifität wie .chat-panel oben,
   gewinnt also nur, weil sie später kommt — beim Umsortieren aufpassen.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce){
  .chat-panel,.consent__box{transition:none}
}

/* ==========================================================================
   MITARBEITER-KONSOLE  (?page=agent)
   ========================================================================== */
.agent{padding-block:clamp(90px,12vw,140px)}
.agent__login{max-width:400px;margin:0 auto;display:flex;flex-direction:column;gap:14px}
.agent__grid{display:grid;grid-template-columns:minmax(240px,320px) 1fr;gap:20px;align-items:start}
@media (max-width:860px){.agent__grid{grid-template-columns:1fr}}
.agent__list{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);
  overflow:hidden;max-height:70vh;overflow-y:auto}
.agent__item{display:block;width:100%;text-align:left;padding:13px 15px;
  border-bottom:1px solid var(--line);transition:background .2s}
.agent__item:hover,.agent__item.is-active{background:var(--surface-2)}
.agent__item-top{display:flex;align-items:center;gap:8px;justify-content:space-between}
.agent__who{font-weight:600;font-size:14px;color:var(--text)}
.agent__badge{font-size:10.5px;letter-spacing:.06em;text-transform:uppercase;
  padding:3px 8px;border-radius:999px;flex:none}
.agent__badge--waiting{background:var(--accent);color:var(--accent-ink)}
.agent__badge--human{background:rgba(94,200,191,.2);color:var(--teal)}
.agent__badge--ai{background:var(--surface-3);color:var(--text-3)}
.agent__preview{font-size:12.5px;color:var(--text-3);margin-top:4px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.agent__thread{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);
  display:flex;flex-direction:column;min-height:420px;max-height:70vh}
.agent__log{flex:1;overflow-y:auto;padding:18px;display:flex;flex-direction:column;gap:14px}
.agent__empty{margin:auto;color:var(--text-3);font-size:14px}
.agent__composer{display:flex;gap:10px;padding:12px;border-top:1px solid var(--line)}
.agent__composer textarea{flex:1;resize:none;background:var(--bg-2);border:1px solid var(--line);
  border-radius:var(--r-sm);color:var(--text);padding:10px 12px;font-size:14.5px;min-height:46px}
.agent__composer textarea:focus{outline:none;border-color:var(--accent)}
.agent__bar{display:flex;flex-wrap:wrap;align-items:center;gap:14px;margin-bottom:18px}
.agent__pill{display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--text-2);
  background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:7px 14px}
.agent__pill::before{content:"";width:8px;height:8px;border-radius:50%;background:var(--teal);
  box-shadow:0 0 10px var(--teal)}
