/* ============================================================
   BaufiExperte – AI-Chat Widget (Bea)
   ============================================================ */

/* Site-Floating-Buttons (WhatsApp + Telefon) über Bea-Launcher
   positionieren, damit Bea ganz unten rechts sitzt. */
.float-buttons {
  bottom: 5.5rem !important;
}
@media (max-width: 768px) {
  .float-buttons {
    bottom: 5rem !important;
  }
}

.bx-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 14px 16px;
  background: var(--navy, #0B1F42);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(11, 31, 66, 0.35);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.bx-chat-launcher:hover {
  transform: translateY(-2px);
  background: var(--navy-light, #1A3A6C);
  box-shadow: 0 12px 32px rgba(11, 31, 66, 0.45);
}
.bx-chat-launcher svg { width: 22px; height: 22px; }
.bx-chat-launcher .bx-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  background: var(--gold, #C8A84B);
  border-radius: 50%;
  border: 2px solid #fff;
}

.bx-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 620px;
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(11, 31, 66, 0.35);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-body, 'Inter', sans-serif);
}
.bx-chat-window.open { display: flex; }

.bx-chat-header {
  background: linear-gradient(135deg, var(--navy, #0B1F42) 0%, var(--navy-light, #1A3A6C) 100%);
  color: #fff;
  padding: 18px 20px;
  padding-top: max(18px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
}
.bx-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold, #C8A84B);
  color: var(--navy, #0B1F42);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.bx-chat-title { flex: 1; }
.bx-chat-title strong { display: block; font-size: 15px; font-weight: 600; }
.bx-chat-title span { font-size: 12px; opacity: 0.8; }
.bx-chat-title span::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #10B981;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.bx-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.bx-chat-close:hover { opacity: 1; background: rgba(255,255,255,0.1); }

.bx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: var(--bg, #F7F9FC);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.bx-chat-messages::-webkit-scrollbar { width: 6px; }
.bx-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }

.bx-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.bx-msg.user {
  align-self: flex-end;
  background: var(--navy, #0B1F42);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bx-msg.assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--text, #1A202C);
  border: 1px solid var(--border, #E2E8F0);
  border-bottom-left-radius: 4px;
}
.bx-msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-muted, #718096);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
  padding: 6px 12px;
}
.bx-msg a { color: var(--blue, #2563EB); text-decoration: underline; }

.bx-typing {
  align-self: flex-start;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: inline-flex;
  gap: 4px;
}
.bx-typing span {
  width: 6px;
  height: 6px;
  background: #cbd5e0;
  border-radius: 50%;
  animation: bx-bounce 1.2s infinite;
}
.bx-typing span:nth-child(2) { animation-delay: 0.15s; }
.bx-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bx-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.bx-chat-cta {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid var(--border, #E2E8F0);
  display: none;
}
.bx-chat-cta.show { display: block; }
.bx-chat-cta a {
  display: block;
  padding: 10px 14px;
  background: var(--gold, #C8A84B);
  color: var(--navy, #0B1F42);
  text-align: center;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s;
}
.bx-chat-cta a:hover { background: var(--gold-light, #E8C96B); }

.bx-chat-input-wrap {
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid var(--border, #E2E8F0);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.bx-chat-input {
  flex: 1;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  max-height: 110px;
  min-height: 40px;
  line-height: 1.4;
  background: #fff;
  color: var(--text, #1A202C);
  outline: none;
  transition: border-color 0.2s;
}
.bx-chat-input:focus { border-color: var(--navy, #0B1F42); }
.bx-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--navy, #0B1F42);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}
.bx-chat-send:hover:not(:disabled) { background: var(--navy-light, #1A3A6C); }
.bx-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }
.bx-chat-send svg { width: 18px; height: 18px; }

.bx-chat-disclaimer {
  padding: 8px 16px 12px;
  background: #fff;
  font-size: 10.5px;
  color: var(--text-muted, #718096);
  text-align: center;
  line-height: 1.4;
}
.bx-chat-disclaimer a { color: var(--navy-light, #1A3A6C); }

@media (max-width: 480px) {
  .bx-chat-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .bx-chat-input-wrap {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .bx-chat-launcher { bottom: 16px; right: 16px; padding: 12px 16px 12px 14px; font-size: 14px; }
}
