/* Landing page styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f0f2f5;
  margin: 0;
  padding: 0;
  min-height: calc(100vh + 250px); /* Balanced height to make footer reachable without pushing too far */
  display: flex;
  flex-direction: column;
  position: relative;
}

.mobile-container {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  position: relative;
  background-color: white;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: calc(100vh + 150px); /* Balanced to ensure footer is reachable but not too far */
}

/* Browser bar styles */
.browser-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #333;
  color: white;
  padding: 10px 15px;
  position: relative;
}

.lock-icon {
  margin-right: 5px;
  font-size: 12px;
}

.domain-name {
  font-size: 14px;
  font-weight: 500;
}

.privacy-label {
  position: absolute;
  right: 15px;
  font-size: 12px;
  opacity: 0.7;
}

/* Chat interface styles */
.chat-interface {
  flex: 1;
  min-height: calc(100vh + 100px); /* Balanced height - enough content but not pushing footer too far */
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative; /* Ensure proper positioning context */
}

/* Chat status styles */
.chat-status {
  text-align: center;
  margin-bottom: 20px;
  color: #555;
  font-size: 14px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

.status-dot.online {
  background-color: #34a853;
  box-shadow: 0 0 0 2px rgba(52, 168, 83, 0.2);
}

/* Chat messages container */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: none; /* Allow overflow to trigger page scroll */
  padding: 10px;
  padding-bottom: 80px; /* Increased padding for regular chat messages */
  background-color: #fff; /* Optional: Set a background color */
  border-radius: 5px;
  margin-bottom: 10px; /* Space between messages and input */
  scroll-behavior: smooth; /* Optional: browser-native smooth scrolling */
  max-height: calc(100vh - 116px);
}

/* Chat bubble wrapper */
.chat-bubble-wrapper {
  display: flex;
  margin-bottom: 10px;
}

/* For a bubble that follows a different sender's bubble (change of turns) */
.chat-bubble-wrapper.user-turn + .chat-bubble-wrapper:not(.user-turn),
.chat-bubble-wrapper:not(.user-turn) + .chat-bubble-wrapper.user-turn {
  margin-top: 16px;
}

/* Add consistent spacing for user messages */
.user-response-container + .chat-bubble-wrapper.user-turn {
  margin-top: 16px;
}

/* Chat bubble styles */
.chat-bubble {
  background-color: #f1f1f1;
  border-radius: 18px;
  padding: 12px 16px;
  max-width: 80%;
  word-wrap: break-word;
  align-self: flex-start;
  position: relative;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-bubble.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Representative bubble styles */
.rep-bubble {
  background-color: #f1f1f1;
  color: #333;
  position: relative;
  margin-left: 40px;
}

.rep-bubble::before {
  content: '';
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #34a853;
  background-image: var(--avatar-image, url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%23fff" d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>'));
  background-size: var(--avatar-size, 70%);
  background-position: center;
  background-repeat: no-repeat;
  position: absolute;
  left: -40px;
  top: 50%;
  transform: translateY(-50%);
}

/* User bubble styles */
.user-bubble {
  background-color: #1e88e5;
  color: white;
  border-radius: 18px;
  padding: 12px 16px;
  max-width: 80%;
  word-wrap: break-word;
  position: relative;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  margin-left: auto;
  margin-right: 40px;
}

.user-bubble.visible {
  opacity: 1;
  transform: translateY(0);
}

.user-bubble::after {
  content: '';
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #ccc;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%23666" d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
  background-size: 70%;
  background-position: center;
  background-repeat: no-repeat;
  position: absolute;
  right: -40px;
  top: 50%;
  transform: translateY(-50%);
}

/* Typing indicator styles */
.typing-indicator {
  padding: 12px 16px;
  background-color: #f1f1f1;
  border-radius: 18px;
  width: 60px;
  display: flex;
  justify-content: space-between;
  margin-left: 40px;
  position: relative;
}

/* Ensure typing indicator has space at bottom to be visible */
.chat-bubble-wrapper:has(.typing-indicator) {
  margin-bottom: 20px;
}

/* Extra space for typing indicators during final messages sequence */
.chat-bubble-wrapper:has(.typing-indicator):last-child {
  margin-bottom: 60px;
}

/* Ensure last regular chat message has space from bottom */
.chat-bubble-wrapper:last-child:not(:has(.typing-indicator)) {
  margin-bottom: 40px;
}

.typing-indicator::before {
  content: '';
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #34a853;
  background-image: var(--avatar-image, url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%23fff" d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>'));
  background-size: var(--avatar-size, 70%);
  background-position: center;
  background-repeat: no-repeat;
  position: absolute;
  left: -40px;
  top: 50%;
  transform: translateY(-50%);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: #999;
  border-radius: 50%;
  animation: typingAnimation 1.5s infinite ease-in-out;
}

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

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

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

@keyframes typingAnimation {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
  100% {
    transform: translateY(0);
  }
}

/* Header styles */
.chat-header {
  background-color: #f8f9fa;
  padding: 15px;
  text-align: center;
  font-weight: bold;
  border-bottom: 1px solid #dee2e6;
  color: #721c24;
  background-color: #f8d7da;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.4;
  position: sticky;
}

/* User response container styles */
.user-response-container {
  display: flex;
  flex-wrap: wrap;
  margin: 8px 0;
  justify-content: flex-start;
  margin-left: 40px;
}

/* Call button container specific styles */
.call-button-container {
  justify-content: flex-start !important; /* Align with rep bubbles */
  margin-left: 40px; /* Match the left margin of rep bubbles */
  width: auto !important;
  margin-bottom: 80px; /* Extra space below final CTA to push content up */
  padding-bottom: 0; /* Remove padding, use margin instead */
}

/* Chat button styles */
.chat-button {
  background-color: #1e88e5;
  color: white;
  border: none;
  border-radius: 18px;
  padding: 10px 20px;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 0.3s;
  font-weight: 500;
  margin-bottom: 8px;
  margin-right: 8px;
}

.chat-button:hover {
  opacity: 0.9;
}

/* Phone button styles */
.phone-button {
  display: inline-block;
  background-color: #1e88e5;
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: bold;
  transition: all 0.3s ease;
  margin: 15px 0;
  box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
  width: auto; /* Allow button to size to content */
  text-align: center;
}

.phone-button:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 123, 255, 0.4);
}

/* Footer Styles */
.site-footer {
  position: relative;
  margin-top: 10px; /* Reduced from 20px to bring footer closer */
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  background-color: #f8f9fa;
  padding: 15px;
  border-top: 1px solid #dee2e6;
  text-align: center;
  font-size: 12px;
  color: #6c757d;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.site-footer.visible {
  opacity: 1;
}

.site-footer p {
  margin-bottom: 10px;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

.footer-links a {
  color: #007bff;
  text-decoration: none;
  margin: 0 10px;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Chat divider for closed chat */
.chat-divider {
  width: 100%;
  text-align: center;
  margin: 20px 0;
  color: #666;
}

.chat-divider hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 10px 0;
}

.chat-closed-text {
  font-size: 14px;
  color: #888;
  padding: 5px 10px;
  display: inline-block;
}

/* Chat input wrapper */
.chat-input-wrapper {
  margin: 10px 0;
}

/* Countdown timer */
.countdown-span {
  color: #e53935; /* same red as headers */
  font-weight: 600;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  /* Increase bottom padding for chat messages on mobile */
  #chat-messages {
    padding-bottom: 120px; /* Extra padding on mobile to prevent messages being too close to bottom */
  }
  
  /* Ensure last chat message has more space from bottom on mobile */
  .chat-bubble-wrapper:last-child:not(:has(.typing-indicator)) {
    margin-bottom: 60px; /* Increased from 40px for mobile */
  }
  
  /* Extra space for typing indicators on mobile */
  .chat-bubble-wrapper:has(.typing-indicator):last-child {
    margin-bottom: 80px; /* Increased from 60px for mobile */
  }
  
  /* Adjust call button container on mobile */
  .call-button-container {
    margin-bottom: 100px; /* Extra space below final CTA on mobile */
  }
}

/* Small mobile devices (phones in portrait) */
@media (max-width: 480px) {
  /* Even more padding for smaller screens */
  #chat-messages {
    padding-bottom: 140px;
  }

  .chat-bubble-wrapper:last-child:not(:has(.typing-indicator)) {
    margin-bottom: 80px;
  }

  .chat-bubble-wrapper:has(.typing-indicator):last-child {
    margin-bottom: 100px;
  }
}

/* Dark Mode Styles */
body.dark-mode {
  background-color: #000000;
}

body.dark-mode .mobile-container {
  background-color: #1C1C1E;
}

body.dark-mode .browser-bar {
  background-color: #1C1C1E;
  color: white;
}

body.dark-mode .chat-interface {
  background-color: #1C1C1E;
}

body.dark-mode #chat-messages {
  background-color: #1C1C1E;
}

body.dark-mode .chat-status {
  color: white;
  background-color: #1C1C1E;
}

/* Dark mode chat bubbles */
body.dark-mode .rep-bubble {
  background-color: #3A3A3C;
  color: white;
}

body.dark-mode .user-bubble {
  background-color: #0A84FF;
  color: white;
}

body.dark-mode .typing-indicator {
  background-color: #3A3A3C;
}

body.dark-mode .typing-dot {
  background-color: #8E8E93;
}

/* Dark mode header - keep original light red background with dark red text */
body.dark-mode .chat-header {
  background-color: #f8d7da;
  color: #721c24;
  border-bottom: 1px solid #f5c6cb;
}

/* Dark mode buttons */
body.dark-mode .chat-button {
  background-color: #0A84FF;
  color: white;
}

body.dark-mode .phone-button {
  background-color: #0A84FF;
  color: white;
}

/* Dark mode footer */
body.dark-mode .site-footer {
  background-color: #2C2C2E;
  border-top: 1px solid #3A3A3C;
  color: #8E8E93;
}

body.dark-mode .footer-links a {
  color: #0A84FF;
}

/* Dark mode chat divider */
body.dark-mode .chat-divider {
  color: #8E8E93;
}

body.dark-mode .chat-divider hr {
  border-top: 1px solid #3A3A3C;
}

body.dark-mode .chat-closed-text {
  color: #8E8E93;
}

/* Dark mode modals */
body.dark-mode .modal-content {
  background-color: #2C2C2E;
  color: white;
}

body.dark-mode .modal-header {
  border-bottom: 1px solid #3A3A3C;
}

body.dark-mode .modal-header h2 {
  color: white;
}

body.dark-mode .close-modal {
  color: #8E8E93;
}

body.dark-mode .modal-body {
  color: white;
}

body.dark-mode .form-group label {
  color: #E5E5EA;
}

body.dark-mode .form-control {
  background-color: #3A3A3C;
  border: 1px solid #1C1C1E;
  color: white;
}

body.dark-mode #leadCaptureForm .form-control {
  background-color: #3A3A3C;
  border: 1px solid #1C1C1E !important;
  color: white;
}

body.dark-mode #leadCaptureForm .form-control:focus {
  border-color: #0A84FF !important;
  box-shadow: 0 0 0 0.2rem rgba(10, 132, 255, 0.25);
}

body.dark-mode .fixed-submit-button-container {
  background-color: #2C2C2E;
  border-top: 1px solid #3A3A3C;
}

body.dark-mode .modal-success h3 {
  color: white;
}

body.dark-mode .modal-success p {
  color: #E5E5EA;
}

/* Dark mode opt-in popup */
body.dark-mode .opt-in-popup-content {
  background-color: #2C2C2E;
  color: white;
}

body.dark-mode .opt-in-popup h5 {
  color: #0A84FF;
}

body.dark-mode .opt-in-popup-content .form-check-label {
  color: white !important;
}

body.dark-mode .form-check-label {
  color: white;
}

body.dark-mode .opt-in-actions .btn-secondary {
  background-color: #3A3A3C;
  border: 1px solid #48484A;
  color: #E5E5EA;
}

body.dark-mode .opt-in-actions .btn-secondary:hover {
  background-color: #48484A;
}

/* Bottom Sheet Selector Styles */
.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.bottom-sheet-overlay.active {
  background-color: rgba(0, 0, 0, 0.5);
}

.bottom-sheet {
  width: 100%;
  max-width: 400px;
  background-color: white;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.bottom-sheet-overlay.active .bottom-sheet {
  transform: translateY(0);
}

.bottom-sheet-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e0e0e0;
  position: relative;
  flex-shrink: 0;
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background-color: #d0d0d0;
  border-radius: 2px;
  margin: 0 auto 12px;
}

.bottom-sheet-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  text-align: center;
  padding-right: 30px; /* Space for close button */
}

.bottom-sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 32px;
  color: #666;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: color 0.2s ease;
}

.bottom-sheet-close:hover {
  color: #333;
}

.bottom-sheet-content {
  overflow-y: auto;
  padding: 8px 0;
  flex: 1;
  overscroll-behavior: contain;
}

.bottom-sheet-option {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border: none;
  background-color: white;
  text-align: left;
  font-size: 16px;
  color: #333;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #f0f0f0;
}

.bottom-sheet-option:hover,
.bottom-sheet-option:active {
  background-color: #f5f5f5;
}

.bottom-sheet-option:last-child {
  border-bottom: none;
}

/* Dark Mode Bottom Sheet */
body.dark-mode .bottom-sheet {
  background-color: #2C2C2E;
}

body.dark-mode .bottom-sheet-header {
  border-bottom: 1px solid #3A3A3C;
}

body.dark-mode .bottom-sheet-handle {
  background-color: #48484A;
}

body.dark-mode .bottom-sheet-title {
  color: white;
}

body.dark-mode .bottom-sheet-close {
  color: #8E8E93;
}

body.dark-mode .bottom-sheet-close:hover {
  color: #E5E5EA;
}

body.dark-mode .bottom-sheet-option {
  background-color: #2C2C2E;
  color: white;
  border-bottom: 1px solid #3A3A3C;
}

body.dark-mode .bottom-sheet-option:hover,
body.dark-mode .bottom-sheet-option:active {
  background-color: #3A3A3C;
}
