/* Vivy AI Chatbot Styles */
:root {
  --vivy-primary: #8b5cf6;
  --vivy-primary-dark: #7c3aed;
  --vivy-secondary: #1e293b;
  --vivy-background: #0f172a;
  --vivy-surface: #1e293b;
  --vivy-surface-light: #334155;
  --vivy-text: #f8fafc;
  --vivy-text-muted: #94a3b8;
  --vivy-border: #334155;
  --vivy-success: #10b981;
  --vivy-error: #ef4444;
  --vivy-shadow: rgba(0, 0, 0, 0.25);
  --vivy-glow: rgba(139, 92, 246, 0.3);
}

/* Chatbot Bubble */
.vivy-chatbot-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--vivy-primary), var(--vivy-primary-dark));
  border-radius: 50%;
  cursor: pointer;
  z-index: 9999; /* Increased z-index */
  box-shadow: 0 8px 32px var(--vivy-shadow), 0 0 0 0 var(--vivy-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; /* Explicitly set display */
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.vivy-chatbot-bubble:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 40px var(--vivy-shadow), 0 0 20px var(--vivy-glow);
}

.vivy-chatbot-bubble.pulse {
  animation: vivyPulse 2s infinite;
}

@keyframes vivyPulse {
  0%,
  100% {
    box-shadow: 0 8px 32px var(--vivy-shadow), 0 0 0 0 var(--vivy-glow);
  }
  50% {
    box-shadow: 0 8px 32px var(--vivy-shadow), 0 0 20px var(--vivy-glow);
  }
}

.vivy-bubble-icon {
  font-size: 24px;
  color: white;
  transition: transform 0.3s ease;
}

.vivy-chatbot-bubble:hover .vivy-bubble-icon {
  transform: scale(1.1);
}

/* Notification Badge */
.vivy-notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: var(--vivy-error);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  border: 2px solid var(--vivy-background);
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-4px);
  }
  60% {
    transform: translateY(-2px);
  }
}

/* Chatbot Modal */
.vivy-chatbot-modal {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  height: 600px;
  background: var(--vivy-background);
  border-radius: 16px;
  box-shadow: 0 20px 60px var(--vivy-shadow), 0 0 0 1px var(--vivy-border);
  z-index: 99999; /* Increased z-index to be very high */
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex; /* Added */
  flex-direction: column; /* Added */
}

.vivy-chat-messages {
  flex: 1; /* Added */
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vivy-chatbot-modal.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Modal Header */
.vivy-modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--vivy-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--vivy-surface), var(--vivy-surface-light));
  border-radius: 16px 16px 0 0;
}

.vivy-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vivy-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--vivy-primary), var(--vivy-primary-dark));
  border-radius: 50%; /* This should make it rounded */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: white;
  position: relative;
  overflow: hidden; /* Ensure content inside is clipped to the circle */
}

.vivy-avatar::after {
  content: "";
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: var(--vivy-success);
  border-radius: 50%;
  border: 2px solid var(--vivy-background);
}

.vivy-bot-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--vivy-text);
}

.vivy-bot-status {
  font-size: 12px;
  color: var(--vivy-text-muted);
  margin: 2px 0 0 0;
}

.vivy-close-btn {
  background: none;
  border: none;
  color: var(--vivy-text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.vivy-close-btn:hover {
  background: var(--vivy-surface-light);
  color: var(--vivy-text);
  border: 1px solid var(--vivy-border); /* Added border on hover */
}

/* Chat Messages Area */
/* This rule is already modified above, removing max-height */


.vivy-chat-messages::-webkit-scrollbar {
  width: 8px; /* Increased width */
}

.vivy-chat-messages::-webkit-scrollbar-track {
  background: var(--vivy-surface);
  border-radius: 4px; /* Slightly more rounded */
}

.vivy-chat-messages::-webkit-scrollbar-thumb {
  background: var(--vivy-border);
  border-radius: 4px; /* Slightly more rounded */
  border: 2px solid var(--vivy-surface); /* Added border for better contrast */
}

.vivy-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--vivy-primary); /* Changed hover color */
}

/* Message Bubbles */
.vivy-message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.3s ease-out;
}

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

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

.vivy-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden; /* Ensure content inside is clipped to the circle */
}

.vivy-message.bot .vivy-message-avatar {
  background: linear-gradient(135deg, var(--vivy-primary), var(--vivy-primary-dark));
  color: white;
}

.vivy-message.user .vivy-message-avatar {
  background: var(--vivy-surface-light);
  color: var(--vivy-text);
}

.vivy-message-content {
  background: var(--vivy-surface);
  padding: 12px 16px;
  border-radius: 16px;
  max-width: 280px;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.5;
  color: var(--vivy-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Added subtle shadow */
}

.vivy-message.user .vivy-message-content {
  background: var(--vivy-primary);
  color: white;
  border-radius: 16px 16px 4px 16px;
}

.vivy-message.bot .vivy-message-content {
  border-radius: 16px 16px 16px 4px;
}

/* Typing Indicator */
.vivy-typing-indicator {
  display: flex;
  gap: 12px;
  padding: 0 20px;
}

.vivy-typing-content {
  background: var(--vivy-surface);
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.vivy-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--vivy-text-muted);
  border-radius: 50%;
  animation: typingPulse 1.4s infinite ease-in-out;
}

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

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

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

/* Input Area */
.vivy-input-area {
  padding: 20px;
  border-top: 1px solid var(--vivy-border);
  background: var(--vivy-surface);
  border-radius: 0 0 16px 16px;
}

.vivy-input-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.vivy-input-wrapper {
  flex: 1;
  position: relative;
}

.vivy-message-input {
  width: 100%;
  background: var(--vivy-background);
  border: 1px solid var(--vivy-border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--vivy-text);
  font-size: 14px;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease; /* Added box-shadow to transition */
}

.vivy-message-input:focus {
  outline: none;
  border-color: var(--vivy-primary);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2); /* More prominent shadow */
}

.vivy-message-input::placeholder {
  color: var(--vivy-text-muted);
}

.vivy-send-btn {
  background: var(--vivy-primary);
  border: none;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  font-size: 16px;
}

.vivy-send-btn:hover:not(:disabled) {
  background: var(--vivy-primary-dark);
  transform: translateY(-1px);
}

.vivy-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Welcome Message */
.vivy-welcome-message {
  text-align: center;
  padding: 30px 15px; /* Adjusted padding */
  color: var(--vivy-text-muted);
}

.vivy-welcome-message .vivy-avatar {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px; /* Adjusted margin */
  font-size: 24px;
}

.vivy-welcome-message h3 {
  margin: 0 0 6px 0; /* Adjusted margin */
  color: var(--vivy-text);
  font-size: 18px;
}

.vivy-welcome-message p {
  margin: 0;
  font-size: 13px; /* Slightly smaller font size */
  line-height: 1.5;
}

/* Quick Actions */
.vivy-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  justify-content: center; /* Center quick actions */
}

.vivy-quick-action {
  background: var(--vivy-surface);
  border: 1px solid var(--vivy-border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--vivy-text);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); /* Added subtle shadow */
}

.vivy-quick-action:hover {
  background: var(--vivy-surface-light);
  border-color: var(--vivy-primary);
  transform: translateY(-1px); /* Lift on hover */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); /* More prominent shadow on hover */
}

/* Responsive Design */
@media (max-width: 480px) {
  .vivy-chatbot-modal {
    width: calc(100vw - 20px); /* Slightly less width */
    height: 90vh; /* Use viewport height */
    right: 10px; /* Adjusted right position */
    bottom: 80px; /* Adjusted bottom position */
  }

  .vivy-chatbot-bubble {
    bottom: 10px; /* Adjusted bottom position */
    right: 10px; /* Adjusted right position */
  }

  .vivy-message-content,
  .vivy-message-input,
  .vivy-welcome-message p {
    font-size: 13px; /* Smaller font size for mobile readability */
  }

  .vivy-modal-header {
    padding: 15px; /* Reduced header padding */
  }

  .vivy-chat-messages {
    padding: 15px; /* Reduced message area padding */
  }

  .vivy-input-area {
    padding: 15px; /* Reduced input area padding */
  }
}

/* Loading State */
.vivy-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--vivy-text-muted);
  font-size: 14px;
}

.vivy-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--vivy-border);
  border-top: 2px solid var(--vivy-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Error State */
.vivy-error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--vivy-error);
  border-radius: 8px;
  padding: 12px;
  margin: 16px 0;
  color: var(--vivy-error);
  font-size: 14px;
  text-align: center;
}

/* Specific styles for bot and user avatars */
.vivy-avatar.vivy-bot-avatar {
  background: linear-gradient(135deg, var(--vivy-primary), var(--vivy-primary-dark));
  color: white;
  font-size: 18px; /* Adjust as needed for icon */
  overflow: hidden; /* Ensure image stays within bounds */
}

.vivy-avatar.vivy-bot-avatar i {
  font-size: 18px; /* Ensure Font Awesome icon is visible */
}

.vivy-avatar.vivy-bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Cover the area without distortion */
  border-radius: 50%; /* Maintain circular shape */
}

.vivy-avatar.vivy-user-avatar {
  background: var(--vivy-surface-light);
  color: var(--vivy-text);
  font-size: 14px;
  font-weight: 600;
  border-radius: 50%; /* Ensure user avatar is also rounded */
  overflow: hidden; /* Ensure content inside is clipped */
}

/* Header actions for reset and close buttons */
.vivy-header-actions {
  display: flex;
  gap: 8px;
}

.vivy-reset-btn {
  background: none;
  border: none;
  color: var(--vivy-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.vivy-reset-btn:hover {
  background: var(--vivy-surface-light);
  color: var(--vivy-text);
  border: 1px solid var(--vivy-border); /* Added border on hover */
}
/* Callout Message */
.vivy-callout-message {
  position: fixed;
  bottom: 90px; /* Position above the bubble */
  right: 24px;
  background: var(--vivy-surface);
  color: var(--vivy-text);
  padding: 12px 18px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  max-width: 250px;
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
  z-index: 9998; /* Increased z-index, slightly less than bubble */
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease-out;
  pointer-events: none; /* Allow clicks to pass through */
  display: none; /* Hidden by default */
}

.vivy-callout-message.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all; /* Allow interaction when active */
  display: block; /* Show when active */
}

/* Pointer for the callout message */
.vivy-callout-message::after {
  content: '';
  position: absolute;
  bottom: -10px; /* Position below the message box */
  right: 20px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid var(--vivy-surface);
}