/* Reset and isolate chat widget styles */
.ai-chat-assistant-widget,
.ai-chat-assistant-widget *,
.ai-chat-assistant-widget *::before,
.ai-chat-assistant-widget *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue",
    sans-serif;
  line-height: normal;
}

/* Root variables with theme support */
.ai-chat-assistant-widget {
  /* Default dark theme */
  --ai-chat-primary: #00c853; /* Bright green to match image */
  --ai-chat-primary-hover: #00a844; /* Darker green for hover */
  --ai-chat-bg: #1e2029;
  --ai-chat-card-bg: #272934;
  --ai-chat-text: #ffffff;
  --ai-chat-text-secondary: #a0a0a0;
  --ai-chat-border: #3a3a3a;
  --ai-chat-user-message-bg: #9c27b0; /* Keep purple for user messages */
  --ai-chat-assistant-message-bg: #272934;
  --ai-chat-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  --ai-chat-input-bg: #333333;
  --ai-chat-warning-bg: #ff9800;
  --ai-chat-system-bg: #444444;

  /* Widget positioning */
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;

  /* Text styling */
  color: var(--ai-chat-text);
  font-size: 14px;
}

/* Light theme - only change text and icon colors */
.ai-chat-assistant-widget.light-theme {
  --ai-chat-text: #333333 !important;
  --ai-chat-text-secondary: #666666 !important;
}

/* Make sure SVG icons use the text color */
.ai-chat-assistant-widget svg {
  stroke: var(--ai-chat-text) !important;
}

/* Find and modify the AI assistant message styles to remove the hardcoded white color */
/* Replace these styles: */

/* AI assistant message styling - default (will be overridden by container background setting) */
.ai-chat-message.ai-chat-message-assistant .ai-chat-message-content,
.ai-chat-assistant-widget.light-theme .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content {
  background-color: var(--ai-chat-assistant-message-bg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

/* Default text styling for AI messages */
.ai-chat-message.ai-chat-message-assistant .ai-chat-message-content p,
.ai-chat-assistant-widget.light-theme .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content p {
  /* Color will be set by container background setting */
}

/* Default link styling for AI messages */
.ai-chat-message.ai-chat-message-assistant .ai-chat-message-content a,
.ai-chat-assistant-widget.light-theme .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content a {
  text-decoration: underline;
  /* Color will be set by container background setting */
}

/* Force AI assistant messages to have appropriate text color based on theme */
.ai-chat-assistant-widget .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content,
.ai-chat-assistant-widget.light-theme .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content p,
.ai-chat-assistant-widget .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content p,
.ai-chat-assistant-widget.light-theme .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content p,
.ai-chat-assistant-widget .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content a,
.ai-chat-assistant-widget.light-theme .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content a {
  /* Remove the !important flag to allow theme overrides */
  color: white;
}

/* Container background specific overrides - these need !important */
.ai-chat-assistant-widget[data-container-bg="light"]
  .ai-chat-message.ai-chat-message-assistant
  .ai-chat-message-content,
.ai-chat-assistant-widget[data-container-bg="light"]
  .ai-chat-message.ai-chat-message-assistant
  .ai-chat-message-content
  p,
.ai-chat-assistant-widget[data-container-bg="light"]
  .ai-chat-message.ai-chat-message-assistant
  .ai-chat-message-content
  a {
  color: #333333 !important; /* Dark text for light background with !important */
}

.ai-chat-assistant-widget[data-container-bg="dark"] .ai-chat-message.ai-chat-message-assistant .ai-chat-message-content,
.ai-chat-assistant-widget[data-container-bg="dark"]
  .ai-chat-message.ai-chat-message-assistant
  .ai-chat-message-content
  p,
.ai-chat-assistant-widget[data-container-bg="dark"]
  .ai-chat-message.ai-chat-message-assistant
  .ai-chat-message-content
  a {
  color: white !important; /* White text for dark background with !important */
}

/* Make user message styling customizable */
.ai-chat-message.ai-chat-message-user .ai-chat-message-content {
  background-color: var(--ai-chat-user-message-bg) !important;
  color: var(--ai-chat-user-message-text);
  border-radius: 18px !important;
  border-bottom-right-radius: 4px !important;
  font-weight: 500; /* Added increased font weight for better readability */
}

/* Target paragraphs inside user messages */
.ai-chat-message.ai-chat-message-user .ai-chat-message-content p {
  color: var(--ai-chat-user-message-text);
  font-weight: 500; /* Added increased font weight for better readability */
}

/* Target links inside user messages */
.ai-chat-message.ai-chat-message-user .ai-chat-message-content a {
  color: var(--ai-chat-user-message-text);
  text-decoration: underline !important;
}

/* Add stronger protection for the toggle button */
.ai-chat-toggle-btn {
  background-color: var(--ai-chat-primary) !important;
  color: white !important;
  border: none !important;
  border-radius: 50% !important;
  width: 60px !important;
  height: 60px !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: var(--ai-chat-shadow) !important;
  transition: background-color 0.2s ease, opacity 0.3s ease, visibility 0.3s ease !important;
  z-index: 9998 !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  position: relative !important;
}

.ai-chat-toggle-btn:hover {
  background-color: var(--ai-chat-primary-hover) !important;
}

.ai-chat-toggle-btn.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Notification badge on the toggle button */
.ai-chat-notification-badge {
  position: absolute !important;
  top: -4px !important;
  right: -4px !important;
  width: 22px !important;
  height: 22px !important;
  background-color: #ef4444 !important;
  color: #ffffff !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 2px solid #ffffff !important;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5) !important;
  pointer-events: none !important;
  animation: ai-chat-badge-pulse 2s ease-in-out infinite !important;
  line-height: 1 !important;
  padding: 0 !important;
}

.ai-chat-notification-badge.hidden {
  display: none !important;
}

@keyframes ai-chat-badge-pulse {
  0%, 100% {
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.8);
    transform: scale(1.1);
  }
}

.ai-chat-toggle-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-chat-container {
  display: none;
  flex-direction: column;
  width: 360px;
  height: 600px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--ai-chat-shadow);
  margin-bottom: 16px;
  border: 1px solid var(--ai-chat-border);
  z-index: 9999;
}

.ai-chat-container.active {
  display: flex;
}

.ai-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background-color: var(--ai-chat-primary);
  color: var(--ai-chat-text); /* Changed from white to use theme variable */
}

.ai-chat-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ai-chat-text); /* Changed from white to use theme variable */
  margin: 0;
  padding: 0;
}

.ai-chat-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Make all action buttons have transparent backgrounds and reduce padding/radius */
.ai-chat-action-btn,
.ai-chat-email-btn,
.ai-chat-call-btn,
.ai-chat-minimize-btn,
.ai-chat-close-btn {
  background: transparent !important;
  border: none;
  color: var(--ai-chat-text); /* Changed from white to use theme variable */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px; /* Reduced padding */
  border-radius: 0; /* Removed border radius */
  transition: background-color 0.2s ease;
  margin: 0;
  outline: none;
}

.ai-chat-action-btn:hover,
.ai-chat-email-btn:hover,
.ai-chat-call-btn:hover,
.ai-chat-minimize-btn:hover,
.ai-chat-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.2) !important;
}

.ai-chat-action-btn svg,
.ai-chat-email-btn svg,
.ai-chat-call-btn svg,
.ai-chat-minimize-btn svg,
.ai-chat-close-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ai-chat-text) !important; /* Changed from white to use theme variable */
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden; /* Hide scrollbars */
}

.ai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  overflow-y: auto; /* Allow scrolling */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  flex: 1;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  touch-action: pan-y; /* Allow vertical scrolling only */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.ai-chat-messages::-webkit-scrollbar {
  display: none;
}

.ai-chat-message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  outline: none; /* Remove focus outline but keep it accessible */
  position: relative;
}

.ai-chat-message:focus {
  outline: none; /* Remove focus outline but keep it accessible */
}

.ai-chat-message-assistant {
  align-self: flex-start;
  margin-bottom: 15px;
  padding-bottom: 5px;
}

.ai-chat-message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-chat-message-content {
  background-color: var(--ai-chat-assistant-message-bg);
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  color: var(--ai-chat-text);
}

.ai-chat-message-content:focus-within {
  box-shadow: 0 0 0 2px var(--ai-chat-primary);
}

.ai-chat-message-assistant .ai-chat-message-content {
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

.ai-chat-message-content p {
  margin: 0;
  padding: 0;
  color: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.ai-chat-message-content p + p {
  margin-top: 8px;
}

.ai-chat-message-content a {
  color: var(--ai-chat-primary);
  text-decoration: underline;
}

/* Live indicator bar */
.ai-chat-live-indicator {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 16px !important;
  background-color: rgba(16, 185, 129, 0.06) !important;
  border-top: 1px solid rgba(16, 185, 129, 0.15) !important;
}

.ai-chat-live-dot {
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  background-color: #10b981 !important;
  flex-shrink: 0 !important;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6) !important;
  animation: ai-chat-live-pulse 2s ease-in-out infinite !important;
}

@keyframes ai-chat-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  50%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ai-chat-live-text {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #10b981 !important;
  letter-spacing: 0.02em !important;
}

/* Update the preset buttons container to remove the bottom border */
.ai-chat-preset-buttons {
  display: flex !important; /* Force display */
  overflow-x: auto !important;
  padding: 12px 16px !important;
  margin: 0 !important;
  -webkit-overflow-scrolling: touch !important;
  position: relative !important;
  cursor: grab !important;
  border-top: 1px solid var(--ai-chat-border) !important; /* Using the theme variable instead of hardcoded color */
  border-bottom: none !important; /* Remove bottom border as it's handled by footer */
  min-height: 60px !important;
  align-items: center !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  touch-action: pan-x !important;
  gap: 10px !important; /* Add gap between buttons */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.ai-chat-preset-buttons::-webkit-scrollbar {
  display: none;
}

/* Make preset buttons more minimal */
.ai-chat-preset-btn {
  background-color: var(--ai-chat-assistant-message-bg) !important; /* Match assistant message background */
  color: white !important; /* Force white text color */
  border: 1px solid var(--ai-chat-primary) !important; /* Use primary color for border */
  border-radius: 18px !important;
  padding: 10px 16px !important;
  font-size: 14px !important;
  text-align: center !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  white-space: nowrap !important;
  margin-right: 0 !important;
  flex-shrink: 0 !important;
  outline: none !important;
}

/* Update the last button margin */
.ai-chat-preset-btn:last-child {
  margin-right: 8px;
}

.ai-chat-preset-btn:hover {
  background-color: rgba(156, 39, 176, 0.1); /* Purple with opacity */
  border-color: var(--ai-chat-primary);
}

/* Add active state for when dragging */
.ai-chat-preset-buttons:active {
  cursor: grabbing;
}

/* Update the footer border styling */
.ai-chat-footer {
  padding: 16px;
  border-top: 1px solid var(--ai-chat-border); /* Using the theme variable instead of hardcoded color */
  background-color: #555555; /* Darker gray background for footer */
}

.ai-chat-form {
  margin-bottom: 8px;
}

/* Update the input container to match the image */
.ai-chat-input-container {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  background-color: rgba(51, 51, 51, 0.8) !important; /* Slightly transparent dark background */
  border-radius: 24px !important;
  border: 0 !important; /* Force remove border */
  padding: 8px 12px !important; /* Add proper padding to match image */
}

.ai-chat-input {
  flex: 1 !important;
  background: rgba(51, 51, 51, 0.8) !important; /* Match input container background */
  border: 0 !important; /* Force remove border */
  padding: 8px 0 !important; /* Add vertical padding, no horizontal padding */
  color: white !important; /* Force white text color */
  font-size: 16px !important; /* Increased font size to prevent iOS zoom */
  outline: none !important;
  width: 100% !important;
  min-height: auto !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  /* Prevent autofill styling */
  transition: background-color 5000s ease-in-out 0s !important;
  margin: 0 !important;
}

/* Ensure placeholder text is also white with proper opacity */
.ai-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.6) !important;
  opacity: 1 !important;
}

/* Update the submit button to match the green circular button in the image */
.ai-chat-submit-btn {
  background-color: #00c853 !important; /* Bright green to match image */
  border: none !important;
  color: var(--ai-chat-text) !important; /* Changed to use theme variable */
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 8px !important;
  border-radius: 50% !important;
  width: 36px !important;
  height: 36px !important;
  transition: background-color 0.2s ease !important;
  margin: 0 !important;
  outline: none !important;
  flex-shrink: 0 !important;
  position: relative !important;
  z-index: 10 !important; /* Ensure it's above other elements */
}

/* Fix send icon visibility and change to paper airplane */
.ai-chat-submit-btn svg {
  width: 20px !important;
  height: 20px !important;
  fill: none !important;
  stroke: var(--ai-chat-text) !important; /* Changed to use theme variable */
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  transform: rotate(45deg) translate(0, 0) !important; /* Added translate to center it */
  position: absolute !important; /* Added to help with centering */
  top: 50% !important; /* Center vertically */
  left: 50% !important; /* Center horizontally */
  margin-top: -10px !important; /* Half of height */
  margin-left: -10px !important; /* Half of width */
}

/* Center the powered by text */
.ai-chat-powered-by {
  text-align: center !important;
  font-size: 12px !important;
  margin-top: 8px !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 4px !important;
  padding-bottom: 5px !important; /* Add some padding at the bottom */
}

/* Style the "Powered by" text specifically - with higher specificity */
.ai-chat-assistant-widget .ai-chat-powered-by .ai-chat-powered-by-text {
  margin: 0 !important;
  padding: 0 !important;
  color: #ffffff !important; /* White text for dark theme by default */
  font-size: 12px !important;
  font-weight: normal !important;
}

/* Container background specific overrides for powered by text */
.ai-chat-assistant-widget[data-container-bg="light"] .ai-chat-powered-by .ai-chat-powered-by-text {
  color: #333333 !important; /* Dark text for light container */
}

.ai-chat-assistant-widget[data-container-bg="dark"] .ai-chat-powered-by .ai-chat-powered-by-text {
  color: #ffffff !important; /* White text for dark container */
}

/* Find this CSS rule for the powered by link */
.ai-chat-assistant-widget .ai-chat-powered-by .ai-chat-powered-by-link {
  color: #00c853 !important; /* Match green theme */
  text-decoration: none !important;
  font-size: 12px !important;
  font-weight: normal !important;
}

/* Replace it with this updated rule that uses the primary color variable */
.ai-chat-assistant-widget .ai-chat-powered-by .ai-chat-powered-by-link {
  color: var(--ai-chat-primary) !important; /* Use the primary color variable instead of hardcoded green */
  text-decoration: none !important;
  font-size: 12px !important;
  font-weight: normal !important;
}

.ai-chat-assistant-widget .ai-chat-powered-by .ai-chat-powered-by-link:hover {
  text-decoration: underline !important;
}

.ai-chat-typing {
  align-self: flex-start;
  max-width: 85%;
}

.ai-chat-typing-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background-color: var(--ai-chat-assistant-message-bg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

.ai-chat-typing-label {
  font-size: 13px;
  color: var(--ai-chat-text-secondary);
  font-style: italic;
  white-space: nowrap;
}

.ai-chat-typing-dots {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.ai-chat-typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--ai-chat-text-secondary);
  border-radius: 50%;
  animation: typing-animation 1.4s infinite ease-in-out;
}

.ai-chat-typing-dot:nth-child(1) {
  animation-delay: 0s;
}

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

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

/* Simplified system message style */
.ai-chat-message-system {
  align-self: center;
  max-width: 90%;
  width: auto;
}

/* We can remove these old styles since we're using a new approach */
.ai-chat-warning {
  display: none; /* Hide the old warning style */
}

/* System message */
.ai-chat-system-message {
  align-self: center;
  width: 90%;
  margin: 10px 0;
}

.ai-chat-system-message p {
  background-color: #333333;
  color: var(--ai-chat-text);
  padding: 10px;
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
  margin: 0;
}

/* Update the timeout overlay styling to ensure it stays centered */
.ai-chat-timeout-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000; /* Higher than anything else */
  background-color: rgba(30, 32, 41, 0.95);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--ai-chat-primary);
  padding: 20px;
  text-align: center;
  display: none;
  width: 80%;
  max-width: 300px;
  pointer-events: auto; /* Ensure clicks work */
}

.ai-chat-timeout-content {
  color: white;
  font-size: 16px;
  line-height: 1.5;
}

.ai-chat-timeout-content p {
  margin-bottom: 15px;
}

/* Find the .ai-chat-continue-btn style and replace it with this stronger version */
/* Replace this: */
.ai-chat-continue-btn {
  /* Use theme variables instead of hardcoded colors */
  background-color: var(--ai-chat-card-bg) !important;
  color: var(--ai-chat-text) !important;
  border: 1px solid var(--ai-chat-border) !important;
  border-radius: 20px !important;
  padding: 10px 20px !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: background-color 0.2s ease !important;
  outline: none !important;
  display: inline-block !important;
  margin-top: 10px !important;
  text-align: center !important;
  text-decoration: none !important;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue",
    sans-serif !important;
  line-height: normal !important;
  position: relative !important;
  z-index: 10001 !important; /* Higher than the overlay */
}

.ai-chat-continue-btn:hover {
  background-color: var(--ai-chat-assistant-message-bg) !important;
}

/* Add specific styling for light theme */
.ai-chat-assistant-widget.light-theme .ai-chat-continue-btn {
  background-color: #f0f0f0 !important;
  border-color: #ddd !important;
  color: #333333 !important;
}

.ai-chat-assistant-widget.light-theme .ai-chat-continue-btn:hover {
  background-color: #e0e0e0 !important;
}

/* Remove theme toggle button styles */
.ai-chat-theme-toggle {
  display: none !important;
}

@keyframes typing-animation {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
  100% {
    opacity: 0.8;
  }
}

/* Responsive styles */
@media (max-width: 480px) {
  .ai-chat-container {
    width: 100%;
    height: 100%;
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0; /* Add this so it works for both left and right positioning */
    border-radius: 0;
    margin-bottom: 0;
  }

  /* Prevent page scrolling when chat is open on mobile */
  .ai-chat-container.active {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    overflow: hidden;
  }

  /* Ensure the chat body takes full height */
  .ai-chat-body {
    height: calc(100% - 120px); /* Adjust based on header and footer height */
  }
}

/* Add or update the timeout message styling to make it more prominent */
.ai-chat-message-timeout {
  align-self: flex-start;
  max-width: 85%;
  margin: 16px 0;
  z-index: 100; /* Ensure it's above other elements */
}

.ai-chat-message-timeout .ai-chat-message-content {
  background-color: rgba(156, 39, 176, 0.15); /* Lighter purple background */
  border-left: 3px solid var(--ai-chat-primary);
  color: var(--ai-chat-text);
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); /* Add shadow for emphasis */
}

/* Add this to ensure the chat body doesn't interfere with the overlay */
.ai-chat-body {
  position: relative;
}

/* Prevent page scrolling when chat is open */
body.ai-chat-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* Prevent iOS zoom */
@media screen and (max-width: 768px) {
  .ai-chat-input {
    font-size: 16px; /* Minimum font size to prevent iOS zoom */
  }

  /* Prevent double-tap zoom */
  .ai-chat-container * {
    touch-action: manipulation;
  }
}

/* Add stronger protection for minimize and close buttons */
.ai-chat-minimize-btn,
.ai-chat-close-btn {
  background: transparent !important;
  border: none !important;
  color: white !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 2px !important;
  border-radius: 0 !important;
  transition: background-color 0.2s ease !important;
  margin: 0 !important;
  outline: none !important;
  position: relative !important;
  z-index: 10 !important;
  width: 24px !important;
  height: 24px !important;
}

.ai-chat-minimize-btn:hover,
.ai-chat-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.2) !important;
}

.ai-chat-minimize-btn svg,
.ai-chat-close-btn svg {
  width: 18px !important;
  height: 18px !important;
  fill: none !important;
  stroke: var(--ai-chat-text) !important; /* Changed from white to use theme variable */
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}

/* AI Profile Picture */
.ai-chat-profile-picture {
  position: absolute;
  bottom: -10px;
  left: -10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--ai-chat-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.ai-chat-profile-picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Countdown timer styling */
.ai-chat-inactivity-countdown {
  position: absolute;
  bottom: 70px;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px;
  text-align: center;
  z-index: 1000;
  border-radius: 4px;
  margin: 0 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  animation: pulse 2s infinite;
}

.ai-chat-countdown-content {
  font-weight: bold;
}

#countdown-timer {
  color: #ff5252;
  font-size: 1.2em;
}

@keyframes pulse {
  0% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.8;
  }
}
