/* ============================================================================
   Helfer-Chat "Frag Stellio" (public/js/helper.js)
   Alle Klassen mit Praefix sh-, damit nichts mit Landing/App kollidiert.
   Eigene Werte statt Variablen, weil index.html kein base.css laedt.
   ============================================================================ */

/* ── Schwebender Knopf ──────────────────────────────────────────────────── */
.sh-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 90;
  height: 52px; min-width: 52px; padding: 0 18px 0 14px;
  border: none; border-radius: 100px; background: #2563EB; color: #fff;
  display: flex; align-items: center; gap: 8px;
  font: 700 14px 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: 0;
  box-shadow: 0 8px 24px rgba(37,99,235,0.32); cursor: pointer;
  transition: transform .2s cubic-bezier(0.23,1,0.32,1), background .2s;
  -webkit-tap-highlight-color: transparent;
}
.sh-fab:hover { background: #1D4ED8; transform: translateY(-2px); }
.sh-fab:active { transform: translateY(0) scale(0.97); }
.sh-fab:focus-visible { outline: 3px solid rgba(37,99,235,0.35); outline-offset: 3px; }
.sh-fab-icon { display: inline-flex; }
.sh-fab svg { width: 22px; height: 22px; flex-shrink: 0; }

/* ── Fenster ────────────────────────────────────────────────────────────── */
.sh-panel {
  position: fixed; right: 24px; bottom: 88px; z-index: 320;
  width: 380px; max-height: min(600px, calc(100vh - 120px));
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid #E4E4E7; border-radius: 20px;
  box-shadow: 0 24px 60px rgba(24,24,27,0.18); overflow: hidden;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif; color: #18181B;
  text-align: left; line-height: 1.4;
  opacity: 0; transform: translateY(8px);
  transition: opacity 200ms cubic-bezier(0.23,1,0.32,1), transform 200ms cubic-bezier(0.23,1,0.32,1);
}
.sh-panel[hidden] { display: none; }
.sh-panel.is-open { opacity: 1; transform: translateY(0); }
.sh-panel *, .sh-panel *::before, .sh-panel *::after { box-sizing: border-box; }
.sh-panel button { font-family: inherit; }
.sh-panel :focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; }

/* Kopf */
.sh-head {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid #F0F0F1; flex-shrink: 0;
}
.sh-grip { display: none; }
.sh-logo { width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0; }
.sh-titles { flex: 1; min-width: 0; }
.sh-title { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; color: #18181B; }
.sh-sub { font-size: 12px; color: #71717A; margin-top: 1px; }
.sh-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.sh-icon-btn {
  width: 34px; height: 34px; border: none; background: transparent; color: #52525B;
  border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s;
}
.sh-icon-btn:hover { background: #F4F6FA; color: #18181B; }
.sh-icon-btn svg { width: 18px; height: 18px; }
.sh-lang-row { flex-basis: 100%; display: flex; order: 3; }
.sh-langs { display: flex; gap: 2px; margin-left: 34px; }
.sh-lang {
  font-size: 11.5px; font-weight: 700; color: #71717A; background: transparent;
  border: none; padding: 3px 7px; border-radius: 100px; cursor: pointer; letter-spacing: 0.02em;
}
.sh-lang:hover { color: #18181B; }
.sh-lang.is-active { color: #1D4ED8; background: #EFF6FF; }

/* Chat-Ansicht */
.sh-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sh-chat[hidden] { display: none; }
.sh-log {
  flex: 1; overflow-y: auto; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain; min-height: 120px;
}

/* Blasen */
.sh-msg {
  max-width: 85%; padding: 10px 13px; font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.sh-msg.is-user {
  align-self: flex-end; background: #2563EB; color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.sh-msg.is-bot {
  align-self: flex-start; background: #F4F6FA; color: #18181B;
  border-radius: 16px 16px 16px 4px;
}
.sh-msg.is-new { animation: shIn .22s cubic-bezier(0.23,1,0.32,1) both; }
@keyframes shIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sh-msg.is-transient, .sh-msg.is-notice { background: #FFF7ED; color: #7C2D12; }
.sh-links { white-space: normal; }
/* Link-Knopf in der Antwort: weiss mit blauem Rand, klar als Knopf erkennbar
   (Text #1D4ED8 auf Weiss 6.7:1, Rand #2563EB auf #F4F6FA 4.8:1) */
.sh-link {
  display: inline-flex; align-items: center; margin: 8px 6px 0 0; padding: 7px 13px; border-radius: 100px;
  background: #fff; border: 1.5px solid #2563EB; color: #1D4ED8;
  font-size: 13px; font-weight: 700; line-height: 1.3; text-decoration: none;
  box-shadow: 0 1px 2px rgba(24,24,27,0.06);
  transition: background .15s, color .15s;
}
.sh-link:hover { background: #2563EB; color: #fff; }
.sh-link:active { background: #1D4ED8; border-color: #1D4ED8; color: #fff; }
.sh-msg-actions { margin-top: 8px; white-space: normal; }
.sh-msg-btn {
  display: inline-flex; align-items: center; gap: 6px; text-align: left;
  border: 1px solid #DBEAFE; background: #fff; color: #1D4ED8;
  font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 100px; cursor: pointer;
}
.sh-msg-btn:hover { background: #EFF6FF; }
.sh-msg-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Vorschlags-Fragen: eine waagrechte Zeile, seitwaerts scrollbar, damit die
   Antwort oben genug Platz behaelt. Verlauf am Rand zeigt, dass es weitergeht. */
.sh-chips-wrap { position: relative; flex-shrink: 0; }
.sh-chips-wrap::before, .sh-chips-wrap::after {
  content: ''; position: absolute; top: 0; bottom: 10px; width: 36px; z-index: 1;
  pointer-events: none; opacity: 0; transition: opacity .15s;
}
.sh-chips-wrap::before { left: 0; background: linear-gradient(to right, #fff 20%, rgba(255,255,255,0)); }
.sh-chips-wrap::after { right: 0; background: linear-gradient(to left, #fff 20%, rgba(255,255,255,0)); }
.sh-chips-wrap.has-more-left::before, .sh-chips-wrap.has-more-right::after { opacity: 1; }
.sh-chips {
  display: flex; flex-wrap: nowrap; gap: 6px; padding: 2px 16px 10px;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  scrollbar-width: none; scroll-padding: 0 40px;
}
.sh-chips::-webkit-scrollbar { display: none; }
/* Lange Vorschlaege brechen auf hoechstens ca. 2 Zeilen um; der naechste
   Vorschlag schaut rechts hervor, damit man sieht, dass es weitergeht. */
.sh-chip {
  flex-shrink: 0; max-width: 76%; white-space: normal;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #DBEAFE; background: #fff; color: #1D4ED8;
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.3;
  padding: 7px 12px; border-radius: 100px; cursor: pointer; text-align: left;
  transition: background .15s, border-color .15s;
}
.sh-chip:hover { background: #EFF6FF; }
.sh-chip:disabled { opacity: .5; cursor: default; }
.sh-chip svg { width: 14px; height: 14px; flex-shrink: 0; }
.sh-chip.is-primary { background: #2563EB; color: #fff; border-color: #2563EB; }
.sh-chip.is-primary:hover { background: #1D4ED8; }

/* Eingabe */
.sh-input {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px 12px; border-top: 1px solid #F0F0F1; flex-shrink: 0; margin: 0;
}
.sh-panel .sh-textarea {
  flex: 1; width: auto; min-height: 0; height: 42px; max-height: 96px;
  border: 1px solid #E4E4E7; border-radius: 14px; padding: 10px 12px;
  font-family: inherit; font-size: 14px; line-height: 1.45; color: #18181B;
  background: #fff; resize: none; outline: none; box-shadow: none; margin: 0;
  transition: border-color .15s, box-shadow .15s;
}
.sh-panel .sh-textarea::placeholder { color: #A1A1AA; }
.sh-panel .sh-textarea:focus { border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); background: #fff; }
.sh-send {
  width: 40px; height: 40px; flex-shrink: 0; border: none; border-radius: 50%;
  background: #2563EB; color: #fff; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, transform .15s;
}
.sh-send:hover { background: #1D4ED8; }
.sh-send:active { transform: scale(0.94); }
.sh-send:disabled { opacity: .5; cursor: default; }
.sh-send svg { width: 18px; height: 18px; }
.sh-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.sh-foot { font-size: 11.5px; color: #71717A; padding: 0 16px 10px; line-height: 1.4; flex-shrink: 0; }
/* App: Textlink "Problem melden" in der Fusszeile */
.sh-foot-link {
  display: inline; border: none; background: none; padding: 0; margin: 0;
  font: inherit; font-weight: 700; color: #1D4ED8; text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer;
}
.sh-foot-link:hover { color: #1E40AF; }

/* "Stellio schreibt gerade" – gleiche Werte wie components.css (4) */
.sh-panel .sh-msg.is-typing { padding: 12px 14px; }
.sh-panel .typing-indicator { display: inline-flex; align-items: center; gap: 10px; min-height: 21px; }
.sh-panel .typing-dots { display: inline-flex; align-items: center; gap: 4px; }
.sh-panel .typing-dots i {
  width: 7px; height: 7px; border-radius: 50%; background: #2563EB; opacity: 0.55;
  animation: shTyping 1.3s ease-in-out infinite;
}
.sh-panel .typing-dots i:nth-child(2) { animation-delay: 0.16s; }
.sh-panel .typing-dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes shTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%           { transform: translateY(-3px); opacity: 1; }
}
.sh-panel .typing-label { font-size: 12.5px; color: #71717A; white-space: normal; }

/* ── Uebergabe-Formular ─────────────────────────────────────────────────── */
.sh-form { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 16px; overscroll-behavior: contain; }
.sh-form[hidden] { display: none; }
.sh-back {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 0 8px -6px;
  border: none; background: transparent; color: #1D4ED8; font-size: 13px; font-weight: 700;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
}
.sh-back:hover { background: #EFF6FF; }
.sh-back svg { width: 16px; height: 16px; }
.sh-form-title { font-size: 16px; font-weight: 800; color: #18181B; margin: 0 0 12px; letter-spacing: -0.01em; }
.sh-form-body { position: relative; margin: 0; }
.sh-field { margin-bottom: 12px; }
.sh-label { display: block; font-size: 12.5px; font-weight: 700; color: #3F3F46; margin-bottom: 5px; }
.sh-panel .sh-field-input {
  display: block; width: 100%; min-height: 0; height: auto; margin: 0;
  border: 1px solid #E4E4E7; border-radius: 14px; padding: 10px 12px;
  font-family: inherit; font-size: 14px; line-height: 1.45; color: #18181B;
  background: #fff; outline: none; box-shadow: none; resize: none;
  transition: border-color .15s, box-shadow .15s;
}
.sh-panel .sh-field-input:focus { border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); background: #fff; }
.sh-panel .sh-field-input[aria-invalid="true"] { border-color: #B45309; }
.sh-panel .sh-field-area { min-height: 92px; resize: vertical; }
/* Auswahl "Wo ist es passiert?" mit eigenem Pfeil */
.sh-panel .sh-field-select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 36px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2352525B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px 16px;
}
.sh-hint { font-size: 12.5px; line-height: 1.5; color: #52525B; margin: -2px 0 14px; }
.sh-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #3F3F46; margin: 2px 0 14px; cursor: pointer; }
.sh-panel .sh-check input { width: 16px; height: 16px; margin: 0; accent-color: #2563EB; flex-shrink: 0; }
.sh-btn {
  position: relative; width: 100%; height: 44px; border: none; border-radius: 100px;
  background: #2563EB; color: #fff; font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: background .15s;
}
.sh-btn:hover { background: #1D4ED8; }
.sh-btn-light { background: #EFF6FF; color: #1D4ED8; margin-top: 14px; }
.sh-btn-light:hover { background: #DBEAFE; }
/* Knopf-Spinner – gleiche Optik wie .btn.btn-busy in base.css */
.sh-btn.btn-busy { color: transparent; pointer-events: none; cursor: progress; }
.sh-btn.btn-busy:disabled { opacity: 0.92; }
.sh-btn.btn-busy > * { visibility: hidden; }
.sh-btn.btn-busy::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  animation: shSpin .7s linear infinite;
}
@keyframes shSpin { to { transform: rotate(360deg); } }
.sh-form-error { font-size: 12.5px; color: #B45309; margin-top: 8px; min-height: 1px; }
.sh-done { text-align: center; padding: 28px 8px 8px; }
.sh-done-icon { display: inline-flex; color: #16A34A; margin-bottom: 10px; }
.sh-done-icon svg { width: 40px; height: 40px; }
.sh-done p { font-size: 14.5px; line-height: 1.55; color: #18181B; margin: 0; }

/* ── Handy: runder Knopf, Fenster als Blatt von unten ───────────────────── */
@media (max-width: 640px) {
  .sh-fab-label { display: none; }
  .sh-fab {
    width: 56px; height: 56px; padding: 0; justify-content: center;
    right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .sh-panel {
    left: 0; right: 0; bottom: 0; width: auto; max-height: none;
    height: 88vh; height: 88dvh;
    border-radius: 20px 20px 0 0; border-bottom: none;
    transform: translateY(24px);
  }
  .sh-panel.is-open { transform: translateY(0); }
  .sh-head { padding-top: 20px; }
  .sh-grip {
    display: block; position: absolute; top: 7px; left: 50%; margin-left: -18px;
    width: 36px; height: 4px; border-radius: 4px; background: #E4E4E7;
  }
  .sh-input { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  /* 16px verhindert das automatische Hineinzoomen auf dem iPhone */
  .sh-panel .sh-textarea, .sh-panel .sh-field-input { font-size: 16px; }
  html.sh-locked, html.sh-locked body { overflow: hidden; }
}

/* ── In der App ─────────────────────────────────────────────────────────────
   Knopf unter Modals (100), Tour (200) und Sprachmodus (300); das "+ Bewerbung"
   im Tracker rueckt nach links, damit nichts ueberlappt. */
body.sh-in-app .sh-fab { z-index: 90; }
/* --sh-fab-w = echte Breite des Knopfs (mit Beschriftung, je nach Sprache
   verschieden), setzt helper.js; 96px = Wert fuer den runden Knopf */
body.sh-in-app .tracker-fab { right: 96px; right: calc(44px + var(--sh-fab-w, 52px)); }
@media (max-width: 760px) {
  /* ueber der Bottom-Nav (bottom:10px, z-index:150) */
  body.sh-in-app .sh-fab { bottom: calc(86px + env(safe-area-inset-bottom)); }
  body.sh-in-app .sh-panel { z-index: 320; }
  /* "+ Bewerbung" auf gleicher Hoehe wie der Knopf, nicht hinter der Bottom-Nav */
  body.sh-in-app .tracker-fab { bottom: 84px; }
  /* Ganz nach unten gescrollt liegt der letzte Knopf der Seite (z.B. "Abmelden",
     "Senden") ueber dem Helfer-Knopf: Knopf endet 142px ueber dem Rand + Abstand */
  body.sh-in-app .content { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }
  /* Waehrend in ein Feld der Seite getippt wird, tritt der Knopf zur Seite (helper.js) */
  body.sh-in-app.sh-typing .sh-fab:not(.is-open) {
    opacity: 0; pointer-events: none; transform: translateY(12px);
    transition: opacity .15s, transform .15s;
  }
}
@media (min-width: 641px) and (max-width: 760px) {
  /* Fenster ueber dem hoeher sitzenden Knopf, nicht darauf */
  body.sh-in-app .sh-panel {
    bottom: calc(150px + env(safe-area-inset-bottom));
    max-height: min(600px, calc(100vh - 180px));
  }
}
@media (max-width: 640px) {
  body.sh-in-app .tracker-fab { right: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .sh-fab, .sh-panel, .sh-send, .sh-chip, .sh-link, .sh-icon-btn, .sh-chips-wrap::before, .sh-chips-wrap::after,
  .sh-panel .sh-textarea, .sh-panel .sh-field-input, .sh-foot-link { transition: none; }
  .sh-fab:hover, .sh-fab:active, .sh-send:active { transform: none; }
  .sh-panel, .sh-panel.is-open { transform: none; }
  .sh-msg.is-new, .sh-panel .typing-dots i, .sh-btn.btn-busy::after { animation: none; }
  .sh-panel .typing-dots i { opacity: 0.7; }
  body.sh-in-app.sh-typing .sh-fab:not(.is-open) { transition: none; transform: none; }
}
