/*
 * Bugbär Chat-Widget — Waldemaster-Design-System (Petrol/Pergament,
 * Georgia-Serife, harte 1px-Konturen, vgl. wmg-shared.css).
 * !important auf Hintergrund-/Textfarben: das Theme bringt globale
 * Magenta-Regeln fuer button/.active/:hover mit (bekannter Fall).
 */
/*
 * Harte Resets: Das Theme legt eigene Regeln (Magenta-Rahmen/-Outlines,
 * Uppercase, Paddings, Schriftarten) auf button/textarea, die das Widget
 * sonst verunstalten. Alles Sichtbare hier deshalb mit !important festnageln.
 */
.wba-root, .wba-root *{ box-sizing: border-box; }
.wba-root button{
  text-transform: none !important;
  letter-spacing: normal !important;
  box-shadow: none !important;
  outline: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  line-height: 1.3 !important;
  font-family: Georgia, 'Times New Roman', serif !important;
}
.wba-root button:hover,
.wba-root button:focus,
.wba-root button:active{
  outline: none !important;
  box-shadow: none !important;
}

.wba-root{
  --wm-teal: #0c857b;
  --wm-teal-light: #49a49c;
  --wm-teal-tint: #e7f3f2;
  --wm-gold: #c9a35c;
  --wm-gold-tint: #f7f0e2;
  --wm-parchment-dark: #e5e1d6;
  --wm-panel: #faf7f0;
  --wm-ink: #262421;
  --wm-on-teal: #ffffff;
  --wm-muted: #6b6558;
  --wm-muted2: #8a8474;
  --wm-radius: 8px;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99990;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--wm-ink);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* ---------- Schwebender Kaefer-Button ---------- */
.wba-toggle{
  width: 58px !important;
  height: 58px !important;
  border-radius: 50% !important;
  border: 1px solid var(--wm-teal) !important;
  background: var(--wm-panel) !important;
  color: var(--wm-teal) !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(38,36,33,.22) !important;
  transition: transform .15s ease, box-shadow .15s ease;
  padding: 6px !important;
}
.wba-toggle:hover{ transform: translateY(-2px); box-shadow: 0 6px 18px rgba(38,36,33,.28) !important; background: var(--wm-teal-tint) !important; }
/* Käfer-Button ausblenden, solange der Chat offen ist. */
.wba-root.wba-open .wba-toggle{ display: none !important; }

/* ---------- Teaser-Sprechblase ("Brauchst du Hilfe?") ---------- */
.wba-teaser{
  position: relative;
  max-width: 220px;
  background: var(--wm-panel);
  color: var(--wm-ink);
  border: 1px solid var(--wm-teal);
  border-radius: var(--wm-radius);
  padding: 9px 30px 9px 12px;
  box-shadow: 0 4px 14px rgba(38,36,33,.22);
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
  align-self: flex-end;
  opacity: 0;
  transform: translateY(6px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .2s ease, transform .2s ease;
}
.wba-teaser[hidden]{ display: none; }
.wba-teaser.wba-teaser-in{ opacity: 1; transform: translateY(0) scale(1); }
.wba-teaser:hover{ border-color: var(--wm-teal-light); }
/* Schwänzchen, das zum Käfer-Button zeigt (unten rechts). */
.wba-teaser::after{
  content: "";
  position: absolute;
  right: 20px;
  bottom: -8px;
  width: 14px;
  height: 14px;
  background: var(--wm-panel);
  border-right: 1px solid var(--wm-teal);
  border-bottom: 1px solid var(--wm-teal);
  transform: rotate(45deg);
}
.wba-teaser-text{ font-family: Georgia, 'Times New Roman', serif; }
.wba-teaser-close{
  position: absolute;
  top: 2px;
  right: 4px;
  border: 0;
  background: transparent !important;
  color: var(--wm-muted2) !important;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.wba-teaser-close:hover{ color: var(--wm-teal) !important; background: transparent !important; }
/* Wenn der Chat offen ist, ist auch die Blase weg. */
.wba-root.wba-open .wba-teaser{ display: none !important; }
.wba-toggle .wba-avatar-svg,
.wba-toggle .wba-avatar-img{ width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }

/* ---------- Chat-Panel ---------- */
.wba-panel{
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 110px);
  background: var(--wm-panel);
  border: 1px solid var(--wm-teal);
  border-radius: var(--wm-radius);
  box-shadow: 0 10px 30px rgba(38,36,33,.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wba-panel[hidden]{ display: none; }

/* Header */
.wba-header{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--wm-teal);
  color: var(--wm-on-teal);
  flex: 0 0 auto;
}
.wba-header-avatar{
  width: 36px; height: 36px; flex: 0 0 auto;
  background: var(--wm-panel);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 3px;
  border: 1px solid var(--wm-gold);
}
.wba-header-avatar .wba-avatar-svg,
.wba-header-avatar .wba-avatar-img{ width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.wba-header-text{ display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1 1 auto; }
.wba-header-text strong{ font-size: 15px; letter-spacing: .3px; color: var(--wm-on-teal); }
.wba-header-sub{ font-size: 11px; opacity: .85; }

.wba-lang-toggle{
  display: inline-flex;
  border: 1px solid rgba(255,255,255,.55) !important;
  border-radius: 4px !important;
  overflow: hidden;
  flex: 0 0 auto;
}
.wba-lang-btn{
  appearance: none; -webkit-appearance: none;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: rgba(255,255,255,.75) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: .06em !important;
  padding: 3px 8px !important;
  height: auto !important;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.wba-lang-btn + .wba-lang-btn{ border-left: 1px solid rgba(255,255,255,.55) !important; }
.wba-lang-btn.active{ background: var(--wm-panel) !important; color: var(--wm-teal) !important; }

.wba-close{
  appearance: none; -webkit-appearance: none;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--wm-on-teal) !important;
  font-size: 22px !important;
  line-height: 1 !important;
  cursor: pointer;
  padding: 2px 6px !important;
  height: auto !important;
  width: auto !important;
  flex: 0 0 auto;
}
.wba-close:hover{ color: var(--wm-gold) !important; background: transparent !important; }

/* Nachrichtenbereich */
.wba-messages{
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    linear-gradient(rgba(250,247,240,.94), rgba(250,247,240,.94)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(201,163,92,.05) 12px 24px);
}
.wba-msg{
  max-width: 85%;
  padding: 9px 12px;
  border-radius: var(--wm-radius);
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid var(--wm-parchment-dark);
  overflow-wrap: break-word;
}
.wba-msg-assistant{
  align-self: flex-start;
  background: #fff;
  border-color: var(--wm-teal-light);
  border-bottom-left-radius: 2px;
}
.wba-msg-user{
  align-self: flex-end;
  background: var(--wm-teal-tint);
  border-color: var(--wm-teal-light);
  border-bottom-right-radius: 2px;
}
.wba-msg-error{
  align-self: flex-start;
  background: var(--wm-gold-tint);
  border-color: var(--wm-gold);
  color: var(--wm-muted);
  font-size: 12.5px;
}
.wba-msg p{ margin: 0 0 6px; }
.wba-msg p:last-child{ margin-bottom: 0; }
.wba-msg ul{ margin: 4px 0; padding-left: 18px; }
.wba-msg li{ margin: 2px 0; }
.wba-msg a{ color: var(--wm-teal) !important; font-weight: 700; text-decoration: underline; }
.wba-msg a:hover{ color: var(--wm-teal-light) !important; }
.wba-msg strong{ color: inherit; }

/* Tipp-Indikator */
.wba-typing{
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--wm-teal-light);
  border-radius: var(--wm-radius);
  border-bottom-left-radius: 2px;
}
.wba-typing i{
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--wm-teal);
  animation: wbaBlink 1.2s infinite ease-in-out;
}
.wba-typing i:nth-child(2){ animation-delay: .2s; }
.wba-typing i:nth-child(3){ animation-delay: .4s; }
@keyframes wbaBlink{ 0%,80%,100%{ opacity: .25; } 40%{ opacity: 1; } }

/* Eingabezeile */
.wba-inputrow{
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--wm-parchment-dark);
  background: #fff;
  flex: 0 0 auto;
}
.wba-input{
  flex: 1 1 auto;
  resize: none !important;
  border: 1px solid var(--wm-parchment-dark) !important;
  border-radius: 4px !important;
  background: var(--wm-panel) !important;
  color: var(--wm-ink) !important;
  font-family: Georgia, 'Times New Roman', serif !important;
  font-size: 13.5px !important;
  line-height: 1.4 !important;
  padding: 8px 10px !important;
  margin: 0 !important;
  min-height: 0 !important;
  max-height: 110px;
  overflow-y: auto;
  box-shadow: none !important;
}
.wba-input:focus{ outline: none !important; border-color: var(--wm-teal) !important; box-shadow: 0 0 0 3px var(--wm-teal-tint) !important; }
.wba-send{
  appearance: none; -webkit-appearance: none;
  width: 38px !important;
  height: 38px !important;
  flex: 0 0 auto;
  border-radius: 4px !important;
  border: 1px solid var(--wm-teal) !important;
  background: var(--wm-teal) !important;
  color: var(--wm-on-teal) !important;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0 !important;
  transition: background .15s ease;
}
.wba-send:hover{ background: var(--wm-teal-light) !important; border-color: var(--wm-teal-light) !important; }
.wba-send:disabled{ opacity: .5; cursor: not-allowed; }

/* Fusszeile */
.wba-footnote{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 6px 12px 8px;
  background: #fff;
  font-size: 10.5px;
  color: var(--wm-muted2);
  flex: 0 0 auto;
}

/* Kontingent-Anzeige (nur eingeloggte Nutzer/Admins; Server liefert den Stand) */
.wba-quota{
  font-weight: 700;
  color: var(--wm-teal);
  white-space: nowrap;
}
.wba-quota[hidden]{ display: none; }
.wba-quota-warn{ color: var(--wm-gold); }
.wba-clear{
  appearance: none; -webkit-appearance: none;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--wm-teal) !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  cursor: pointer;
  padding: 0 !important;
  height: auto !important;
  width: auto !important;
  text-decoration: underline !important;
}
.wba-clear:hover{ color: var(--wm-teal-light) !important; background: transparent !important; }

/* ---------- Mobil: Panel als Bottom-Sheet ---------- */
@media (max-width: 480px){
  .wba-root{ right: 12px; bottom: 12px; }
  .wba-panel{
    position: fixed;
    left: 8px; right: 8px; bottom: 8px;
    width: auto;
    height: min(78vh, 560px);
    max-height: none;
  }
}

/* ------------------------------------------------------------------
 * Theme-Override-Schicht (ID-verankert, am Dateiende).
 * Das Website-Theme nutzt selbst !important auf button-Regeln; bei
 * gleichem !important entscheidet die Spezifitaet, und nur Selektoren
 * mit #wba-root gewinnen zuverlaessig (bewaehrtes Muster, vgl.
 * Spell Card Editor). Hier werden alle sichtbaren Button-/Input-
 * Eigenschaften noch einmal mit ID-Anker festgenagelt.
 * ------------------------------------------------------------------ */
#wba-root button,
#wba-root button:hover,
#wba-root button:focus,
#wba-root button:focus-visible,
#wba-root button:active{
  outline: none !important;
  box-shadow: none !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  text-decoration: none !important;
  font-family: Georgia, 'Times New Roman', serif !important;
  line-height: 1.3 !important;
}

#wba-root .wba-toggle,
#wba-root .wba-toggle:hover,
#wba-root .wba-toggle:focus{
  width: 58px !important;
  height: 58px !important;
  padding: 6px !important;
  border: 1px solid #0c857b !important;
  border-radius: 50% !important;
  background: #faf7f0 !important;
  color: #0c857b !important;
  box-shadow: 0 4px 14px rgba(38,36,33,.22) !important;
}
#wba-root .wba-toggle:hover{ background: #e7f3f2 !important; }
#wba-root.wba-open .wba-toggle{ display: none !important; }

#wba-root .wba-lang-toggle{
  border: 1px solid rgba(255,255,255,.55) !important;
  border-radius: 4px !important;
}
#wba-root .wba-lang-btn,
#wba-root .wba-lang-btn:hover,
#wba-root .wba-lang-btn:focus{
  border: 0 !important;
  border-radius: 0 !important;
  padding: 3px 8px !important;
  height: auto !important;
  width: auto !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: .06em !important;
  background: transparent !important;
  color: rgba(255,255,255,.75) !important;
}
#wba-root .wba-lang-btn + .wba-lang-btn{ border-left: 1px solid rgba(255,255,255,.55) !important; }
#wba-root .wba-lang-btn.active{ background: #faf7f0 !important; color: #0c857b !important; }

#wba-root .wba-close,
#wba-root .wba-close:hover,
#wba-root .wba-close:focus{
  border: 0 !important;
  border-radius: 0 !important;
  padding: 2px 6px !important;
  width: auto !important;
  height: auto !important;
  background: transparent !important;
  color: #ffffff !important;
  font-size: 22px !important;
  line-height: 1 !important;
}
#wba-root .wba-close:hover{ color: #c9a35c !important; }

#wba-root .wba-send,
#wba-root .wba-send:focus{
  width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  border: 1px solid #0c857b !important;
  border-radius: 4px !important;
  background: #0c857b !important;
  color: #ffffff !important;
}
#wba-root .wba-send:hover{
  width: 38px !important;
  height: 38px !important;
  padding: 0 !important;
  border: 1px solid #49a49c !important;
  border-radius: 4px !important;
  background: #49a49c !important;
  color: #ffffff !important;
}

#wba-root .wba-clear,
#wba-root .wba-clear:hover,
#wba-root .wba-clear:focus{
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  width: auto !important;
  height: auto !important;
  background: transparent !important;
  color: #0c857b !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  text-decoration: underline !important;
}
#wba-root .wba-clear:hover{ color: #49a49c !important; }

#wba-root .wba-input{
  resize: none !important;
  border: 1px solid #e5e1d6 !important;
  border-radius: 4px !important;
  padding: 8px 10px !important;
  margin: 0 !important;
  min-height: 0 !important;
  background: #faf7f0 !important;
  color: #262421 !important;
  font-family: Georgia, 'Times New Roman', serif !important;
  font-size: 13.5px !important;
  line-height: 1.4 !important;
  box-shadow: none !important;
  outline: none !important;
}
#wba-root .wba-input:focus{
  border-color: #0c857b !important;
  box-shadow: 0 0 0 3px #e7f3f2 !important;
  outline: none !important;
}

#wba-root .wba-teaser-close,
#wba-root .wba-teaser-close:hover,
#wba-root .wba-teaser-close:focus{
  border: 0 !important;
  border-radius: 0 !important;
  padding: 2px 4px !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  background: transparent !important;
  color: #8a8474 !important;
  font-size: 16px !important;
  line-height: 1 !important;
  box-shadow: none !important;
}
#wba-root .wba-teaser-close:hover{ color: #0c857b !important; }
