/* chatbot.css — Lazy-geladene Chatbot-Fenster-Styles.
   Unterstützt Dark Mode & Light Mode mit WCAG AAA High-Contrast Kontrasten. */

.chatbot-window {
  position: fixed;
  bottom: 105px;
  right: 30px;
  width: 380px;
  height: min(580px, 80dvh);
  background: #161628;
  color: #e8e8f0;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: 
    opacity 0.25s ease,
    visibility 0.25s ease,
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.2s, color 0.2s;
}

.chatbot-window.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Light Mode Chatbot Override */
[data-theme="light"] .chatbot-window {
  background: #ffffff;
  color: #0f1430;
  border: 1px solid rgba(15, 20, 48, 0.14);
  box-shadow: 0 20px 60px rgba(15, 20, 48, 0.18);
}

/* Header Styles */
.chatbot-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #141424 0%, #1f2136 100%);
  border-bottom: 1px solid rgba(var(--color-primary-rgb), 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s, border-color 0.2s;
}

[data-theme="light"] .chatbot-header {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid rgba(15, 20, 48, 0.12);
}

.chatbot-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chatbot-avatar-container {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
}

.chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
  background: #1f2136;
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
}

[data-theme="light"] .chatbot-avatar {
  border-color: #d97706;
}

.chatbot-status-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background-color: #4caf50;
  border: 2px solid #161628;
  border-radius: 50%;
  box-shadow: 0 0 8px #4caf50;
}

[data-theme="light"] .chatbot-status-dot {
  border-color: #ffffff;
}

.chatbot-info {
  display: flex;
  flex-direction: column;
}

.chatbot-title {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.5px;
}

[data-theme="light"] .chatbot-title {
  color: #0f1430;
}

.chatbot-subtitle {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75rem;
  margin: 1px 0 0 0;
}

[data-theme="light"] .chatbot-subtitle {
  color: rgba(15, 20, 48, 0.65);
}

.chatbot-status-text {
  color: #4caf50;
  font-weight: 600;
}

[data-theme="light"] .chatbot-status-text {
  color: #15803d;
}

.chatbot-actions {
  display: flex;
  gap: 0.35rem;
}

.chatbot-action-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-size: 1.1rem;
}

[data-theme="light"] .chatbot-action-btn {
  color: #0f1430;
}

.chatbot-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-primary);
}

[data-theme="light"] .chatbot-action-btn:hover {
  background: rgba(15, 20, 48, 0.08);
  color: #b45309;
}

/* Messages Area */
.chatbot-messages {
  flex: 1;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #10101c;
  scroll-behavior: smooth;
  transition: background 0.2s;
}

[data-theme="light"] .chatbot-messages {
  background: #f8fafc;
}

.chat-message {
  display: flex;
  max-width: 88%;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-bubble {
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-message.bot .chat-bubble {
  background: #1f2136;
  color: #e8e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-left-radius: 4px;
}

[data-theme="light"] .chat-message.bot .chat-bubble {
  background: #ffffff;
  color: #0f1430;
  border: 1px solid rgba(15, 20, 48, 0.12);
  box-shadow: 0 2px 8px rgba(15, 20, 48, 0.06);
}

.chat-message.bot .chat-bubble a {
  color: var(--color-primary);
  text-decoration: underline;
  font-weight: 600;
}

[data-theme="light"] .chat-message.bot .chat-bubble a {
  color: #1d4ed8;
}

.chat-message.bot .chat-bubble a:hover {
  color: #ffe066;
}

[data-theme="light"] .chat-message.bot .chat-bubble a:hover {
  color: #1e40af;
}

.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, var(--color-primary) 0%, #e6b800 100%);
  color: #10101c;
  font-weight: 600;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.25);
}

[data-theme="light"] .chat-message.user .chat-bubble {
  background: var(--color-primary);
  color: #0f1430;
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.25);
}

/* Quick Replies */
.chatbot-quick-replies {
  padding: 0.75rem 1.25rem;
  background: #10101c;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.2s, border-color 0.2s;
}

[data-theme="light"] .chatbot-quick-replies {
  background: #f8fafc;
  border-top: 1px solid rgba(15, 20, 48, 0.08);
}

.qr-chip {
  background: #1f2136;
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

[data-theme="light"] .qr-chip {
  background: #ffffff;
  color: #0f1430;
  border: 1px solid rgba(15, 20, 48, 0.16);
}

.qr-chip:hover {
  background: rgba(var(--color-primary-rgb), 0.15);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

[data-theme="light"] .qr-chip:hover {
  background: #fef08a;
  border-color: #ca8a04;
  color: #0f1430;
}

.qr-chip.primary {
  background: var(--color-primary);
  color: #10101c;
  font-weight: 700;
  border-color: var(--color-primary);
}

[data-theme="light"] .qr-chip.primary {
  background: var(--color-primary);
  color: #0f1430;
  border-color: #d97706;
}

.qr-chip.primary:hover {
  background: #ffe066;
}

/* Input Form */
.chatbot-input-container {
  padding: 0.85rem 1rem;
  background: #161628;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  transition: background 0.2s, border-color 0.2s;
}

[data-theme="light"] .chatbot-input-container {
  background: #ffffff;
  border-top: 1px solid rgba(15, 20, 48, 0.1);
}

.chatbot-input-container input {
  flex: 1;
  background: #0c0c16;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 0.65rem 1rem;
  color: #ffffff;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

[data-theme="light"] .chatbot-input-container input {
  background: #f1f5f9;
  color: #0f1430;
  border: 1px solid rgba(15, 20, 48, 0.15);
}

.chatbot-input-container input:focus {
  border-color: var(--color-primary);
}

[data-theme="light"] .chatbot-input-container input:focus {
  border-color: #d97706;
  background: #ffffff;
}

.chatbot-input-container button {
  background: var(--color-primary);
  color: #10101c;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  font-size: 1.1rem;
}

.chatbot-input-container button:hover {
  background: #ffe066;
  transform: scale(1.05);
}

/* Typing Dots */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.85rem 1.25rem;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: rgba(232, 232, 240, 0.5);
  border-radius: 50%;
  animation: typingDot 1.4s infinite ease-in-out both;
}

[data-theme="light"] .typing-dots span {
  background: rgba(15, 20, 48, 0.4);
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.fade-in {
  animation: fadeIn 0.25s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile: Fenster an den Viewport binden.
   Vorher war das Fenster ueberall fest 380px breit bei right:30px — auf
   Viewports < 410px lief die linke Kante aus dem Bild, und bottom:105px +
   80dvh schob die Oberkante unter/hinter den Sticky-Header. */
@media (max-width: 600px) {
  .chatbot-window {
    /* Bewusst ueber right + width statt left: /assistent und /en/assistant
       binden dasselbe Markup inline ein (position: relative) und
       neutralisieren dort right/width/bottom/height per !important. Ein
       `left` wuerde diese Overrides umgehen und das eingebettete Fenster
       um 12px nach rechts aus dem Viewport schieben. */
    right: 12px;
    width: calc(100vw - 24px);
    /* Button ist mobil bottom:20px + 56px hoch (components.css) → 84px frei. */
    bottom: 84px;
    height: auto;
    max-height: calc(100dvh - 84px - 76px); /* 76px: Platz fuer den Sticky-Header */
  }
}
