/* Eximia Chat Widget Styles */
.eximia-chat-widget {
  position: fixed;
  bottom: 80px; /* More visible on desktop */
  right: 20px; /* Properly visible, not cut off */
  z-index: 9999999; /* Extremely high z-index */
  font-family: 'Montserrat', 'Open Sans', sans-serif;
  pointer-events: auto; /* Ensure events are captured */
}

/* Chat Bubble (Minimized State) */
.eximia-chat-bubble {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #2c5530, #3a6b3f);
  border-radius: 35px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: none; /* Hidden by default, shown after delay */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: fixed; /* Fixed positioning for proper placement */
  animation: eximia-pulse 2s infinite;
  z-index: 1000000; /* Highest z-index to ensure clickability */
  pointer-events: auto; /* Ensure bubble can be clicked */
  /* Safari-specific fixes */
  -webkit-transform: translateZ(0); /* Force hardware acceleration */
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  touch-action: manipulation; /* Ensure touchability on Safari */
}

.eximia-chat-bubble:hover {
  transform: scale(1.1) translateZ(0);
  -webkit-transform: scale(1.1) translateZ(0);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.eximia-chat-bubble-icon {
  color: white;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 2px;
}

.eximia-chat-bubble-label {
  color: white;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

/* Notification Badge */
.eximia-chat-notification {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: eximia-bounce 1s infinite;
}

/* Popup Notification (Initial Greeting) */
.eximia-chat-popup-notification {
  position: fixed;
  bottom: 150px; /* Above bubble at new position */
  right: 20px; /* Closer to bubble and more visible */
  background: white;
  border: 2px solid #2c5530;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-width: 200px;
  z-index: 10000001; /* Above bubble */
  opacity: 0;
  transform: translateY(10px) scale(0.8);
  transition: all 0.3s ease;
  pointer-events: none; /* Don't interfere with clicking */
}

.eximia-chat-popup-notification.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: eximia-gentle-bounce 0.6s ease-out;
}

.eximia-popup-message {
  color: #2c5530;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
}

.eximia-popup-arrow {
  position: absolute;
  bottom: -8px;
  right: 25px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid white;
}

.eximia-popup-arrow::before {
  content: '';
  position: absolute;
  bottom: 1px;
  right: -9px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 9px solid #2c5530;
}

/* Chat Window (Expanded State) */
.eximia-chat-window {
  position: fixed; /* Fixed positioning for proper placement */
  bottom: 20px; /* Position above bubble */
  right: 20px; /* Align with bubble position */
  width: 350px;
  height: 500px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999998; /* Just below bubble but above everything else */
}

.eximia-chat-window.active {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

/* Chat Header */
.eximia-chat-header {
  background: linear-gradient(135deg, #2c5530, #3a6b3f);
  color: white;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eximia-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eximia-chat-logo {
  width: 35px;
  height: 35px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2c5530;
  font-weight: bold;
  font-size: 16px;
}

.eximia-chat-header-text h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.eximia-chat-header-text p {
  margin: 0;
  font-size: 12px;
  opacity: 0.9;
}

.eximia-chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.eximia-chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages Area */
.eximia-chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.eximia-chat-message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  animation: eximia-fadeInUp 0.3s ease;
}

.eximia-chat-message.user {
  background: #2c5530;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.eximia-chat-message.agent {
  background: white;
  color: #333;
  align-self: flex-start;
  border: 1px solid #e1e5e9;
  border-bottom-left-radius: 5px;
}

.eximia-chat-message.system {
  background: #ffe6e6;
  color: #d63031;
  align-self: center;
  border: 1px solid #d63031;
  border-radius: 8px;
  font-size: 12px;
  padding: 8px 12px;
  margin: 5px 0;
  text-align: center;
}

.eximia-chat-message-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 5px;
  text-align: right;
}

.eximia-chat-message.agent .eximia-chat-message-time {
  text-align: left;
}

/* Greeting Message */
.eximia-chat-greeting {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border: 2px dashed #3a6b3f;
  border-radius: 15px;
  padding: 20px;
  text-align: center;
  margin-bottom: 10px;
}

.eximia-chat-greeting h5 {
  margin: 0 0 10px 0;
  color: #2c5530;
  font-size: 16px;
  font-weight: 600;
}

.eximia-chat-greeting p {
  margin: 0;
  color: #666;
  font-size: 14px;
  line-height: 1.4;
}

/* Typing Indicator */
.eximia-chat-typing {
  align-self: flex-start;
  background: white;
  border: 1px solid #e1e5e9;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  padding: 12px 16px;
  display: none;
}

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

.eximia-chat-typing-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: eximia-typing 1.4s infinite ease-in-out;
}

.eximia-chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.eximia-chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.eximia-chat-typing-dot:nth-child(3) { animation-delay: 0; }

/* Chat Input Area */
.eximia-chat-input-area {
  padding: 20px;
  background: white;
  border-top: 1px solid #e1e5e9;
}

.eximia-chat-input-container {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.eximia-chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 100px;
  padding: 10px 15px;
  border: 2px solid #e1e5e9;
  border-radius: 20px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease;
}

.eximia-chat-input:focus {
  border-color: #3a6b3f;
}

.eximia-chat-input::placeholder {
  color: #999;
}

.eximia-chat-send-btn {
  width: 40px;
  height: 40px;
  background: #2c5530;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 16px;
}

.eximia-chat-send-btn:hover:not(:disabled) {
  background: #3a6b3f;
  transform: scale(1.05);
}

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

/* Status Indicators */
.eximia-chat-status {
  font-size: 11px;
  text-align: center;
  padding: 5px;
  color: #666;
  font-style: italic;
}

.eximia-chat-status.connected {
  color: #28a745;
}

.eximia-chat-status.connecting {
  color: #ffc107;
}

.eximia-chat-status.error {
  color: #dc3545;
}

.eximia-chat-status.warning {
  color: #ff8c00;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .eximia-chat-widget {
    position: fixed; /* Fix mobile positioning */
    bottom: 80px; /* Much higher on mobile for thumb reach */
    right: 20px; /* Fixed right positioning for mobile Safari */
    z-index: 9999999; /* Ensure high z-index on mobile */
  }

  .eximia-chat-bubble {
    position: fixed; /* Fix mobile bubble positioning */
    width: 75px; /* Bigger for easier mobile tapping */
    height: 75px; /* Bigger for easier mobile tapping */
    border-radius: 37px; /* Match new size */
    z-index: 10000000; /* Highest z-index on mobile */
    pointer-events: auto; /* Ensure clickable on mobile */
    box-shadow: 0 6px 30px rgba(44, 85, 48, 0.6); /* More prominent shadow on mobile */
  }

  .eximia-chat-window {
    position: fixed; /* Fixed positioning on mobile */
    bottom: 10px; /* Near bottom on mobile */
    left: 10px; /* Center on mobile */
    right: 10px; /* Center on mobile */
    width: calc(100vw - 20px);
    max-width: 350px;
    height: 60vh;
    max-height: 500px;
    z-index: 9999998; /* Below bubble but above everything else */
  }

  .eximia-chat-popup-notification {
    bottom: 155px; /* Higher on mobile */
    right: 10px; /* Align with mobile bubble area */
    left: 10px; /* Take full width on mobile */
    max-width: calc(100vw - 20px); /* Better width for mobile */
    text-align: center;
  }

  .eximia-popup-arrow {
    right: 30px; /* Adjust arrow position on mobile */
  }
}

/* Animations */
@keyframes eximia-pulse {
  0% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); }
  50% { box-shadow: 0 4px 20px rgba(44, 85, 48, 0.5); }
  100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); }
}

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

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

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

@keyframes eximia-gentle-bounce {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.05);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

/* Scroll Styling */
.eximia-chat-messages::-webkit-scrollbar {
  width: 5px;
}

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

.eximia-chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.eximia-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}