/*
 * Der Walther-Assistent — Walther-Look.
 * Blau #1A3E8F, Rot #D2122E, Schrift Poppins / Inter.
 */

:root {
  --walther-blau: #1a3e8f;
  --walther-blau-dunkel: #12306f;
  --walther-rot: #d2122e;
  --hintergrund: #ffffff;
  --flaeche: #f2f5fb;
  --linie: #d9e0ec;
  --text: #1c2431;
  --text-leise: #5a6472;
  --weiss: #ffffff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Poppins", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--flaeche);
  -webkit-font-smoothing: antialiased;
}

/* --- Startknopf unten rechts ------------------------------------------------- */

.chat-knopf {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--walther-blau);
  color: var(--weiss);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(26, 62, 143, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.chat-knopf:hover {
  background: var(--walther-blau-dunkel);
  transform: scale(1.05);
}

.chat-knopf:focus-visible,
.chat-schliessen:focus-visible,
.chat-senden:focus-visible,
.chat-eingabe:focus-visible {
  outline: 3px solid rgba(210, 18, 46, 0.6);
  outline-offset: 2px;
}

/* --- Chat-Fenster ------------------------------------------------------------ */

.chat-fenster {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 1001;
  width: 380px;
  max-width: calc(100vw - 20px);
  height: min(600px, calc(100dvh - 112px));
  display: flex;
  flex-direction: column;
  background: var(--hintergrund);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(16, 32, 68, 0.28);
  border: 1px solid var(--linie);
  animation: aufklappen 0.18s ease-out;
}

@keyframes aufklappen {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Kopfzeile in Walther-Blau */
.chat-kopf {
  background: var(--walther-blau);
  color: var(--weiss);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-kopf-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.chat-kopf-text strong {
  font-size: 1rem;
  font-weight: 600;
}

.chat-kopf-text span {
  font-size: 0.72rem;
  opacity: 0.85;
}

.chat-schliessen {
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: var(--weiss);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-schliessen:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Verlauf */
.chat-verlauf {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--flaeche);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Sprechblasen */
.nachricht {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.nachricht.assistent {
  align-self: flex-start;
  background: var(--weiss);
  border: 1px solid var(--linie);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.nachricht.besucher {
  align-self: flex-end;
  background: var(--walther-blau);
  color: var(--weiss);
  border-bottom-right-radius: 4px;
}

.nachricht.fehler {
  align-self: flex-start;
  background: #fdecee;
  border: 1px solid #f3c2c8;
  color: #7c1523;
  border-bottom-left-radius: 4px;
}

/* Fußbereich mit Eingabe */
.chat-fuss {
  border-top: 1px solid var(--linie);
  background: var(--weiss);
  padding: 10px 12px 8px;
}

.chat-eingabe-zeile {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-eingabe {
  flex: 1;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  padding: 10px 12px;
  border: 1px solid var(--linie);
  border-radius: 22px;
  background: var(--flaeche);
}

.chat-eingabe::placeholder {
  color: var(--text-leise);
}

.chat-senden {
  flex: none;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--walther-blau);
  color: var(--weiss);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.chat-senden:hover {
  background: var(--walther-blau-dunkel);
}

.chat-senden:disabled {
  opacity: 0.5;
  cursor: default;
}

.chat-hinweis {
  margin: 6px 2px 0;
  font-size: 0.68rem;
  color: var(--text-leise);
  text-align: center;
}

/* Ladeanzeige (drei Punkte) */
.chat-ladeanzeige {
  position: absolute;
  left: 14px;
  bottom: 84px;
  background: var(--weiss);
  border: 1px solid var(--linie);
  border-bottom-left-radius: 4px;
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 6px 16px rgba(16, 32, 68, 0.12);
}

.chat-ladeanzeige span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--walther-blau);
  opacity: 0.35;
  animation: puls 1s ease-in-out infinite;
}

.chat-ladeanzeige span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-ladeanzeige span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes puls {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 0.9; transform: translateY(-3px); }
}

/* --- Mobil: Fenster fast vollflächig ----------------------------------------- */

@media (max-width: 480px) {
  .chat-knopf {
    right: 14px;
    bottom: 14px;
  }

  .chat-fenster {
    right: 10px;
    left: 10px;
    bottom: 76px;
    width: auto;
    max-width: none;
    height: min(640px, calc(100dvh - 88px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-fenster,
  .chat-ladeanzeige span {
    animation: none;
  }
}
