/* Updated CSS Variables to match your theme system */
:root {
  --bg-color: #ffffff;
  --text-color: #2c3e50;
  --accent-color: #3498db;
  --navbar-bg: rgba(255, 255, 255, 0.95);
  --navbar-border: rgba(0, 0, 0, 0.1);
  --hover-bg: rgba(52, 152, 219, 0.1);
  --active-bg: rgba(52, 152, 219, 0.15);
  --hamburger-color: #2c3e50;
  --shadow-color: rgba(0, 0, 0, 0.1);
  
  /* Chatbot specific variables */
  --chatbot-primary: #3498db;
  --chatbot-secondary: #2980b9;
  --chatbot-success: #27ae60;
  --chatbot-glass-bg: rgba(255, 255, 255, 0.85);
  --chatbot-border: rgba(52, 152, 219, 0.2);
  --chatbot-input-bg: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --text-color: #e4e4e7;
  --accent-color: #60a5fa;
  --navbar-bg: rgba(26, 26, 26, 0.95);
  --navbar-border: rgba(255, 255, 255, 0.1);
  --hover-bg: rgba(96, 165, 250, 0.1);
  --active-bg: rgba(96, 165, 250, 0.15);
  --hamburger-color: #e4e4e7;
  --shadow-color: rgba(0, 0, 0, 0.3);
  
  /* Chatbot dark theme variables */
  --chatbot-primary: #60a5fa;
  --chatbot-secondary: #3b82f6;
  --chatbot-success: #10b981;
  --chatbot-glass-bg: rgba(26, 26, 26, 0.85);
  --chatbot-border: rgba(96, 165, 250, 0.3);
  --chatbot-input-bg: rgba(26, 26, 26, 0.9);
}

/* Chatbot Button - Clean modern design with theme colors */
.ai-chatbot-btn {
  /* Positioning */
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;

  /* Size and shape */
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--chatbot-border);
  outline: none;
  cursor: pointer;

  /* Background - Clean gradient with theme colors */
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  color: white;

  /* Font and icon */
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Shadows - Subtle elevation */
  box-shadow: 
    0 4px 20px var(--shadow-color),
    0 0 0 0 rgba(var(--chatbot-primary), 0.4);

  /* Transitions */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(0) scale(1);
}

/* Hover effects - Smooth elevation */
.ai-chatbot-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 
    0 8px 30px var(--shadow-color),
    0 0 0 8px rgba(var(--chatbot-primary), 0.1);
}

/* Active state */
.ai-chatbot-btn:active {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 
    0 4px 20px var(--shadow-color),
    0 0 0 4px rgba(var(--chatbot-primary), 0.2);
}

/* Focus state */
.ai-chatbot-btn:focus {
  outline: 3px solid var(--accent-color);
  outline-offset: 4px;
}

/* Icon animation */
.ai-chatbot-btn i {
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ai-chatbot-btn:hover i {
  transform: rotate(15deg) scale(1.1);
}

/* Responsive design */
@media (max-width: 768px) {
  .ai-chatbot-btn {
    width: 56px;
    height: 56px;
    font-size: 20px;
    bottom: 20px;
    right: 20px;
  }
}

@media (max-width: 480px) {
  .ai-chatbot-btn {
    width: 48px;
    height: 48px;
    font-size: 18px;
    bottom: 16px;
    right: 16px;
  }
}

/* Notification badge - Theme aware */
.ai-chatbot-btn::before {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: var(--chatbot-success);
  border-radius: 50%;
  border: 2px solid var(--bg-color);
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s ease;
}

/* Show notification badge */
.ai-chatbot-btn.has-notification::before {
  opacity: 1;
  transform: scale(1);
  animation: notificationPulse 2s ease-in-out infinite;
}

@keyframes notificationPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

/* Chatbot Container - Modern glassmorphism with theme colors */
.chatbot-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: var(--chatbot-glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  border-radius: 16px;
  box-shadow: 
    0 20px 40px var(--shadow-color),
    0 0 0 1px var(--chatbot-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2000;
}

/* Show chatbot animation */
.chatbot-container.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Chatbot Header - Clean gradient with theme colors */
.chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 16px 16px 0 0;
  position: relative;
}

.chatbot-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  pointer-events: none;
  border-radius: 16px 16px 0 0;
}

.chatbot-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Close Button - Theme aware */
.chatbot-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.chatbot-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

/* Messages Container - Theme aware backdrop */
.chatbot-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-color);
}

/* Custom scrollbar - Theme colors */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: var(--hover-bg);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-secondary);
}

/* Message Bubbles - Clean theme-aware styling */
.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  animation: messagePop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* Bot Message - Theme primary color */
.bot-message {
  align-self: flex-start;
  background: var(--accent-color);
  color: white;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(var(--chatbot-primary), 0.2);
}

.bot-message::before {
  content: '🤖';
  position: absolute;
  left: -36px;
  top: 12px;
  font-size: 18px;
  background: var(--chatbot-glass-bg);
  border: 2px solid var(--chatbot-border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--shadow-color);
}

/* User Message - Neutral theme color */
.user-message {
  align-self: flex-end;
  background: var(--hover-bg);
  color: var(--text-color);
  border-bottom-right-radius: 6px;
  border: 1px solid var(--chatbot-border);
}

.user-message::before {
  content: '👤';
  position: absolute;
  right: -36px;
  top: 12px;
  font-size: 18px;
  background: var(--chatbot-glass-bg);
  border: 2px solid var(--chatbot-border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--shadow-color);
}

/* Input Area - Theme aware */
.chatbot-input {
  padding: 20px 24px;
  background: var(--bg-color);
  border-top: 1px solid var(--chatbot-border);
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Input Field - Theme styling */
.chatbot-input input {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid var(--chatbot-border);
  border-radius: 24px;
  outline: none;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--chatbot-input-bg);
  color: var(--text-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-input input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(var(--chatbot-primary), 0.1);
}

.chatbot-input input::placeholder {
  color: var(--text-color);
  opacity: 0.6;
}

/* Send Button - Theme primary */
.chatbot-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(var(--chatbot-primary), 0.3);
}

.chatbot-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(var(--chatbot-primary), 0.4);
}

.chatbot-send-btn:active {
  transform: scale(0.98);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Typing Indicator - Theme aware */
.typing-indicator {
  align-self: flex-start;
  background: var(--accent-color);
  color: white;
  border-radius: 18px 18px 18px 6px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: messagePop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(var(--chatbot-primary), 0.2);
}

.typing-indicator::before {
  content: '🤖';
  position: absolute;
  left: -36px;
  top: 12px;
  font-size: 18px;
  background: var(--chatbot-glass-bg);
  border: 2px solid var(--chatbot-border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--shadow-color);
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
  animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Animations */
@keyframes messagePop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes typingDots {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* Responsive Design */
@media (max-width: 768px) {
  .chatbot-container {
    width: calc(100vw - 32px);
    height: calc(100vh - 140px);
    right: 16px;
    bottom: 80px;
    border-radius: 12px;
  }
  
  .chatbot-header {
    border-radius: 12px 12px 0 0;
  }
}

@media (max-width: 480px) {
  .chatbot-container {
    width: calc(100vw - 16px);
    height: calc(100vh - 120px);
    right: 8px;
    bottom: 70px;
    border-radius: 8px;
  }
  
  .chatbot-header {
    padding: 16px 20px;
    border-radius: 8px 8px 0 0;
  }
  
  .chatbot-header h3 {
    font-size: 16px;
  }
  
  .chatbot-messages {
    padding: 20px;
  }
  
  .chatbot-input {
    padding: 16px 20px;
  }
}