/* Developed by Enjyn Gruppe — https://enjyn.de */

.bh-knopf {
  position: fixed; right: 20px; bottom: 20px; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  width: 62px; height: 62px; padding: 7px;
  background: var(--ps-purple);
  border: 2px solid var(--ps-border); border-radius: 50%;
  box-shadow: 4px 4px 0 var(--ps-shadow);
  cursor: pointer; transition: transform .16s ease, box-shadow .16s ease;
}
.bh-knopf:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--ps-shadow); }
.bh-knopf:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ps-shadow); }
.bh-knopf svg { width: 100%; height: 100%; }
.bh-knopf[hidden] { display: none; }

.bh-blase {
  position: fixed; right: 94px; bottom: 30px; z-index: 899;
  max-width: min(272px, calc(100vw - 130px));
  display: flex; align-items: flex-start; gap: 8px;
  padding: 11px 12px 11px 14px;
  background: var(--ps-surface-solid); color: var(--ps-text-primary);
  border: 2px solid var(--ps-border); border-radius: 16px;
  box-shadow: 4px 4px 0 var(--ps-shadow);
  font-family: var(--ps-font-body); font-size: 13.5px; line-height: 1.45;
  cursor: pointer;
  opacity: 0; transform: translateY(6px) scale(.96); transform-origin: right bottom;
  transition: opacity .2s ease, transform .2s ease;
}
.bh-blase-an { opacity: 1; transform: translateY(0) scale(1); }
/* Zipfel zum Maskottchen hin, in zwei Lagen für die Kontur */
.bh-blase::after, .bh-blase::before {
  content: ''; position: absolute; right: -11px; bottom: 16px;
  border: 8px solid transparent; border-left-color: var(--ps-surface-solid);
}
.bh-blase::before { right: -16px; border-left-color: var(--ps-border); }
.bh-blase-text { flex: 1; }
.bh-blase-zu {
  flex: none; width: 19px; height: 19px; margin-top: -1px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ps-text-tertiary); background: transparent;
  border: none; border-radius: 6px; cursor: pointer;
}
.bh-blase-zu:hover { color: var(--ps-text-primary); background: var(--ps-border-soft); }
.bh-blase-zu svg { width: 11px; height: 11px; }

.bh-fenster {
  position: fixed; right: 20px; bottom: 20px; z-index: 901;
  display: flex; flex-direction: column;
  width: 380px; max-width: calc(100vw - 32px); height: 540px; max-height: calc(100vh - 40px);
  background: var(--ps-surface-solid);
  border: 2px solid var(--ps-border); border-radius: 18px;
  box-shadow: 6px 6px 0 var(--ps-shadow);
  overflow: hidden;
  font-family: var(--ps-font-body);
}
.bh-fenster[hidden] { display: none; }

.bh-kopf {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; background: var(--ps-bg-alt);
  border-bottom: 2px solid var(--ps-border); flex: none;
}
.bh-kopf-symbol {
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--ps-lime); color: var(--ps-ink);
  border: 2.5px solid var(--ps-border); border-radius: 11px;
}
.bh-kopf-symbol svg { width: 20px; height: 20px; }
.bh-kopf-titel { font-family: var(--ps-font-display); font-size: 15.5px; font-weight: 600; color: var(--ps-text-primary); line-height: 1.2; }
.bh-kopf-unter { font-size: 11.5px; color: var(--ps-text-secondary); }
.bh-schliessen {
  margin-left: auto; width: 30px; height: 30px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--ps-text-primary); background: transparent;
  border: 2px solid transparent; border-radius: 9px; cursor: pointer;
}
.bh-schliessen:hover { border-color: var(--ps-border-soft); background: var(--ps-accent-light); }
.bh-schliessen svg { width: 17px; height: 17px; }

.bh-verlauf {
  flex: 1; min-height: 0; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.bh-start { padding: 10px 2px 4px; }
.bh-start-titel { font-family: var(--ps-font-display); font-size: 16px; font-weight: 600; color: var(--ps-text-primary); margin-bottom: 5px; }
.bh-start-text { font-size: 13px; line-height: 1.55; color: var(--ps-text-secondary); }
.bh-vorschlaege { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.bh-vorschlag {
  font-family: var(--ps-font-body); font-size: 12.5px; color: var(--ps-text-primary);
  padding: 7px 11px; background: var(--ps-bg);
  border: 2px solid var(--ps-border-soft); border-radius: 999px; cursor: pointer;
}
.bh-vorschlag:hover { border-color: var(--ps-accent); background: var(--ps-accent-light); }

/* Platzhalter, solange die seitenbezogenen Fragen noch unterwegs sind. Gleiche Hoehe
   wie die echten Knoepfe, damit beim Austausch nichts springt. */
.bh-warten { pointer-events: none; }
.bh-platzhalter {
  display: block; height: 31px;
  border-color: transparent;
  background: linear-gradient(100deg,
    var(--ps-border-soft) 28%, var(--ps-bg) 46%, var(--ps-border-soft) 64%);
  background-size: 260% 100%;
  animation: bh-schimmer 1.4s ease-in-out infinite;
}
@keyframes bh-schimmer {
  from { background-position: 150% 0; }
  to   { background-position: -50% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bh-platzhalter { animation: none; background: var(--ps-border-soft); }
}

/* Zeichenzaehler unter dem Eingabefeld */
.bh-zaehler {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 0 14px 10px;
  font-size: 11px; line-height: 1.3; color: var(--ps-text-tertiary);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.bh-zaehler .bh-zeichen { flex: none; }
.bh-zaehler .bh-knapp { color: #b4690e; font-weight: 600; }
.bh-zaehler .bh-voll  { color: #c0392b; font-weight: 700; }

.bh-nachricht { max-width: 86%; padding: 10px 13px; font-size: 13.5px; line-height: 1.6; border-radius: 14px; overflow-wrap: anywhere; }
/* Umbrueche erhaelt nur die eigene Nachricht — sie steht als reiner Text im Element.
   Die Antwort wird aus Absaetzen und Listen aufgebaut, dort wuerde pre-wrap zusaetzlich
   jede Einrueckung des Modells als Leerraum zeigen. */
.bh-nachricht.bh-von-mir { white-space: pre-wrap; }
.bh-nachricht.bh-von-mir { align-self: flex-end; background: var(--ps-purple); color: #fff; border-bottom-right-radius: 5px; }
.bh-nachricht.bh-von-bot { align-self: flex-start; background: var(--ps-bg); color: var(--ps-text-primary); border: 2px solid var(--ps-border-soft); border-bottom-left-radius: 5px; }
.bh-nachricht.bh-stoerung { align-self: flex-start; background: rgba(226,61,61,.10); border: 2px solid rgba(226,61,61,.34); color: var(--ps-text-primary); }
.bh-nachricht a { color: inherit; font-weight: 700; text-underline-offset: 3px; }
.bh-nachricht.bh-von-bot a { color: var(--ps-accent); }
[data-theme="dark"] .bh-nachricht.bh-von-bot a { color: #A78BFA; }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) .bh-nachricht.bh-von-bot a { color: #A78BFA; } }
.bh-nachricht strong { font-weight: 800; }
.bh-nachricht code {
  padding: 1px 5px; border-radius: 5px;
  background: var(--ps-chat-flaeche-stark);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
}
.bh-absatz { margin: 0 0 8px; }
.bh-absatz:last-child { margin-bottom: 0; }
.bh-liste { margin: 8px 0; padding-left: 19px; }
.bh-liste:first-child { margin-top: 0; }
.bh-liste:last-child { margin-bottom: 0; }
.bh-liste li { margin: 0; padding-left: 2px; }
.bh-liste li + li { margin-top: 5px; }
.bh-liste li::marker { color: var(--ps-text-tertiary); }

.bh-tippt { align-self: flex-start; display: flex; gap: 4px; padding: 12px 13px; }
.bh-tippt span { width: 7px; height: 7px; background: var(--ps-text-tertiary); border-radius: 50%; animation: bh-huepf 1.1s infinite; }
.bh-tippt span:nth-child(2) { animation-delay: .16s; }
.bh-tippt span:nth-child(3) { animation-delay: .32s; }
@keyframes bh-huepf { 0%,60%,100% { transform: translateY(0); opacity: .45 } 30% { transform: translateY(-4px); opacity: 1 } }
@media (prefers-reduced-motion: reduce) {
  .bh-tippt span { animation: none; }
  .bh-knopf { transition: none; }
}

/* Steht jetzt in der Zählerzeile unter dem Eingabefeld statt als eigener Block über
   dem Verlauf — dort nahm er fünf Zeilen Gesprächsfläche weg. Volltext im title. */
.bh-hinweis {
  flex: 1; min-width: 0;
  font-size: 10px; line-height: 1.3;
  color: var(--ps-text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: help;
}
.bh-eingabe { display: flex; gap: 8px; padding: 11px 12px 12px; border-top: 2px solid var(--ps-border-soft); flex: none; }
.bh-eingabe textarea {
  flex: 1; resize: none; max-height: 96px;
  padding: 10px 12px; font-family: var(--ps-font-body); font-size: 13.5px; line-height: 1.45;
  color: var(--ps-text-primary); background: var(--ps-bg);
  border: 2.5px solid var(--ps-border-soft); border-radius: 12px; outline: none;
}
.bh-eingabe textarea:focus { border-color: var(--ps-accent); }
.bh-eingabe textarea:disabled { opacity: .6; cursor: not-allowed; }
.bh-senden {
  width: 42px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--ps-ink); background: var(--ps-lime);
  border: 2.5px solid var(--ps-border); border-radius: 12px; cursor: pointer;
}
.bh-senden:disabled { opacity: .5; cursor: default; }
.bh-senden svg { width: 18px; height: 18px; }

@media (max-width: 560px) {
  .bh-knopf { right: 14px; bottom: 14px; width: 56px; height: 56px; }
  /* Auf dem Handy ist neben dem Maskottchen kein Platz — Blase darüber setzen. */
  .bh-blase {
    right: 14px; bottom: 80px; max-width: calc(100vw - 28px);
    transform-origin: right bottom;
  }
  .bh-blase::after, .bh-blase::before {
    right: 18px; bottom: -11px;
    border-left-color: transparent; border-top-color: var(--ps-surface-solid);
  }
  .bh-blase::before { right: 18px; bottom: -16px; border-top-color: var(--ps-border); }
  .bh-fenster {
    right: 0; bottom: 0; left: 0;
    width: auto; max-width: none; height: 88dvh; max-height: 88dvh;
    border-radius: 18px 18px 0 0; border-bottom: none; box-shadow: 0 -4px 0 var(--ps-shadow);
  }
}

/* ── Formatierungen der Bot-Antwort ──
   Gegenstueck zum Kit im System-Prompt (wissen.php) und zu antwortAufbauen() in
   berater.js. Fehlt hier etwas, sieht der Besucher rohes Markdown. */
.bh-nachricht em { font-style: italic; }
.bh-nachricht del { opacity: .6; }

.bh-h1, .bh-h2 { line-height: 1.3; margin: 11px 0 5px; color: var(--ps-text-primary); }
.bh-h1 { font-size: 14.5px; font-weight: 800; }
.bh-h2 { font-size: 13.5px; font-weight: 700; }
.bh-nachricht > .bh-h1:first-child, .bh-nachricht > .bh-h2:first-child { margin-top: 0; }

.bh-trenner { border-top: 2px solid var(--ps-border-soft); margin: 10px 0; }

.bh-zitat {
  margin: 8px 0; padding: 7px 11px;
  border-left: 3px solid var(--ps-accent);
  background: var(--ps-chat-flaeche);
  border-radius: 0 10px 10px 0;
  color: var(--ps-text-secondary, var(--ps-text-primary));
}
.bh-zitat:first-child { margin-top: 0; }
.bh-zitat:last-child { margin-bottom: 0; }

/* Waagrecht scrollbar, damit die Blase auf dem Handy nicht breiter wird als das Fenster. */
.bh-tabelle {
  margin: 9px 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 2px solid var(--ps-border-soft); border-radius: 11px;
}
.bh-tabelle table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.bh-tabelle th, .bh-tabelle td {
  padding: 6px 10px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--ps-border-soft);
}
.bh-tabelle th { font-weight: 800; background: var(--ps-chat-flaeche-stark); }
.bh-tabelle tr:last-child td { border-bottom: 0; }

.bh-code {
  margin: 9px 0; border-radius: 11px; overflow: hidden;
  background: var(--ps-chat-flaeche);
  border: 2px solid var(--ps-border-soft);
}
.bh-code-kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 6px 5px 11px;
  background: var(--ps-chat-flaeche-stark);
  border-bottom: 2px solid var(--ps-border-soft);
}
.bh-code-sprache {
  font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ps-text-tertiary);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.bh-code-kopieren {
  flex: none; padding: 3px 9px; font-size: 10px; font-weight: 700;
  font-family: inherit; cursor: pointer;
  color: var(--ps-text-tertiary); background: var(--ps-bg);
  border: 2px solid var(--ps-border-soft); border-radius: 7px;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.bh-code-kopieren:hover { background: var(--ps-purple); color: #fff; border-color: var(--ps-purple); }
.bh-code pre {
  margin: 0; padding: 10px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  color: var(--ps-text-primary); background: transparent;
}

/* Aufgabenliste: Kaestchen zum Ansehen, nicht zum Anklicken. */
.bh-liste li:has(> .bh-haken) { list-style: none; margin-left: -14px; }
.bh-haken {
  display: inline-block; width: 13px; height: 13px; margin-right: 7px;
  vertical-align: -2px; position: relative;
  border: 2px solid var(--ps-text-tertiary); border-radius: 4px;
}
.bh-haken-an { background: var(--ps-purple); border-color: var(--ps-purple); }
.bh-haken-an::after {
  content: ""; position: absolute; left: 3px; top: 0;
  width: 3px; height: 6px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

@media (prefers-reduced-motion: reduce) { .bh-code-kopieren { transition: none; } }

/* Stoerungsmeldung mit Knopf zum erneuten Senden: Die Frage soll niemand zweimal
   tippen muessen, nur weil die Verbindung gehakt hat. */
.bh-nachricht.bh-stoerung { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bh-nochmal {
  flex: none;
  padding: 5px 11px;
  font-size: 11.5px; font-weight: 800;
  font-family: inherit; cursor: pointer;
  color: #fff; background: var(--ps-purple);
  border: 0; border-radius: 9px;
  transition: filter .15s ease;
}
.bh-nochmal:hover { filter: brightness(1.08); }
.bh-nochmal:active { filter: brightness(.95); }

@media (max-width: 420px) {
  .bh-nachricht.bh-stoerung { flex-direction: column; align-items: stretch; }
  .bh-nochmal { width: 100%; padding: 8px 11px; }
}
@media (prefers-reduced-motion: reduce) { .bh-nochmal { transition: none; } }

/* Knopf unter der Antwort, wenn der Bot genau eine passende Seite nennt. */
.bh-seitenknopf-reihe { align-self: flex-start; max-width: 86%; margin-top: -2px; }
.bh-seitenknopf {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  font-size: 13px; font-weight: 800; text-decoration: none;
  color: #fff; background: var(--ps-purple);
  border-radius: 12px;
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--ps-accent) 55%, transparent);
  transition: transform .14s ease, filter .14s ease;
}
.bh-seitenknopf:hover { filter: brightness(1.07); transform: translateY(-1px); }
.bh-seitenknopf:active { transform: translateY(0); filter: brightness(.96); }
.bh-seitenknopf-pfeil { display: flex; width: 15px; height: 15px; }
.bh-seitenknopf-pfeil svg { width: 100%; height: 100%; }
@media (prefers-reduced-motion: reduce) { .bh-seitenknopf { transition: none; } }

/* Gespräch zurücksetzen — steht links neben dem Schließen-Kreuz. */
.bh-zuruecksetzen {
  margin-left: auto; width: 30px; height: 30px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--ps-text-tertiary); background: transparent;
  border: 2px solid transparent; border-radius: 9px; cursor: pointer;
}
.bh-zuruecksetzen:hover {
  color: var(--ps-text-primary);
  border-color: var(--ps-border-soft);
  background: var(--ps-accent-light);
}
.bh-zuruecksetzen svg { width: 16px; height: 16px; }
/* Sonst teilen sich zwei margin-left:auto den Restplatz und die Knöpfe stehen auseinander. */
.bh-zuruecksetzen + .bh-schliessen { margin-left: 2px; }
/* Unter 16 px zoomt iOS-Safari beim Antippen in die Seite. */
@media (max-width: 640px), (hover: none) and (pointer: coarse) { .bh-eingabe textarea { font-size: 16px; } }
/* Auf dem Handy läge das Maskottchen halb hinter der Cookie-Karte. */
@media (max-width: 560px) { body:has(.nytrix-cookie-banner.show) .bh-knopf, body:has(.cookie-banner.show) .bh-knopf { display: none; } }
