/* ----------  Variablen & Grundlayout  ---------- */
:root {
  --primary: #006fb9;
  --primary-dark: #005799;
  --bg: #eef2f7;
  --surface: #ffffff;
  --text: #333333;
  --msg-bg: #f7f8fa;
  --btn-gradient: linear-gradient(135deg, #4c8cff, #006fb9);
  --btn-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: var(--bg);
  font-family: system-ui, sans-serif;
}

/* ----------  Hauptcontainer ---------- */
.chat-window {
  position: relative;
  width: 100%;
  max-width: 1200px;
  height: 94vh;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ----------  HEADER ---------- */
.chat-header {
  position: relative;
  flex: 0 0 60px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center; /* Titel mittig */
  padding: 0 2rem 0 4rem; /* links Platz für Zurück-Button */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.back-btn {
  position: absolute;
  left: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.4rem;
  display: none; /* <-- jetzt anfangs unsichtbar */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.back-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.1);
}

/* Bild im Header ausgeblendet */
.chatbot-icon {
  display: none !important;
  width: 36px;
  height: 36px;
}
.chat-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
  white-space: nowrap; /* verhindert Umbruch, falls gewünscht */
}

/* ----------  MESSAGES ---------- */
.messages {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--surface) 40%, var(--bg) 100%);
  display: flex;
  flex-direction: column;
}
.message {
  max-width: 80%;
  margin: 0.75rem 0;
  padding: 0.75rem 1.1rem;
  border-radius: 20px;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  position: relative;
}
.bot {
  background: var(--msg-bg);
  color: var(--text);
  align-self: flex-start;
}
.user {
  background: var(--btn-gradient);
  color: #fff;
  align-self: flex-end;
  text-align: right;
  box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1),
    -4px -4px 8px rgba(255, 255, 255, 0.7);
  padding-right: 52px; /* Platz für Avatar */
}

/* ----------  OVERLAY SPINNER ---------- */
.overlay {
  position: absolute;
  inset: 60px 0 60px;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #ddd;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ----------  FOOTER / OPTION-BUTTONS ---------- */
.chat-footer {
  flex: 0 0 auto;
  background: var(--surface);
  padding: 0.75rem 0.5rem;
  border-top: 1px solid #e0e0e0;
}
.options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}
.options button {
  flex: 1 1 calc(50% - 0.6rem);
  padding: 0.8rem;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--primary);
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.05),
    -4px -4px 8px rgba(255, 255, 255, 0.7);
  transition: transform 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Hover (nur Desktop) */
@media (hover: hover) {
  .options button:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--btn-shadow);
    transform: translateY(-2px);
  }
}
.options button:active:not(:disabled) {
  background: var(--primary-dark);
  color: #fff;
  transform: scale(0.98);
}
.options button:focus {
  outline: none;
}
.options button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

/* ----------  RESPONSIVE ---------- */
@media (max-width: 520px) {
  .chat-window {
    height: 100vh;
    border-radius: 0;
  }

  /* Header: weiterhin mittig, aber links Platz fürs Icon */
  .chat-header {
    flex: 0 0 54px;
    padding: 0 1.5rem 0 4rem; /* gleiches Padding wie oben */
    justify-content: center;
  }

  .chat-title {
    font-size: 1.2rem;
  }

  .options button {
    flex: 1 1 100%;
    font-size: 0.9rem;
  }
}
/* ----------  INPUT-FELD (Freitext) ---------- */
.input-wrapper {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  align-items: center;
  margin: 0.4rem 0.2rem;
}

.input-wrapper input {
  flex: 1 1 75%; /* → Startbreite 75 % */
  min-width: 0;
  padding: 0.9rem 1rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.05),
    -4px -4px 8px rgba(255, 255, 255, 0.7);
  transition: box-shadow 0.25s, background 0.25s;
}

.input-wrapper input:focus {
  outline: none;
  background: #fefefe;
  box-shadow: var(--btn-shadow);
}

/* Send-Button daneben */
.input-wrapper button {
  flex: 0 0 90px; /* → etwas schmaler */
  padding: 0.9rem;
  border: none;
  border-radius: 12px;
  background: var(--btn-gradient);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
  transition: transform 0.2s, background 0.2s;
}

@media (hover: hover) {
  .input-wrapper button:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
  }
}

.input-wrapper button:active:not(:disabled) {
  transform: scale(0.96);
}

.input-wrapper button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

/* ----------  BOT-AVATAR LINKS VOM TEXT ---------- */
.message.bot:not(.loading) {
  padding-left: 52px;
}
.message.bot:not(.loading)::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translateY(-50%);
  background: url("chatbot-icon.png") center/cover no-repeat;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ----------  USER-AVATAR RECHTS VOM TEXT ---------- */
.message.user::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translateY(-50%);
  background: url("anonym.png") center/cover no-repeat;
  border-radius: 50%;
  flex-shrink: 0;
}

.waiting-loader-text {
  margin-bottom: 0.4rem;
  font-weight: 500;
  color: var(--text);
}

.waiting-loader-animation {
  display: inline-flex;
  gap: 0.35rem;
}

/* drei kleine Kreise, die nacheinander „hüpfen“ */
.waiting-loader-animation span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.4;
  animation: waitingBounce 0.8s infinite ease-in-out;
}
.waiting-loader-animation span:nth-child(2) {
  animation-delay: 0.16s;
}
.waiting-loader-animation span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes waitingBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}
