/* Riley Watson AI Assistant - Deep Navy Blue Theme (#002E48) */
/* Theme variables */
:root {
  --ai-primary: #002E48;
  --ai-primary-600: #003A5C;
  --ai-primary-700: #004670;
  --ai-primary-800: #001E30;
  --ai-accent: #0066CC;
  --ai-accent-light: #3399FF;
  --ai-surface: #ffffff;
  --ai-surface-2: #f8fafc;
  --ai-surface-3: #f1f5f9;
  --ai-text: #0f172a;
  --ai-text-muted: #475569;
  --ai-text-light: #64748b;
  --ai-border: #e2e8f0;
  --ai-border-light: #f1f5f9;
  --ai-shadow: 0 20px 50px rgba(0, 46, 72, 0.15);
  --ai-shadow-lg: 0 25px 60px rgba(0, 46, 72, 0.25);
  --ai-shadow-bubble: 0 12px 40px rgba(0, 46, 72, 0.3);
  --ai-gradient: linear-gradient(135deg, #002E48 0%, #004670 100%);
  --ai-gradient-hover: linear-gradient(135deg, #001E30 0%, #003A5C 100%);
  --ai-gradient-light: linear-gradient(135deg, #003A5C 0%, #0066CC 100%);
  --ai-radius-xl: 28px;
  --ai-radius-lg: 22px;
  --ai-radius-md: 18px;
  --ai-radius-sm: 14px;
  --ai-z: 2147483000;
}

/* Dark mode (opt-in if theme sets data-theme="dark" on html/body) */
html[data-theme="dark"] :root,
body[data-theme="dark"] :root {
  --ai-surface: #0f172a;
  --ai-surface-2: #1e293b;
  --ai-surface-3: #334155;
  --ai-text: #f1f5f9;
  --ai-text-muted: #cbd5e1;
  --ai-text-light: #94a3b8;
  --ai-border: #334155;
  --ai-border-light: #475569;
  --ai-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  --ai-shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.8);
}

/* Enhanced Luxury Bubble (launcher) */
#ai-chatbot-bubble {
  position: fixed !important;
  right: 40px !important;
  bottom: 40px !important;
  left: auto !important;
  top: auto !important;
  width: 68px !important;
  height: 68px !important;
  border: none;
  border-radius: 50%;
  background: var(--ai-gradient);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  box-shadow: var(--ai-shadow-lg);
  z-index: var(--ai-z);
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  transform: none !important;
  margin: 0 !important;
  float: none !important;
  overflow: hidden;
}

#ai-chatbot-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ai-gradient-hover);
  opacity: 0;
  transition: opacity 300ms ease;
  border-radius: 50%;
}

#ai-chatbot-bubble:hover {
  transform: translateY(-5px) scale(1.08);
  box-shadow: var(--ai-shadow-bubble), 0 0 30px rgba(0, 46, 72, 0.4);
  background: var(--ai-gradient-hover);
}

#ai-chatbot-bubble:hover::before {
  opacity: 1;
}

#ai-chatbot-bubble:active {
  transform: translateY(-2px) scale(1.02);
}

#ai-chatbot-bubble:focus-visible {
  outline: 3px solid var(--ai-accent-light);
  outline-offset: 3px;
}

/* Bubble icon */
#ai-chatbot-bubble .bubble-icon {
  position: relative;
  z-index: 2;
  font-weight: 600;
}

/* Enhanced Luxury Chat Window */
#ai-chatbot-window {
  position: fixed !important;
  right: 40px !important;
  bottom: 116px !important;
  left: auto !important;
  top: auto !important;
  width: 340px;
  height: 640px;
  display: none;
  flex-direction: column;
  background: var(--ai-surface);
  border: 2px solid var(--ai-border-light);
  border-radius: var(--ai-radius-xl);
  box-shadow: var(--ai-shadow-lg), 0 0 0 1px rgba(0, 46, 72, 0.05);
  overflow: hidden;
  z-index: var(--ai-z);
  backdrop-filter: blur(20px);
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

#ai-chatbot-window.open {
  display: flex;
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Enhanced Luxury Header */
#ai-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  background: var(--ai-gradient);
  color: #fff;
  position: relative;
  overflow: hidden;
}

#ai-chatbot-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  pointer-events: none;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  position: relative;
  z-index: 1;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

#ai-chatbot-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
}

#ai-chatbot-header .store-status {
  margin-top: 2px;
  font-size: 13px;
  opacity: 0.9;
  font-weight: 500;
}

/* Back button (moved to left) */
#ai-chatbot-back {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--ai-radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease;
  font-size: 16px;
  backdrop-filter: blur(10px);
}

#ai-chatbot-back:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(-2px);
}

/* Close button (right side) */
#ai-chatbot-close {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--ai-radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease;
  backdrop-filter: blur(10px);
}

#ai-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Enhanced Messages Area */
#ai-chatbot-messages {
  flex: 1;
  padding: 24px;
  background: var(--ai-surface-2);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  position: relative;
}

#ai-chatbot-messages::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, var(--ai-surface-2), transparent);
  pointer-events: none;
  z-index: 1;
}

/* Enhanced Message Bubbles */
.chatbot-message {
  max-width: 85%;
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.5;
  border-radius: var(--ai-radius-lg);
  color: var(--ai-text);
  word-wrap: break-word;
  word-break: break-word;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 200ms ease;
}

.chatbot-message:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.chatbot-message.user {
  align-self: flex-end;
  background: var(--ai-gradient);
  color: #fff;
  border-bottom-right-radius: 8px;
  font-weight: 500;
}

.chatbot-message.assistant {
  align-self: flex-start;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-bottom-left-radius: 8px;
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.08);
}

.chatbot-message.system {
  align-self: center;
  background: var(--ai-surface-3);
  color: var(--ai-text-muted);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--ai-radius-md);
  font-style: italic;
  border: 1px solid var(--ai-border-light);
}

/* Enhanced Links in messages */
.chatbot-link {
  color: var(--ai-accent);
  text-decoration: none;
  transition: all 200ms ease;
  font-weight: 600;
  border-bottom: 2px solid var(--ai-accent);
  padding-bottom: 1px;
}

.chatbot-link:hover {
  color: var(--ai-primary);
  border-bottom-color: var(--ai-primary);
  transform: translateY(-1px);
}

.chatbot-link:visited {
  color: var(--ai-accent);
  border-bottom-color: var(--ai-accent);
}

/* Typing indicator */
.typing-indicator {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  padding: 8px 10px;
  border-radius: 16px;
  border-bottom-left-radius: 6px;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--ai-text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: ai-bounce 1.3s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
#ai-chatbot-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--ai-surface);
  border-top: 1px solid var(--ai-border);
}

#ai-chatbot-message-input {
  flex: 1;
  resize: none;
  min-height: 20px;
  max-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--ai-border);
  border-radius: 20px;
  font: inherit;
  color: var(--ai-text);
  background: var(--ai-surface);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

#ai-chatbot-message-input:focus {
  border-color: var(--ai-primary);
  box-shadow: 0 0 0 3px rgba(10, 124, 255, 0.12);
}

#ai-chatbot-send-button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  color: #fff;
  background: var(--ai-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

#ai-chatbot-send-button:hover:not(:disabled) {
  background: var(--ai-primary-600);
  transform: translateY(-1px);
}

#ai-chatbot-send-button:disabled {
  background: #c7cdd6;
  cursor: not-allowed;
  transform: none;
}

/* Scrollbar styling (Webkit) */
#ai-chatbot-messages::-webkit-scrollbar { width: 8px; }
#ai-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#ai-chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(107, 114, 128, 0.4);
  border-radius: 999px;
}
#ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 114, 128, 0.6);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  #ai-chatbot-bubble,
  #ai-chatbot-send-button {
    transition: none;
  }
  #ai-chatbot-messages { scroll-behavior: auto; }
  .typing-dots span { animation: none; opacity: 0.7; }
}

/* Enhanced Responsiveness - NO FULL SCREEN ON MOBILE */
@media (max-width: 768px) {
  #ai-chatbot-window {
    right: 20px;
    left: 40px;
    bottom: 85px;
    width: auto;
    height: 70vh;
    max-height: 580px;
    min-height: 450px;
  }
  #ai-chatbot-bubble {
    right: 20px !important;
    bottom: 20px !important;
    left: auto !important;
    top: auto !important;
  }
  
  #ai-chatbot-messages {
    padding: 16px;
    gap: 12px;
  }
  
  .chatbot-message {
    font-size: 14px;
    padding: 12px 16px;
  }
}

@media (max-width: 480px) {
  #ai-chatbot-window {
    right: 16px;
    left: 30px;
    bottom: 80px;
    width: auto;
    height: 75vh;
    max-height: 520px;
    min-height: 400px;
    border-radius: var(--ai-radius-lg);
  }
  
  #ai-chatbot-header {
    padding: 16px 20px;
  }
  
  #ai-chatbot-header h3 {
    font-size: 15px;
  }
  
  #ai-chatbot-bubble {
    right: 16px !important;
    bottom: 16px !important;
    left: auto !important;
    top: auto !important;
    width: 60px;
    height: 60px;
    font-size: 22px;
  }
}

/* High-contrast focus for accessibility */
#ai-chatbot-window :focus-visible {
  outline: 2px solid var(--ai-primary);
  outline-offset: 2px;
}

/* RTL support (auto if parent sets direction: rtl) */
[dir="rtl"] #ai-chatbot-window { right: auto; left: 20px; }
[dir="rtl"] .chatbot-message.user { align-self: flex-start; border-bottom-left-radius: 6px; border-bottom-right-radius: 16px; }
[dir="rtl"] .chatbot-message.assistant { align-self: flex-end; border-bottom-right-radius: 6px; border-bottom-left-radius: 16px; }

/* Enhanced Quick Reply Buttons */
.chatbot-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
}

.chatbot-quick-reply-btn {
  background: var(--ai-surface);
  border: 2px solid var(--ai-accent);
  border-radius: var(--ai-radius-md);
  color: var(--ai-accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  padding: 10px 16px;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  backdrop-filter: blur(10px);
}

.chatbot-quick-reply-btn:hover {
  background: var(--ai-gradient);
  color: #fff;
  border-color: var(--ai-primary);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(30, 58, 138, 0.3);
}

.chatbot-quick-reply-btn:active {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 4px 15px rgba(30, 58, 138, 0.25);
}

.chatbot-quick-reply-btn:focus-visible {
  outline: 3px solid var(--ai-accent-light);
  outline-offset: 2px;
}

/* Mobile responsive quick replies */
@media (max-width: 480px) {
  .chatbot-quick-replies {
    gap: 6px;
  }
  
  .chatbot-quick-reply-btn {
    font-size: 12px;
    padding: 6px 10px;
    max-width: 150px;
  }
}
