/* ================================================== */
/*  AI CHATBOT STYLES - Paramount Behavior
/* ================================================== */

:root {
  --chat-primary: #ff6f61;
  --chat-primary-dark: #e54b4b;
  --chat-width: 400px;
  --chat-height: 600px;
  --chat-bottom: 90px; /* Adjusted to avoid button conflicts */
  --chat-right: 20px;
  --chat-border-radius: 20px;
  --chat-shadow: 0 10px 40px rgba(0,0,0,0.15);
  --chat-bg: #ffffff;
  --chat-header-height: 72px;
  --chat-input-height: 72px;
}

/* Main Chat Window */
.ai-chat-window {
  position: fixed;
  bottom: var(--chat-bottom);
  right: var(--chat-right);
  width: var(--chat-width);
  height: var(--chat-height);
  background: var(--chat-bg);
  border-radius: var(--chat-border-radius);
  box-shadow: var(--chat-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 100000;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-window.open {
  display: flex;
  animation: slideUp 0.3s ease;
}

.ai-chat-window.minimized {
  height: var(--chat-header-height);
  cursor: pointer;
}

.ai-chat-window.minimized .ai-messages,
.ai-chat-window.minimized .ai-quick-replies,
.ai-chat-window.minimized .ai-input-container {
  display: none;
}

/* Animations */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Chat Header */
.ai-chat-header {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--chat-header-height);
  position: relative;
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.ai-chat-header-info img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  padding: 2px;
  object-fit: contain;
}

.ai-chat-header-info > div {
  flex: 1;
}

.ai-chat-header-info h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-chat-header-info span {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Status Indicators */
.ai-status-dot {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}

.ai-status-dot.offline {
  background: #ef4444;
  animation: none;
}

.ai-status-dot.typing {
  background: #fbbf24;
}

/* Notification Badge */
.ai-unread-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: white;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: bold;
  min-width: 18px;
  text-align: center;
  animation: shake 0.5s;
}

/* Header Buttons */
.ai-header-buttons {
  display: flex;
  gap: 8px;
}

.ai-minimize-btn,
.ai-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: white;
}

.ai-minimize-btn:hover,
.ai-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Message Preview (for minimized state) */
.ai-message-preview {
  position: absolute;
  bottom: -30px;
  left: 20px;
  right: 60px;
  background: white;
  color: #4b5563;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-window.minimized .ai-message-preview {
  display: block;
}

/* Messages Container */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f9fafb;
  scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.ai-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Message Bubbles */
.ai-message {
  margin-bottom: 16px;
  animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-message.user {
  text-align: right;
}

.ai-message-content {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 18px;
  max-width: 80%;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 14px;
  position: relative;
}

.ai-message.user .ai-message-content {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  border-bottom-right-radius: 6px;
}

.ai-message.bot .ai-message-content {
  background: white;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 6px;
}

/* Markdown Support */
.ai-message-content strong {
  font-weight: 600;
}

.ai-message-content em {
  font-style: italic;
}

.ai-message-content code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.ai-message-content a {
  color: var(--chat-primary);
  text-decoration: underline;
}

.ai-message-content ul,
.ai-message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-message-content li {
  margin: 4px 0;
}

/* Message Time */
.ai-message-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  display: block;
}

/* Typing Indicator */
.ai-typing {
  padding: 10px 14px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  display: inline-block;
  border-bottom-left-radius: 6px;
}

.ai-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  margin: 0 2px;
  animation: typingBounce 1.4s infinite;
}

.ai-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* Quick Replies */
.ai-quick-replies {
  padding: 12px 20px;
  background: white;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
  min-height: 52px;
}

.ai-quick-replies::-webkit-scrollbar {
  display: none;
}

.ai-quick-reply {
  padding: 8px 14px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: inherit;
}

.ai-quick-reply:hover {
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
}

.ai-quick-reply:focus {
  outline: 2px solid var(--chat-primary);
  outline-offset: 2px;
}

/* Input Container */
.ai-input-container {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: var(--chat-input-height);
}

.ai-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.ai-input:focus {
  border-color: var(--chat-primary-dark);
}

.ai-input::placeholder {
  color: #9ca3af;
}

/* Send Button */
.ai-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
}

.ai-send-btn:hover:not(:disabled) {
  transform: scale(1.1);
}

.ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Model Badge */
.ai-model-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 12px;
  margin-top: 4px;
  display: inline-block;
}

.ai-model-badge.gpt {
  background: #e0f2fe;
  color: #0369a1;
}

.ai-model-badge.claude {
  background: #fef3c7;
  color: #92400e;
}

.ai-model-badge.qwen {
  background: #dcfce7;
  color: #166534;
}

/* Dark Mode Support */
body.dark .ai-chat-window {
  background: #1f2937;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

body.dark .ai-messages {
  background: #111827;
}

body.dark .ai-message.bot .ai-message-content {
  background: #374151;
  color: #f3f4f6;
  border-color: #4b5563;
}

body.dark .ai-quick-replies {
  background: #1f2937;
  border-top-color: #374151;
}

body.dark .ai-quick-reply {
  background: #374151;
  color: #d1d5db;
  border-color: #4b5563;
}

body.dark .ai-input-container {
  background: #1f2937;
  border-top-color: #374151;
}

body.dark .ai-input {
  background: #374151;
  color: #f3f4f6;
  border-color: #4b5563;
}

body.dark .ai-input::placeholder {
  color: #6b7280;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .ai-chat-window {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    --chat-bottom: 0;
    --chat-right: 0;
  }

  .ai-chat-window.minimized {
    width: calc(100vw - 30px);
    height: var(--chat-header-height);
    bottom: 15px;
    right: 15px;
    border-radius: var(--chat-border-radius);
  }

  .ai-message-content {
    max-width: 85%;
  }

  /* Adjust input for mobile keyboard */
  .ai-input-container {
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }
}

/* Accessibility */
.ai-chat-window:focus-visible,
.ai-quick-reply:focus-visible,
.ai-input:focus-visible,
.ai-send-btn:focus-visible {
  outline: 2px solid var(--chat-primary);
  outline-offset: 2px;
}

/* Loading State */
.ai-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.ai-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--chat-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Sound Toggle */
.ai-sound-toggle {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  color: white;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.ai-sound-toggle:hover {
  opacity: 1;
}

/* Error State */
.ai-error-message {
  background: #fef2f2;
  color: #dc2626;
  padding: 12px;
  border-radius: 8px;
  margin: 12px;
  font-size: 13px;
  border: 1px solid #fecaca;
}

/* Success State */
.ai-success-message {
  background: #f0fdf4;
  color: #16a34a;
  padding: 12px;
  border-radius: 8px;
  margin: 12px;
  font-size: 13px;
  border: 1px solid #bbf7d0;
}