/* ============================================
   KI-SALES ASSISTANT STYLING - OPTIMIERT
   ============================================ */

/* Chat Toggle Button - Größer & mit Text */
.ai-chat-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.9rem 1.5rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-strong) 0%, #667eea 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 8px 30px rgba(58, 155, 255, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  z-index: 9998;
  font-weight: 600;
  font-size: 0.95rem;
  animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 8px 30px rgba(58, 155, 255, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 8px 40px rgba(58, 155, 255, 0.6), 0 0 20px rgba(58, 155, 255, 0.3);
    transform: scale(1.02);
  }
}

.ai-chat-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(58, 155, 255, 0.5);
  animation: none;
}

.ai-chat-toggle svg {
  width: 24px;
  height: 24px;
}

.ai-chat-toggle-text {
  white-space: nowrap;
}

/* Tooltip */
.ai-chat-tooltip {
  position: fixed;
  bottom: 5.5rem;
  right: 2rem;
  background: var(--text);
  color: white;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 9997;
  max-width: 220px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
}

.ai-chat-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 2.5rem;
  width: 12px;
  height: 12px;
  background: var(--text);
  transform: rotate(45deg);
}

.ai-chat-toggle:hover + .ai-chat-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Welcome Bubble */
.ai-welcome-bubble {
  position: fixed;
  bottom: 5.5rem;
  right: 2rem;
  background: white;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.15);
  max-width: 280px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.4s ease;
  z-index: 9997;
  border: 1px solid var(--line);
}

.ai-welcome-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 3rem;
  width: 16px;
  height: 16px;
  background: white;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}

.ai-welcome-bubble.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.ai-welcome-bubble p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}

.ai-welcome-bubble-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  transition: color 0.2s ease;
}

.ai-welcome-bubble-close:hover {
  color: var(--text);
}

.ai-welcome-bubble-close svg {
  width: 16px;
  height: 16px;
}

.ai-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc2626;
  color: #ffffff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid white;
}

/* Chat Container - Glass Effect */
.ai-chat-container {
  position: fixed;
  bottom: 6rem;
  right: 2rem;
  width: 420px;
  max-width: calc(100vw - 2rem);
  height: 650px;
  max-height: calc(100vh - 10rem);
  background: rgba(255, 255, 255, 0.98);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: 0 12px 50px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9997;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .ai-chat-container {
    background: #ffffff;
  }

  .dark .ai-chat-container {
    background: #111827;
    border-color: #374151;
  }
}

.ai-chat-container.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header - Optimiert */
.ai-chat-header {
  padding: 1.2rem 1.3rem;
  background: linear-gradient(135deg, var(--accent-strong) 0%, #667eea 100%);
  color: white;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-chat-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.ai-chat-avatar svg {
  width: 22px;
  height: 22px;
}

.ai-chat-title {
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0;
}

.ai-chat-subtitle {
  font-size: 0.85rem;
  opacity: 0.95;
  margin: 0;
  line-height: 1.4;
  font-weight: 400;
}

.ai-chat-status {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.ai-chat-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.8);
}

.ai-chat-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.6rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ai-chat-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(90deg);
}

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

/* Chat Messages */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

/* KI-Nutzen Info-Box */
.ai-info-box {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.5rem;
  animation: slideDown 0.5s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-info-box h4 {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--accent-strong);
  font-weight: 600;
}

.ai-info-box ul {
  margin: 0;
  padding-left: 1.2rem;
  list-style: none;
}

.ai-info-box li {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.3rem;
  position: relative;
  padding-left: 0.3rem;
}

.ai-info-box li::before {
  content: '✓';
  position: absolute;
  left: -1rem;
  color: var(--accent-strong);
  font-weight: 600;
}

.ai-info-box-footer {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(102, 182, 255, 0.2);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.ai-message {
  display: flex;
  gap: 0.6rem;
  animation: messageSlideIn 0.4s ease;
}

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

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

.ai-message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-strong) 0%, #667eea 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(58, 155, 255, 0.3);
}

.ai-message-avatar svg {
  width: 17px;
  height: 17px;
}

.ai-message-content {
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  font-size: 0.9375rem;
}

.ai-message-bot .ai-message-content {
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
}

.ai-message-user .ai-message-content {
  background: linear-gradient(135deg, var(--accent-strong) 0%, #667eea 100%);
  color: white;
}

/* Typing Indicator */
.ai-typing .ai-message-content {
  padding: 1rem;
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.ai-typing .ai-message-content span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingDot 1.4s infinite;
}

.ai-typing .ai-message-content span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing .ai-message-content span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Quick Replies - Optimiert */
.ai-chat-quick-replies {
  padding: 0.8rem 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  background: white;
  border-top: 1px solid var(--line);
}

.ai-quick-replies-title {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-quick-reply {
  padding: 0.7rem 1.1rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.ai-quick-reply:hover {
  background: var(--accent-soft);
  border-color: var(--accent-strong);
  color: var(--accent-strong);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 182, 255, 0.2);
}

.ai-quick-reply:active {
  transform: translateY(0);
}

/* Chat Input */
.ai-chat-input-container {
  padding: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.5rem;
  background: white;
  border-radius: 0 0 var(--radius) var(--radius);
}

.ai-chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.ai-chat-input:focus {
  border-color: var(--accent);
}

.ai-chat-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-strong) 0%, #667eea 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.ai-chat-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(58, 155, 255, 0.25);
}

.ai-chat-send svg {
  width: 18px;
  height: 18px;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .ai-chat-toggle {
    bottom: 1rem;
    right: 1rem;
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
    animation: none;
    overflow: hidden;
  }

  .ai-chat-toggle-text {
    display: inline;
  }

  .ai-chat-tooltip,
  .ai-welcome-bubble {
    right: 1rem;
  }

  .ai-chat-container {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
  }

  .ai-chat-container.open {
    position: fixed;
  }

  .ai-chat-header {
    border-radius: 0;
  }

  .ai-info-box {
    font-size: 0.9rem;
  }
}

@media (max-width: 360px) {
  .ai-chat-toggle {
    left: 1rem;
    right: 1rem;
    justify-content: center;
    padding: 0.75rem 1rem;
  }

  .ai-chat-tooltip,
  .ai-welcome-bubble {
    display: none;
  }
}

/* Scrollbar Styling */
.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Message Content Formatting */
.ai-message-content strong {
  font-weight: 600;
  color: var(--text);
}

.ai-message-user .ai-message-content strong {
  color: white;
}

.ai-message-content small {
  opacity: 0.8;
  font-size: 0.875rem;
}

.ai-message-content br {
  line-height: 1.8;
}

