/* =========================================================
   SECTION MONSTERS – HeroAI-Chat & Terminbuchung
   css/heroai.css

   CHAT (.hai-*): 1:1 dieselbe Optik wie der HeroAI-Chat in der App
   (app.section-monsters.de, css/hero-ai.css) – helles Panel, violetter
   Verlauf im Kopf, graue Bot-Blasen. Die Tokens sind bewusst identisch
   übernommen, damit beide Oberflächen nicht auseinanderlaufen.

   TERMINBUCHUNG (.tb-*): sitzt im dunklen Demo-Bereich der Landingpage
   und nutzt daher weiter die dunklen Tokens aus css/style.css.
   ========================================================= */

:root {
  /* Aus der App übernommen – nicht abweichen, sonst sehen die Chats verschieden aus */
  --hai-primary:      #5B47D9;
  --hai-primary-dark: #4535c0;
  --hai-primary-glow: rgba(91, 71, 217, 0.3);
  --hai-bg:           #ffffff;
  --hai-bg-dim:       #f9fafb;
  --hai-border:       #e5e7eb;
  --hai-text:         #1f2937;
  --hai-text-muted:   #6b7280;
  --hai-text-light:   #9ca3af;
  --hai-user-bg:      linear-gradient(135deg, #5B47D9, #8B7DD8);
  --hai-user-text:    #ffffff;
  --hai-bot-bg:       #f3f4f6;
  --hai-bot-text:     #1f2937;
  --hai-shadow:       0 20px 60px rgba(0, 0, 0, 0.18);
  --hai-radius:       20px;
  --hai-panel-w:      400px;
  --hai-panel-h:      620px;
  --hai-z:            99998;
  --hai-btn-size:     56px;
}

#hero-ai-root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size:   14px;
  line-height: 1.5;
  color:       var(--hai-text);
  /* iOS Safari bläht Schrift in zu breiten Blöcken auf → unterbinden */
  -webkit-text-size-adjust: 100%;
  text-size-adjust:         100%;
}

/* ============================================
   FLOATING BUTTON
   ============================================ */

#hero-ai-btn {
  position:      fixed;
  bottom:        24px;
  right:         24px;
  z-index:       var(--hai-z);
  display:       flex;
  align-items:   center;
  gap:           8px;
  padding:       0 20px 0 14px;
  height:        var(--hai-btn-size);
  background:    linear-gradient(135deg, #5B47D9, #8B7DD8);
  color:         #fff;
  border:        none;
  border-radius: 999px;
  box-shadow:    0 4px 20px var(--hai-primary-glow), 0 2px 8px rgba(0,0,0,0.15);
  cursor:        pointer;
  transition:    transform .2s, box-shadow .2s, background .2s;
  white-space:   nowrap;
  user-select:   none;
  font-family:   inherit;
}
#hero-ai-btn:hover {
  transform:  translateY(-2px);
  box-shadow: 0 8px 28px var(--hai-primary-glow), 0 4px 12px rgba(0,0,0,0.2);
}
#hero-ai-btn.active { background: linear-gradient(135deg, #4535c0, #7061c8); }
#hero-ai-btn:focus-visible { outline: 3px solid #a6f03a; outline-offset: 3px; }

.hero-ai-btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
}
.hero-ai-btn-icon svg { width: 20px; height: 20px; }

.hero-ai-btn-label { font-size: 14px; font-weight: 700; letter-spacing: .01em; }

.hero-ai-pulse {
  position: absolute; top: -4px; right: -4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #10b981; border: 2px solid #fff;
  animation: hai-pulse 2.5s ease-in-out infinite;
}

@keyframes hai-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.2); opacity: .8; }
}

/* ============================================
   PANEL
   ============================================ */

#hero-ai-panel {
  position:         fixed;
  bottom:           calc(var(--hai-btn-size) + 32px);
  right:            24px;
  z-index:          var(--hai-z);
  width:            var(--hai-panel-w);
  height:           var(--hai-panel-h);
  max-height:       calc(100vh - 120px);
  background:       var(--hai-bg);
  border-radius:    var(--hai-radius);
  box-shadow:       var(--hai-shadow);
  display:          flex;
  flex-direction:   column;
  overflow:         hidden;
  border:           1px solid var(--hai-border);
  opacity:          0;
  transform:        translateY(16px) scale(.97);
  pointer-events:   none;
  transform-origin: bottom right;
  transition:       opacity .25s cubic-bezier(.4,0,.2,1), transform .25s cubic-bezier(.4,0,.2,1);
}
#hero-ai-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

/* ── Kopf ── */
.hai-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #5B47D9, #8B7DD8);
  color: #fff; flex-shrink: 0;
}
.hai-header-left { display: flex; align-items: center; gap: 10px; }

.hai-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-size: 18px;
}
.hai-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Blinkender Cursor während des Streamens – wie in der App */
.hai-cursor {
  display: inline-block;
  animation: hai-blink .8s step-end infinite;
  color: var(--hai-primary);
  font-size: 14px;
}
@keyframes hai-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

.hai-header-name { font-size: 15px; font-weight: 700; line-height: 1.2; margin: 0; }
.hai-header-sub  {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; opacity: .85; margin: 0;
}
.hai-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #10b981; flex-shrink: 0;
  animation: hai-pulse 2.5s ease-in-out infinite;
}
.hai-header-actions { display: flex; gap: 4px; }

.hai-icon-btn {
  width: 32px; height: 32px; border: none; border-radius: 8px;
  background: rgba(255,255,255,.15); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
.hai-icon-btn:hover { background: rgba(255,255,255,.28); }
.hai-icon-btn svg { width: 14px; height: 14px; }

/* ── Nachrichten ── */
.hai-messages {
  flex: 1;
  min-height: 0;              /* iOS-Safari-Flex-Overflow-Fehler */
  overflow-y: auto;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.hai-messages::-webkit-scrollbar       { width: 4px; }
.hai-messages::-webkit-scrollbar-track { background: transparent; }
.hai-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.hai-welcome       { text-align: center; padding: 12px 8px; }
.hai-welcome-icon  { font-size: 32px; margin-bottom: 8px; }
.hai-welcome-title { font-size: 15px; font-weight: 700; color: var(--hai-text); margin-bottom: 4px; }
.hai-welcome-sub   { font-size: 13px; color: var(--hai-text-muted); line-height: 1.5; margin-bottom: 14px; }

.hai-starters { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.hai-starter {
  width: 100%; padding: 9px 14px;
  background: var(--hai-bg-dim);
  border: 1px solid var(--hai-border);
  border-radius: 10px;
  font-size: 13px; color: var(--hai-text);
  cursor: pointer; text-align: left;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit; line-height: 1.4;
}
.hai-starter:hover { background: #ede9fe; border-color: #c4b5fd; color: var(--hai-primary); }

.hai-msg {
  display: flex; flex-direction: column; gap: 3px;
  max-width: 85%;
  animation: hai-msg-in .2s ease-out;
}
@keyframes hai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hai-msg--user      { align-self: flex-end;   align-items: flex-end; }
.hai-msg--assistant { align-self: flex-start; align-items: flex-start; max-width: 92%; min-width: 0; }
.hai-msg--error     { align-self: flex-start; max-width: 92%; }

.hai-bubble {
  padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.55;
  word-break: break-word; overflow-wrap: anywhere;
  min-width: 0; max-width: 100%;
}
.hai-msg--user .hai-bubble {
  background: var(--hai-user-bg); color: var(--hai-user-text);
  border-radius: 16px 16px 4px 16px;
}
.hai-msg--assistant .hai-bubble {
  background: var(--hai-bot-bg); color: var(--hai-bot-text);
  border-radius: 16px 16px 16px 4px;
}
.hai-bubble--error {
  background: #fef2f2; color: #dc2626;
  border: 1px solid #fca5a5; border-radius: 12px;
}
.hai-bubble p  { margin: 0 0 8px; }
.hai-bubble p:last-child { margin: 0; }
.hai-bubble ul { margin: 8px 0; padding-left: 18px; }
.hai-bubble li { margin-bottom: 4px; }
.hai-bubble strong { font-weight: 700; }

/* Tippanzeige */
.hai-typing-dots { display: flex; align-items: center; gap: 4px; padding: 12px 14px; }
.hai-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #9ca3af; animation: hai-bounce 1.2s ease-in-out infinite;
}
.hai-typing-dots span:nth-child(1) { animation-delay: -.32s; }
.hai-typing-dots span:nth-child(2) { animation-delay: -.16s; }

@keyframes hai-bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1; }
}

/* ── Terminauswahl im Chat (helles Design) ── */
.hai-slots { align-self: stretch; display: grid; gap: 6px; }

.hai-slot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 12px 14px;
  background: var(--hai-bg-dim);
  border: 1px solid var(--hai-border);
  border-radius: 12px;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--hai-text); cursor: pointer; text-align: left;
  transition: background .15s, border-color .15s;
}
.hai-slot:hover { background: #ede9fe; border-color: #c4b5fd; }
.hai-slot small { font-weight: 500; font-size: 11.5px; color: var(--hai-text-muted); }
.hai-slot.is-gewaehlt { background: #ede9fe; border-color: var(--hai-primary); }

.hai-form { align-self: stretch; display: grid; gap: 8px; }

.hai-field {
  width: 100%;
  background: var(--hai-bg);
  border: 1.5px solid var(--hai-border);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--hai-text); font-family: inherit;
  font-size: 14px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.hai-field::placeholder { color: var(--hai-text-light); }
.hai-field:focus { border-color: var(--hai-primary); box-shadow: 0 0 0 3px rgba(91,71,217,.12); }

.hai-consent {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 12px; line-height: 1.5; color: var(--hai-text-muted); cursor: pointer;
}
.hai-consent input { margin-top: 2px; accent-color: var(--hai-primary); width: 15px; height: 15px; flex: 0 0 auto; }
.hai-consent a { color: var(--hai-primary); }
.hai-consent.is-fehler { color: #dc2626; }

.hai-btn {
  border: none; border-radius: 10px;
  background: var(--hai-primary); color: #fff;
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  padding: 12px 16px; cursor: pointer;
  transition: background .15s, opacity .15s;
}
.hai-btn:hover:not(:disabled) { background: var(--hai-primary-dark); }
.hai-btn:disabled { opacity: .45; cursor: not-allowed; }

.hai-hinweis {
  align-self: stretch;
  font-size: 12px; line-height: 1.55;
  color: #4535c0; background: #ede9fe;
  border: 1px solid #c4b5fd; border-radius: 10px;
  padding: 10px 12px;
}

/* ── Eingabe ── */
.hai-input-zone {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--hai-border);
  background: var(--hai-bg);
  flex-shrink: 0;
}
.hai-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--hai-bg-dim);
  border: 1.5px solid var(--hai-border);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  transition: border-color .2s, box-shadow .2s;
}
.hai-input-row:focus-within {
  border-color: var(--hai-primary);
  box-shadow: 0 0 0 3px rgba(91,71,217,.12);
}
.hai-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--hai-text); font-family: inherit;
  resize: none; max-height: 120px; line-height: 1.5; padding: 0;
}
.hai-input::placeholder { color: var(--hai-text-light); }

/* iOS-Zoom-Fix: Safari zoomt beim Antippen in JEDES Eingabefeld mit weniger
   als 16px Schriftgröße. Nur auf Touch-Geräten anheben, damit das Desktop-
   Layout unverändert bleibt. Gilt für alle Felder im Chat, auch die des
   Buchungsformulars – sonst zoomt es dort weiter. */
@media (hover: none) and (pointer: coarse) {
  .hai-input, .hai-field { font-size: 16px; }
}

.hai-send-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  border: none; border-radius: 10px;
  background: var(--hai-primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s, opacity .15s;
}
.hai-send-btn:hover:not(:disabled) { background: var(--hai-primary-dark); transform: scale(1.05); }
.hai-send-btn:disabled { opacity: .35; cursor: not-allowed; }
.hai-send-btn svg { width: 16px; height: 16px; }

.hai-input-hint {
  text-align: center; font-size: 11px;
  color: var(--hai-text-light); margin-top: 7px;
}

#hero-ai-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
  z-index: calc(var(--hai-z) - 1);
}
#hero-ai-overlay.open { opacity: 1; pointer-events: auto; }

/* ── Responsiv (wie in der App) ── */

@media (max-width: 768px) { :root { --hai-panel-w: 360px; } }

@media (max-width: 540px) {
  #hero-ai-btn { bottom: 16px; right: 16px; height: 50px; padding: 0 16px 0 12px; }
  #hero-ai-panel {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%; height: 100dvh; max-height: 100dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transform-origin: bottom center;
  }
  #hero-ai-panel.open { transform: translateY(0); }
  .hai-header::before {
    content: ''; display: block; position: absolute;
    top: 8px; left: 50%; transform: translateX(-50%);
    width: 36px; height: 4px;
    background: rgba(255,255,255,.4); border-radius: 2px;
  }
  .hai-header { position: relative; padding-top: 20px; }
  body.hero-ai-open { overflow: hidden; }
}

@media (min-width: 541px) { #hero-ai-overlay { display: none !important; } }

@media (max-width: 360px) {
  .hero-ai-btn-label { display: none; }
  #hero-ai-btn { padding: 0; width: var(--hai-btn-size); justify-content: center; }
  .hero-ai-btn-icon { width: 32px; height: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  #hero-ai-panel { transition: none; }
  .hero-ai-pulse, .hai-status-dot, .hai-typing-dots span { animation: none; }
  #hero-ai-btn:hover, .hai-send-btn:hover { transform: none; }
}

/* =========================================================
   TERMINBUCHUNG IM DEMO-BEREICH
   Bleibt dunkel – sie sitzt im dunklen Abschnitt der Landingpage.
   ========================================================= */

.tb-switch {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(242, 244, 239, .06);
  border-radius: 999px; margin-bottom: 22px;
}

.tb-switch button {
  flex: 1; border: 0; background: none;
  color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 700;
  padding: 11px 14px; border-radius: 999px; cursor: pointer;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.tb-switch button.is-aktiv {
  background: var(--panel-2); color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
}

.tb-panel[hidden] { display: none; }

.tb-titel { font-size: 17px; font-weight: 800; margin: 0 0 6px; }
.tb-lead  { font-size: 14px; line-height: 1.6; color: var(--muted); margin: 0 0 18px; }

.tb-slots { display: grid; gap: 8px; margin-bottom: 18px; }

.tb-slot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--faint);
  background: rgba(242,244,239,.03);
  color: var(--text);
  font: inherit; font-size: 14.5px; font-weight: 600;
  padding: 15px 17px; border-radius: 14px;
  cursor: pointer; text-align: left;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.tb-slot:hover { border-color: var(--green); }
.tb-slot small { font-weight: 500; font-size: 12px; color: var(--muted); }
.tb-slot.is-gewaehlt { border-color: var(--green); background: rgba(139,214,38,.09); }

.tb-slot-check {
  width: 20px; height: 20px; flex: 0 0 auto;
  border-radius: 50%; border: 2px solid var(--faint);
  display: grid; place-items: center;
  font-size: 12px; color: #08080d;
}
.tb-slot.is-gewaehlt .tb-slot-check { background: var(--green); border-color: var(--green); }

.tb-laden, .tb-leer { font-size: 14px; color: var(--muted); padding: 18px 0; text-align: center; }

.tb-hinweis {
  font-size: 13px; line-height: 1.6; color: var(--muted);
  background: rgba(124,92,255,.1);
  border: 1px solid rgba(124,92,255,.32);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 18px;
}

.tb-erfolg { text-align: center; padding: 28px 20px; }
.tb-erfolg-icon { font-size: 42px; margin-bottom: 14px; }
.tb-erfolg strong { display: block; font-size: 18px; margin-bottom: 10px; }
.tb-erfolg span { display: block; font-size: 14px; line-height: 1.65; color: var(--muted); }

.tb-fehler { font-size: 13.5px; color: #fca5a5; margin: 0 0 14px; }

/* Auch hier: iOS zoomt sonst beim Antippen der Formularfelder */
@media (hover: none) and (pointer: coarse) {
  .tb-panel input, .tb-panel textarea, .tb-panel select { font-size: 16px; }
}

@media (max-width: 620px) {
  .tb-switch button { font-size: 13px; padding: 10px 8px; }
}
