/* =========================================================
   Ankauf-Assistent (Chat)
   ========================================================= */

/* Knopf unten rechts (PC und Tablet) */
.chat-start {
  position: fixed; right: 22px; bottom: 22px; z-index: 35;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 0 20px 0 16px;
  background: var(--asphalt); color: var(--weiss);
  border: 2px solid var(--signal); border-radius: 30px;
  font: 700 1rem/1 var(--schrift); cursor: pointer;
  box-shadow: 0 8px 24px rgba(29, 38, 45, .28);
}
.chat-start .ic { color: var(--signal); width: 24px; height: 24px; }
.chat-start:hover { background: var(--asphalt-hell); }
.chat-offen .chat-start { display: none; }

/* Fenster */
.chat {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 390px; height: min(640px, calc(100vh - 44px));
  display: flex; flex-direction: column;
  background: var(--papier); border-radius: 14px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(29, 38, 45, .35);
  opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s;
}
.chat.sichtbar { opacity: 1; transform: none; }
.chat[hidden] { display: none; }

.chat-kopf { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 18px; background: var(--asphalt); color: var(--weiss); }
.chat-bild { width: 42px; height: 42px; border-radius: 50%; background: var(--signal); color: var(--asphalt); display: grid; place-items: center; font: 800 1rem/1 var(--titel); flex: none; }
.chat-kopf p { margin: 0; line-height: 1.25; }
.chat-kopf b { display: block; font-size: 1.05rem; }
.chat-kopf p span { font-size: .85rem; color: #AEB7BD; }
.chat-zu { margin-left: auto; width: 44px; height: 44px; border: 0; background: transparent; color: var(--weiss); font-size: 1.8rem; line-height: 1; cursor: pointer; border-radius: 8px; }
.chat-zu:hover { background: var(--asphalt-hell); }

.chat-verlauf { flex: 1; overflow-y: auto; padding: 18px 14px 8px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.blase { max-width: 86%; padding: 10px 14px; border-radius: 14px; line-height: 1.45; font-size: 1rem; white-space: pre-line; }
.blase-bot { background: var(--weiss); border: 1px solid var(--linie); border-bottom-left-radius: 4px; align-self: flex-start; }
.blase-ich { background: var(--asphalt); color: var(--weiss); border-bottom-right-radius: 4px; align-self: flex-end; }
.tippt { display: flex; gap: 5px; padding: 14px 16px; }
.tippt span { width: 7px; height: 7px; border-radius: 50%; background: var(--stahl); animation: tippen 1s infinite ease-in-out; }
.tippt span:nth-child(2) { animation-delay: .15s; }
.tippt span:nth-child(3) { animation-delay: .3s; }
@keyframes tippen { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.zusammen { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; white-space: normal; }
.zusammen dt { color: var(--stahl); font-size: .9rem; }
.zusammen dd { margin: 0; font-weight: 600; }

.chat-auswahl { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 14px 12px; justify-content: flex-end; }
.chat-auswahl:empty { display: none; }
.wahl-knopf {
  min-height: 42px; padding: 9px 14px; border-radius: 22px;
  border: 2px solid var(--asphalt); background: var(--weiss); color: var(--asphalt);
  font: 600 .95rem/1.2 var(--schrift); cursor: pointer; text-align: left; text-decoration: none;
  display: inline-flex; align-items: center;
}
.wahl-knopf:hover { background: #FFF6D6; }
.wahl-knopf.stark { background: var(--signal); border-color: var(--signal); }
.wahl-knopf.wa { background: var(--wa); border-color: var(--wa); color: var(--weiss); }

.chat-eingabe { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--weiss); border-top: 1px solid var(--linie); }
.chat-eingabe input { flex: 1; min-width: 0; border-radius: 22px; padding: 11px 16px; }
.chat-eingabe button { width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; background: var(--asphalt); color: var(--signal); cursor: pointer; display: grid; place-items: center; }
.chat-eingabe button .ic { width: 20px; height: 20px; transform: rotate(180deg); }
.chat-hinweis { margin: 0; padding: 0 14px 8px; font-size: .78rem; color: var(--stahl); text-align: center; background: var(--weiss); }

/* Handy: Chat füllt den ganzen Bildschirm, Knopf sitzt in der unteren Leiste */
@media (max-width: 720px) {
  .chat-start { display: none; }
  .chat { inset: 0; width: auto; height: auto; border-radius: 0; }
  .chat-kopf { padding-top: calc(14px + env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  .chat { transition: none; }
  .tippt span { animation: none; opacity: .6; }
}

/* Begrüßungs-Blase (Funktion im Admin) */
.gruss-blase {
  position: fixed; right: 22px; bottom: 92px; z-index: 36; max-width: 290px;
  display: flex; align-items: flex-start; gap: 4px;
  background: var(--weiss); border: 2px solid var(--asphalt); border-radius: 14px 14px 4px 14px;
  box-shadow: 0 10px 28px rgba(29, 38, 45, .25);
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s;
}
.gruss-blase.sichtbar { opacity: 1; transform: none; }
.gruss-text { border: 0; background: none; text-align: left; padding: 14px 4px 14px 16px; font: 600 1rem/1.4 var(--schrift); color: var(--asphalt); cursor: pointer; }
.gruss-zu { border: 0; background: none; font-size: 1.4rem; line-height: 1; padding: 8px 10px; color: var(--stahl); cursor: pointer; }
.chat-offen .gruss-blase { display: none; }
@media (max-width: 720px) {
  .gruss-blase { left: 12px; right: auto; bottom: calc(84px + env(safe-area-inset-bottom)); border-radius: 14px 14px 14px 4px; }
}
@media (prefers-reduced-motion: reduce) { .gruss-blase { transition: none; } }
