/**
 * AI Chatbot Widget Styles
 *
 * This stylesheet provides all the visual styling for the chatbot widget.
 * It includes:
 * - Floating chat bubble button with avatar
 * - Collapsible chat window
 * - Message bubbles and conversation styling
 * - Animations and transitions
 * - Responsive design for mobile devices
 *
 * Color scheme can be customized by changing CSS variables below
 */

/* ============================================
   CSS VARIABLES (CUSTOMIZATION)
   ============================================ */
:root {
  /* Primary brand colors */
  --chatbot-primary-color: #2563eb;        /* Main brand color (blue) */
  --chatbot-primary-hover: #1d4ed8;        /* Darker blue for hover states */
  --chatbot-primary-light: #dbeafe;        /* Light blue for backgrounds */

  /* Neutral colors */
  --chatbot-bg-color: #ffffff;             /* White background */
  --chatbot-text-color: #1f2937;           /* Dark gray text */
  --chatbot-text-secondary: #6b7280;       /* Medium gray for secondary text */
  --chatbot-border-color: #e5e7eb;         /* Light gray borders */

  /* Message colors */
  --chatbot-user-msg-bg: #2563eb;          /* User message background (blue) */
  --chatbot-user-msg-text: #ffffff;        /* User message text (white) */
  --chatbot-bot-msg-bg: #f3f4f6;           /* Bot message background (light gray) */
  --chatbot-bot-msg-text: #1f2937;         /* Bot message text (dark gray) */

  /* Status colors */
  --chatbot-online-color: #10b981;         /* Green for online status */
  --chatbot-error-bg: #fee2e2;             /* Light red for error messages */
  --chatbot-error-text: #991b1b;           /* Dark red for error text */

  /* Sizing */
  --chatbot-bubble-size: 70px;             /* Chat bubble button size */
  --chatbot-window-width: 380px;           /* Chat window width */
  --chatbot-window-height: 600px;          /* Chat window height */
  --chatbot-border-radius: 16px;           /* Rounded corners */

  /* Spacing */
  --chatbot-spacing-xs: 4px;
  --chatbot-spacing-sm: 8px;
  --chatbot-spacing-md: 16px;
  --chatbot-spacing-lg: 24px;

  /* Shadows */
  --chatbot-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --chatbot-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --chatbot-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);

  /* Z-index (ensures chatbot appears above other content) */
  --chatbot-z-index: 9999;
}


/* ============================================
   MAIN WIDGET CONTAINER
   ============================================ */
#ai-chatbot-widget {
  /* Position in bottom-right corner */
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--chatbot-z-index);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}


/* ============================================
   FLOATING CHAT BUBBLE BUTTON
   ============================================ */
.chatbot-bubble {
  /* Size and shape */
  width: var(--chatbot-bubble-size);
  height: var(--chatbot-bubble-size);
  border-radius: 50%;

  /* Positioning */
  position: relative;

  /* Styling */
  background: var(--chatbot-primary-color);
  border: 3px solid #ffffff;
  box-shadow: var(--chatbot-shadow-lg);
  cursor: pointer;

  /* Remove default button styles */
  outline: none;
  padding: 0;

  /* Animation */
  transition: transform 0.3s ease, box-shadow 0.3s ease;

  /* Ensure content is positioned correctly */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Hover effect on bubble */
.chatbot-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

/* Active (clicked) state */
.chatbot-bubble:active {
  transform: scale(0.95);
}

/* Avatar image inside bubble */
.chatbot-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
}

.chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* "Ask Me Anything" text overlay */
.chatbot-prompt-text {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);

  /* Styling */
  background: var(--chatbot-primary-color);
  color: white;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--chatbot-shadow-md);

  /* Animation */
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

/* Show text on hover */
.chatbot-bubble:hover .chatbot-prompt-text {
  opacity: 1;
  transform: translateX(-50%) translateY(5px);
}

/* Notification badge (unread message count) */
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;

  /* Styling */
  background: #ef4444;
  color: white;
  border: 2px solid white;
  border-radius: 50%;

  /* Size */
  min-width: 24px;
  height: 24px;
  padding: 0 6px;

  /* Text */
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Animation */
  animation: pulse-badge 2s infinite;
}

/* Pulse animation for notification badge */
@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}


/* ============================================
   CHAT WINDOW
   ============================================ */
.chatbot-window {
  /* Size and position */
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: var(--chatbot-window-width);
  height: var(--chatbot-window-height);
  max-height: calc(100vh - 120px);

  /* Styling */
  background: var(--chatbot-bg-color);
  border-radius: var(--chatbot-border-radius);
  box-shadow: var(--chatbot-shadow-lg);

  /* Layout */
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Animation */
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

/* Show chat window when not hidden */
.chatbot-window:not(.hidden) {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}


/* ============================================
   CHAT HEADER
   ============================================ */
.chatbot-header {
  /* Styling */
  background: var(--chatbot-primary-color);
  color: white;
  padding: var(--chatbot-spacing-md);

  /* Layout */
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;

  /* Border */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-header-content {
  display: flex;
  align-items: center;
  gap: var(--chatbot-spacing-md);
  flex: 1;
}

/* Avatar in header */
.chatbot-header-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.chatbot-header-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Online status indicator */
.status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--chatbot-primary-color);
}

.status-indicator.online {
  background: var(--chatbot-online-color);
  animation: pulse-online 2s infinite;
}

@keyframes pulse-online {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Header text */
.chatbot-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chatbot-status {
  margin: 2px 0 0 0;
  font-size: 12px;
  opacity: 0.9;
}

/* Header action buttons */
.chatbot-header-actions {
  display: flex;
  gap: var(--chatbot-spacing-sm);
}

.icon-btn {
  /* Styling */
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;

  /* Size */
  width: 32px;
  height: 32px;
  border-radius: 8px;

  /* Layout */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;

  /* Animation */
  transition: background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}


/* ============================================
   WELCOME MESSAGE
   ============================================ */
.chatbot-welcome {
  padding: var(--chatbot-spacing-lg);
  text-align: center;
  background: linear-gradient(to bottom, var(--chatbot-primary-light), transparent);
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: var(--chatbot-spacing-md);
}

.chatbot-welcome h4 {
  margin: 0 0 var(--chatbot-spacing-sm) 0;
  color: var(--chatbot-text-color);
  font-size: 18px;
}

.chatbot-welcome p {
  margin: 0 0 var(--chatbot-spacing-lg) 0;
  color: var(--chatbot-text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

/* Quick question buttons */
.quick-questions {
  margin-top: var(--chatbot-spacing-md);
}

.quick-questions p {
  font-size: 13px;
  font-weight: 600;
  color: var(--chatbot-text-color);
  margin-bottom: var(--chatbot-spacing-sm);
}

.quick-question-btn {
  /* Styling */
  background: white;
  border: 1px solid var(--chatbot-border-color);
  color: var(--chatbot-text-color);

  /* Layout */
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: var(--chatbot-spacing-sm);
  border-radius: 8px;

  /* Text */
  text-align: left;
  font-size: 13px;
  cursor: pointer;

  /* Animation */
  transition: all 0.2s ease;
}

.quick-question-btn:hover {
  background: var(--chatbot-primary-light);
  border-color: var(--chatbot-primary-color);
  transform: translateX(4px);
}


/* ============================================
   MESSAGES CONTAINER
   ============================================ */
.chatbot-messages {
  /* Layout */
  flex: 1;
  overflow-y: auto;
  padding: var(--chatbot-spacing-md);

  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--chatbot-border-color) transparent;
}

/* Webkit scrollbar styling (Chrome, Safari, Edge) */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-border-color);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-text-secondary);
}


/* ============================================
   MESSAGE BUBBLES
   ============================================ */
.message {
  display: flex;
  gap: var(--chatbot-spacing-sm);
  margin-bottom: var(--chatbot-spacing-md);

  /* Animation */
  animation: slideIn 0.3s ease;
}

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

/* Bot message (from AI) */
.bot-message {
  flex-direction: row;
}

/* User message (from visitor) */
.user-message {
  flex-direction: row-reverse;
}

/* Message avatar */
.message-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Message content bubble */
.message-content {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-content p {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

/* Bot message styling */
.bot-message .message-content p {
  background: var(--chatbot-bot-msg-bg);
  color: var(--chatbot-bot-msg-text);
  border-bottom-left-radius: 4px;
}

/* User message styling */
.user-message .message-content p {
  background: var(--chatbot-user-msg-bg);
  color: var(--chatbot-user-msg-text);
  border-bottom-right-radius: 4px;
}

/* Message timestamp */
.message-time {
  font-size: 11px;
  color: var(--chatbot-text-secondary);
  padding: 0 8px;
}

.user-message .message-time {
  text-align: right;
}


/* ============================================
   TYPING INDICATOR
   ============================================ */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: var(--chatbot-spacing-sm);
  padding: 0 var(--chatbot-spacing-md) var(--chatbot-spacing-md);

  /* Animation */
  opacity: 0;
  transition: opacity 0.3s ease;
}

.typing-indicator:not(.hidden) {
  opacity: 1;
}

.typing-avatar {
  width: 32px;
  height: 32px;
}

.typing-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Animated typing dots */
.typing-dots {
  background: var(--chatbot-bot-msg-bg);
  padding: 12px 16px;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--chatbot-text-secondary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

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


/* ============================================
   INPUT AREA
   ============================================ */
.chatbot-input-container {
  /* Styling */
  background: var(--chatbot-bg-color);
  border-top: 1px solid var(--chatbot-border-color);
  padding: var(--chatbot-spacing-md);
  flex-shrink: 0;
}

/* Error message display */
.chatbot-error {
  background: var(--chatbot-error-bg);
  color: var(--chatbot-error-text);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: var(--chatbot-spacing-sm);
  display: flex;
  align-items: center;
  gap: var(--chatbot-spacing-sm);
  font-size: 13px;

  /* Animation */
  animation: slideIn 0.3s ease;
}

.chatbot-error svg {
  flex-shrink: 0;
}

.error-close-btn {
  /* Styling */
  background: transparent;
  border: none;
  color: var(--chatbot-error-text);

  /* Size */
  width: 20px;
  height: 20px;

  /* Text */
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  margin-left: auto;

  /* Animation */
  transition: opacity 0.2s ease;
}

.error-close-btn:hover {
  opacity: 0.7;
}

/* Input form */
.chatbot-input-form {
  display: flex;
  gap: var(--chatbot-spacing-sm);
  margin-bottom: var(--chatbot-spacing-xs);
}

/* Text input field */
.chatbot-input {
  /* Layout */
  flex: 1;
  padding: 12px 16px;

  /* Styling */
  background: var(--chatbot-bg-color);
  border: 1px solid var(--chatbot-border-color);
  border-radius: 24px;

  /* Text */
  font-size: 14px;
  color: var(--chatbot-text-color);

  /* Remove default styles */
  outline: none;

  /* Animation */
  transition: border-color 0.2s ease;
}

.chatbot-input:focus {
  border-color: var(--chatbot-primary-color);
}

.chatbot-input::placeholder {
  color: var(--chatbot-text-secondary);
}

/* Send button */
.chatbot-send-btn {
  /* Size */
  width: 44px;
  height: 44px;
  flex-shrink: 0;

  /* Styling */
  background: var(--chatbot-primary-color);
  border: none;
  border-radius: 50%;
  color: white;

  /* Layout */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;

  /* Animation */
  transition: background 0.2s ease, transform 0.1s ease;
}

.chatbot-send-btn:hover {
  background: var(--chatbot-primary-hover);
}

.chatbot-send-btn:active {
  transform: scale(0.95);
}

.chatbot-send-btn:disabled {
  background: var(--chatbot-border-color);
  cursor: not-allowed;
}

/* Character counter */
.character-counter {
  font-size: 11px;
  color: var(--chatbot-text-secondary);
  text-align: right;
  margin-bottom: var(--chatbot-spacing-xs);
}

/* Footer */
.chatbot-footer {
  text-align: center;
  font-size: 11px;
  color: var(--chatbot-text-secondary);
}

.powered-by strong {
  color: var(--chatbot-primary-color);
}


/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
  display: none !important;
}


/* ============================================
   RESPONSIVE DESIGN (MOBILE)
   ============================================ */
@media (max-width: 480px) {
  #ai-chatbot-widget {
    /* Full screen on mobile */
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
  }

  .chatbot-bubble {
    /* Smaller bubble on mobile */
    width: 60px;
    height: 60px;
    bottom: 16px;
    right: 16px;
    position: fixed;
  }

  .chatbot-window {
    /* Full screen chat window on mobile */
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .chatbot-window:not(.hidden) {
    position: fixed;
    top: 0;
    left: 0;
  }
}


/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--chatbot-primary-color);
  outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
