/* ==========================================================================
   CHATBOT STYLES - VERBESSERT
   ========================================================================== */

/* Chatbot Button - Über den Accessibility Buttons */
.chatbot-button {
  position: fixed !important;
  bottom: 160px !important;
  left: 20px !important;
  right: auto !important;
  top: auto !important;
  width: 60px !important;
  height: 60px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3), 0 0 0 0 rgba(37, 99, 235, 0.4) !important;
  box-sizing: border-box !important;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9998 !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translate(0, 0) scale(1) !important;
  isolation: isolate;
  animation: chatbotPulse 3s ease-in-out infinite;
}

.chatbot-button:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #3b82f6 100%) !important;
  transform: translate(0, -3px) scale(1.08) !important;
  box-shadow: 0 6px 30px rgba(37, 99, 235, 0.5), 0 0 0 8px rgba(37, 99, 235, 0.1) !important;
}

.chatbot-button:active {
  transform: translate(0, -1px) scale(1.05) !important;
}

.chatbot-button:focus {
  outline: 3px solid #3b82f6;
  outline-offset: 3px;
}

.chatbot-button svg,
.chatbot-button i {
  width: 26px !important;
  height: 26px !important;
  color: #ffffff !important;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Notification Badge */
.chatbot-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* Chatbot Window */
.chatbot-window {
  position: fixed;
  bottom: 230px;
  left: 20px;
  width: 400px;
  height: 600px;
  max-height: 80vh;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 10px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.3s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

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

/* Chatbot Header */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: white;
  color: #1a202c;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.chatbot-header-logo {
  height: 42px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
}

.chatbot-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chatbot-header-text p {
  margin: 2px 0 0 0;
  font-size: 0.82rem;
  color: #6b7280;
  font-weight: 400;
}

.chatbot-close {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  color: #4b5563;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.chatbot-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1a202c;
  transform: rotate(90deg);
}

.chatbot-close:focus {
  outline: 2px solid rgba(37, 99, 235, 0.5);
  outline-offset: 2px;
}

.chatbot-close svg {
  width: 20px;
  height: 20px;
}

/* Chatbot Messages Area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Chat Message */
.chat-message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-message.bot .chat-avatar {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: white;
}

.chat-message.user .chat-avatar {
  background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
  color: white;
}

.chat-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 16px;
  word-wrap: break-word;
  line-height: 1.6;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-message.bot .chat-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 16px 16px 16px 4px;
}

.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: white;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.chat-bubble a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
  text-underline-offset: 2px;
  transition: opacity 0.2s ease;
}

.chat-message.bot .chat-bubble a {
  color: #2563eb;
}

.chat-message.user .chat-bubble a {
  color: white;
  opacity: 0.95;
}

.chat-bubble a:hover {
  opacity: 0.75;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typingAnimation 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-8px);
  }
}

/* Quick Actions */
.chatbot-quick-actions {
  padding: 14px 20px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-action-btn {
  padding: 10px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: #1e40af;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.quick-action-btn:hover {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.15);
}

.quick-action-btn:active {
  transform: translateY(0);
}

.quick-action-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Chatbot Input Area */
.chatbot-input-area {
  padding: 18px 20px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 12px;
  align-items: center;
}

.chatbot-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid #e2e8f0;
  border-radius: 28px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
  background: #f8fafc;
}

.chatbot-input:focus {
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.chatbot-input::placeholder {
  color: #94a3b8;
}

.chatbot-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.chatbot-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.chatbot-send-btn:active:not(:disabled) {
  transform: scale(1.02);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-send-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.chatbot-send-btn svg {
  width: 20px;
  height: 20px;
}

/* Welcome Screen */
.chatbot-welcome {
  padding: 32px 24px;
  text-align: center;
}

.chatbot-welcome-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25);
  animation: welcomeIconPulse 3s ease-in-out infinite;
}

@keyframes welcomeIconPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.35);
  }
}

.chatbot-welcome-icon svg {
  width: 36px;
  height: 36px;
  color: white;
}

.chatbot-welcome h4 {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chatbot-welcome p {
  margin: 0 0 28px;
  color: #64748b;
  line-height: 1.6;
  font-size: 0.95rem;
}

.chatbot-suggestions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.suggestion-btn {
  padding: 16px 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: #1e40af;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.suggestion-btn:hover {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-color: #3b82f6;
  transform: translateX(6px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.suggestion-btn:active {
  transform: translateX(4px);
}

.suggestion-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.suggestion-btn svg {
  width: 20px;
  height: 20px;
  color: #3b82f6;
  flex-shrink: 0;
}

/* Responsive Design - Mobile Optimized */

/* Tablets & große Handys */
@media (max-width: 768px) {
  .chatbot-button {
    left: 10px !important;
    bottom: 260px !important;
    width: 58px !important;
    height: 58px !important;
    /* Größere Touch-Targets für Mobile */
  }

  .chatbot-window {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 330px;
    max-height: 75vh;
    height: auto;
    border-radius: 16px;
  }

  .chatbot-header {
    border-radius: 16px 16px 0 0;
    padding: 18px 20px;
  }

  /* Chat-Nachrichten auf Mobile */
  .chatbot-messages {
    padding: 20px 16px;
    gap: 16px;
  }

  .chat-bubble {
    max-width: 80%;
    font-size: 0.94rem;
    padding: 13px 16px;
  }

  .chat-avatar {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  /* Input auf Mobile größer für bessere Bedienbarkeit */
  .chatbot-input-area {
    padding: 16px 18px;
  }

  .chatbot-input {
    font-size: 16px; /* Verhindert Zoom auf iOS */
    padding: 13px 16px;
  }

  .chatbot-send-btn {
    width: 46px;
    height: 46px;
    /* Größerer Touch-Target */
  }

  /* Quick Actions auf Mobile */
  .chatbot-quick-actions {
    padding: 12px 16px;
    gap: 10px;
  }

  .quick-action-btn {
    padding: 11px 16px;
    font-size: 0.87rem;
    /* Bessere Touch-Targets */
  }

  /* Welcome Screen auf Mobile */
  .chatbot-welcome {
    padding: 28px 20px;
  }

  .chatbot-welcome-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
  }

  .chatbot-welcome-icon svg {
    width: 32px;
    height: 32px;
  }

  .chatbot-welcome h4 {
    font-size: 1.35rem;
  }

  .chatbot-welcome p {
    font-size: 0.92rem;
  }

  .suggestion-btn {
    padding: 14px 18px;
    font-size: 0.9rem;
  }
}

/* Mobile Handys (Standard) */
@media (max-width: 480px) {
  .chatbot-button {
    left: 8px !important;
    bottom: 260px !important;
    width: 56px !important;
    height: 56px !important;
  }

  /* Fullscreen-ähnliches Fenster auf kleinen Handys */
  .chatbot-window {
    left: 8px;
    right: 8px;
    bottom: 8px;
    top: 8px;
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 16px;
  }

  .chatbot-header {
    padding: 16px 18px;
  }

  .chatbot-header-logo {
    height: 36px;
    max-width: 160px;
  }

  .chatbot-header-text p {
    font-size: 0.8rem;
  }

  .chatbot-close {
    padding: 7px;
  }

  .chatbot-close svg {
    width: 18px;
    height: 18px;
  }

  .chatbot-messages {
    padding: 18px 14px;
    gap: 14px;
  }

  .chat-bubble {
    font-size: 0.92rem;
    padding: 12px 15px;
    max-width: 85%;
  }

  .chat-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .chatbot-input-area {
    padding: 14px 16px;
  }

  .chatbot-input {
    padding: 12px 15px;
    font-size: 16px;
  }

  .chatbot-send-btn {
    width: 44px;
    height: 44px;
  }

  .chatbot-send-btn svg {
    width: 18px;
    height: 18px;
  }

  .quick-action-btn {
    font-size: 0.84rem;
    padding: 10px 14px;
  }

  .chatbot-welcome {
    padding: 24px 18px;
  }

  .chatbot-welcome-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 18px;
  }

  .chatbot-welcome-icon svg {
    width: 30px;
    height: 30px;
  }

  .chatbot-welcome h4 {
    font-size: 1.25rem;
    margin-bottom: 10px;
  }

  .chatbot-welcome p {
    font-size: 0.9rem;
    margin-bottom: 22px;
  }

  .suggestion-btn {
    padding: 13px 16px;
    font-size: 0.88rem;
    gap: 10px;
  }

  .suggestion-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Sehr kleine Handys */
@media (max-width: 360px) {
  .chatbot-button {
    left: 6px !important;
    bottom: 260px !important;
    width: 54px !important;
    height: 54px !important;
  }

  .chatbot-button svg {
    width: 24px !important;
    height: 24px !important;
  }

  .chatbot-window {
    left: 6px;
    right: 6px;
    bottom: 6px;
    top: 6px;
  }

  .chatbot-header {
    padding: 14px 16px;
  }

  .chatbot-messages {
    padding: 16px 12px;
  }

  .chat-bubble {
    font-size: 0.9rem;
    padding: 11px 14px;
  }

  .chatbot-input-area {
    padding: 12px 14px;
  }

  .chatbot-welcome {
    padding: 20px 16px;
  }

  .suggestion-btn {
    padding: 12px 14px;
    font-size: 0.86rem;
  }
}

/* Landscape-Modus auf Handys */
@media (max-width: 768px) and (orientation: landscape) {
  .chatbot-window {
    bottom: 10px;
    top: 10px;
    max-height: 90vh;
  }

  .chatbot-messages {
    padding: 16px;
  }

  .chatbot-welcome {
    padding: 20px 18px;
  }

  .chatbot-welcome-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
  }

  .chatbot-welcome h4 {
    font-size: 1.2rem;
    margin-bottom: 8px;
  }

  .chatbot-welcome p {
    font-size: 0.88rem;
    margin-bottom: 18px;
  }

  .suggestion-btn {
    padding: 11px 15px;
  }
}

/* iOS Safari spezifische Fixes */
@supports (-webkit-touch-callout: none) {
  .chatbot-window {
    /* Berücksichtigt iOS Notch/Safe Area */
    bottom: env(safe-area-inset-bottom, 330px);
  }

  @media (max-width: 480px) {
    .chatbot-window {
      bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
      top: calc(env(safe-area-inset-top, 0px) + 8px);
    }
  }

  .chatbot-button {
    bottom: calc(260px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Touch-optimierte Interaktionen */
@media (hover: none) and (pointer: coarse) {
  /* Mobile Touch-Geräte */
  .chatbot-button,
  .chatbot-send-btn,
  .quick-action-btn,
  .suggestion-btn,
  .chatbot-close {
    /* Größere Touch-Targets */
    min-width: 44px;
    min-height: 44px;
  }

  /* Entferne Hover-Effekte auf Touch-Geräten */
  .chatbot-button:hover {
    transform: translate(0, 0) scale(1) !important;
  }

  /* Active-States statt Hover */
  .chatbot-button:active {
    transform: translate(0, -2px) scale(1.05) !important;
  }

  .suggestion-btn:active {
    transform: translateX(4px);
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
  }

  .quick-action-btn:active {
    transform: translateY(-1px);
  }
}

/* Animation for chatbot button */
@keyframes chatbotPulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3), 0 0 0 0 rgba(37, 99, 235, 0.4);
  }
  50% {
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3), 0 0 0 8px rgba(37, 99, 235, 0.1);
  }
}

/* Dark Mode Support */
html.accessibility-dark-mode .chatbot-window {
  background: #1a1a1a;
  border: 1px solid #404040;
}

html.accessibility-dark-mode .chatbot-messages {
  background: linear-gradient(180deg, #0f0f0f 0%, #1a1a1a 100%);
}

html.accessibility-dark-mode .chat-message.bot .chat-bubble {
  background: #2d2d2d;
  color: #e5e5e5;
  border-color: #404040;
}

html.accessibility-dark-mode .chatbot-input-area,
html.accessibility-dark-mode .chatbot-quick-actions {
  background: #1a1a1a;
  border-color: #404040;
}

html.accessibility-dark-mode .chatbot-input {
  background: #2d2d2d;
  color: #e5e5e5;
  border-color: #404040;
}

html.accessibility-dark-mode .chatbot-input:focus {
  background: #2d2d2d;
  border-color: #3b82f6;
}

html.accessibility-dark-mode .quick-action-btn,
html.accessibility-dark-mode .suggestion-btn {
  background: #2d2d2d;
  color: #e5e5e5;
  border-color: #404040;
}

html.accessibility-dark-mode .quick-action-btn:hover,
html.accessibility-dark-mode .suggestion-btn:hover {
  background: #404040;
  border-color: #3b82f6;
}

html.accessibility-dark-mode .chatbot-welcome h4 {
  color: #ffffff;
}

html.accessibility-dark-mode .chatbot-welcome p {
  color: #a0a0a0;
}
