/* ========================================
   CSS Reset & Base Styles
======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
    sans-serif;
  line-height: 1.6;
  color: #2d2d2d;
  background-color: #ffffff;
  overflow-x: hidden;
}

/* ========================================
   Loading States
======================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e1e5e9;
  border-top: 3px solid #592f96;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

body:not(.loading) .loading-overlay {
  opacity: 0;
  pointer-events: none;
}

/* ========================================
   Layout & Grid
======================================== */

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.logo-container {
  margin-bottom: 0.5rem;
}

.logo-image {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1.4fr 2fr;
  /* margin: 0 auto; */
  padding: 1rem;
}

.form-section {
  padding: 1rem 1rem 2rem 1rem;
  background: #ffffff;
  overflow-y: auto;
}

.content-wrapper {
  max-width: 95%;
  margin: 0 auto;
}

.map-section {
  position: relative;
}

/* Ensure narrow map is hidden on wide screens */
@media (min-width: 1025px) {
  .map-section-narrow {
    display: none;
  }
}

/* ========================================
   Typography
======================================== */

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #592f96;
  line-height: 1.2;
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #592f96;
  /* margin-bottom: 0.5rem; */
}

.section-subtitle {
  color: #6b7280;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.results-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #592f96;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.results-title-no-services {
    font-size: 1.5rem;
    font-weight: 600;
    color: #592f96;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

.emoji {
  font-size: 1.2em;
}

/* ========================================
   Form Elements
======================================== */

.input-section {
  margin-bottom: 1rem;
}

/* Drop-off section animations */
.input-section.dropoff-hidden {
  opacity: 0;
  transform: translateY(-15px);
  max-height: 0;
  margin-bottom: 0;
  overflow: hidden;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, max-height 0.5s ease-out, margin-bottom 0.5s ease-out;
}

.input-section.dropoff-visible {
  opacity: 1;
  transform: translateY(0);
  max-height: 300px; /* Sufficient height for the content */
  margin-bottom: 2rem;
  overflow: visible;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, max-height 0.5s ease-out, margin-bottom 0.5s ease-out;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  .input-section.dropoff-hidden,
  .input-section.dropoff-visible {
    transition: opacity 0.2s ease, max-height 0.2s ease, margin-bottom 0.2s ease;
    transform: none;
  }
}

/* No services section animations */
#no-services.results-hidden {
  opacity: 0;
  transform: translateY(-15px);
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, max-height 0.5s ease-out;
}

#no-services.results-visible {
  opacity: 1;
  transform: translateY(0);
  max-height: 800px; /* Sufficient height for the form content */
  overflow: visible;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, max-height 0.5s ease-out;
}

/* Services available section animations */
#services-available.results-hidden {
  opacity: 0;
  transform: translateY(-15px);
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, max-height 0.5s ease-out;
}

#services-available.results-visible {
  opacity: 1;
  transform: translateY(0);
  max-height: 1000px; /* Sufficient height for service cards */
  overflow: visible;
  transition: opacity 0.5s ease-out, transform 0.5s ease-out, max-height 0.5s ease-out;
}

/* Respect user's motion preferences for results sections */
@media (prefers-reduced-motion: reduce) {
  #no-services.results-hidden,
  #no-services.results-visible,
  #services-available.results-hidden,
  #services-available.results-visible {
    transition: opacity 0.2s ease, max-height 0.2s ease;
    transform: none;
  }
}

.input-group {
  position: relative;
}

.input-label {
  display: block;
  font-weight: 600;
  color: #1b1b1b;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.postal-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: #ffffff;
}

.postal-input:focus {
  outline: none;
  border-color: #592f96;
  box-shadow: 0 0 0 3px rgba(89, 47, 150, 0.1);
}

/* Prefilled input styling */
.postal-input.prefilled {
  background-color: #f0f9ff;
  border-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 600;
}

.postal-input.prefilled::placeholder {
  color: rgba(74, 144, 226, 0.6);
}

.postal-input.valid {
  border-color: #10b981;
  background: #f0fdf4;
}

.postal-input.invalid {
  border-color: #ef4444;
  background: #fef2f2;
}

.input-status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.input-status.valid {
  background: transparent;
  color: white;
}

.input-status.valid::after {
  content: "✅";
  font-size: 2em;
}

.input-status.invalid {
  background: transparent;
  color: white;
}

.input-status.invalid::after {
  content: "❌";
  font-size: 2em;
}

.status-message {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  white-space: pre-line;
}

.status-message.success {
  color: #10b981;
}

.status-message.error {
  color: #ef4444;
}

.status-message.info {
  color: #592f96;
}

/* ========================================
   Warning Message Box
======================================== */

.warning-message-box {
  background: #fef3cd;
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: 1rem;
  margin-top: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.1), 0 2px 4px -1px rgba(245, 158, 11, 0.06);
  animation: slideInWarning 0.3s ease-out;
}

.warning-message-box .warning-icon {
  font-size: 1.25rem;
  color: #d97706;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.warning-message-box .warning-content {
  flex: 1;
}

.warning-message-box .warning-title {
  font-weight: 600;
  color: #92400e;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.warning-message-box .warning-text {
  color: #78350f;
  font-size: 0.8rem;
  line-height: 1.5;
}

.warning-message-box .warning-contact {
  color: #92400e;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

.warning-message-box .warning-contact:hover {
  color: #78350f;
}

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

/* ========================================
   Dividers
======================================== */

.section-divider {
  width: 100%;
  height: 1px;
  background-color: #e5e7eb;
  margin: 1rem 0 1rem 0;
}

/* ========================================
   Service Cards
======================================== */

.service-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.service-card {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 1.5rem;
  background: linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(90deg, #2e22ac 0%, #7833a7 50%, #e54c9c 100%) border-box;
  position: relative;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(46, 34, 172, 0.08);
  opacity: 0;
  transform: translateY(20px);
}

.service-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(46, 34, 172, 0.15);
}

/* Service card fade-in animation */
.service-card.fade-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.service-card.fade-in-delay-1 {
  transition-delay: 0.1s;
}

.service-card.fade-in-delay-2 {
  transition-delay: 0.2s;
}

.service-card.fade-in-delay-3 {
  transition-delay: 0.3s;
}

.service-card.fade-in-delay-4 {
  transition-delay: 0.4s;
}

.service-type {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #592f96;
}

.service-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: #592f96;
  margin-bottom: 1rem;
}

.service-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.service-detail {
  text-align: left;
}

.service-detail-label {
  font-size: 0.85rem;
  color: #592f96;
  white-space: nowrap;
}

.service-detail-label-end {
  font-size: 0.85rem;
  color: #6b7280;
}

.service-detail-value {
  font-weight: 600;
  color: #1f2937;
  font-size: 1.125rem;
}

.service-addons {
  font-size: 0.875rem;
  color: #1f2937;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.service-addons::before {
  content: "Add-ons: ";
  color: #592f96;
  font-weight: 600;
}

.service-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.cta-button {
  background: linear-gradient(135deg, #592f96, #4a2580);
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 25px;
  /* font-weight: 600; */
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.cta-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(89, 47, 150, 0.3);
}

.cta-button:active {
  transform: translateY(0);
}

.service-schedule {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.service-schedule-next-available {
  font-size: 0.875rem;
  color: #592f96;
}

.service-schedule-cutoff-time {
  font-size: 0.875rem;
  color: #2d2d2d;
}

.schedule-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.schedule-icon svg {
  width: 60px;
  height: 60px;
  color: #592f96;
}

/* ========================================
   Lead Capture Form
======================================== */

.lead-form {
  margin-top: 0.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: #ffffff;
}

.form-input:focus {
  outline: none;
  border-color: #592f96;
  box-shadow: 0 0 0 3px rgba(89, 47, 150, 0.1);
}

/* ========================================
   Map Section
======================================== */

.map-container {
  height: 100%;
  position: relative;
  padding: 1.5rem 2rem 2rem 0;
  box-sizing: border-box;
  display: none; /* Hidden by default, shown only when map is available */
}

/* Map section for narrow screens - hidden by default */
.map-section-narrow {
  display: none;
  margin: 2rem 0;
}

.map-section-narrow .map-container {
  height: 400px;
  padding: 0;
  display: none; /* Hidden by default, shown only when map is available */
}



.service-map {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  overflow: hidden;
}

/* ========================================
   Modal
======================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  max-width: 400px;
  margin: 1rem;
  text-align: center;
}

.modal-content h3 {
  color: #1f2937;
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.modal-content p {
  color: #6b7280;
  margin-bottom: 1.5rem;
}

/* ========================================
   Responsive Design
======================================== */

@media (max-width: 1024px) {
  .main-content {
    display: flex;
    flex-direction: column;
    padding: 0 0.5rem;
  }

  .form-section {
    order: 1;
  }

  /* Hide the original right-side map section */
  .map-section {
    display: none;
  }

  /* Show the narrow map section inline with form */
  .map-section-narrow {
    display: block;
  }

  .hero-title {
    font-size: 2rem;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 0 0.5rem;
  }

  .form-section {
    padding: 1.5rem 1.5rem 2rem 1.5rem;
  }

  .logo-container {
    margin-bottom: 1.5rem;
  }

  .hero-title {
    font-size: 1.75rem;
    margin-bottom: 2rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .service-details {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .service-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .map-section {
    min-height: 300px;
  }

  .map-container {
    padding: 1rem 1rem 1.5rem 0;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 0 0.5rem;
  }

  .form-section {
    padding: 1rem 1rem 2rem 1rem;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .service-card {
    padding: 1rem;
  }

  .cta-button {
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
  }

  .map-container {
    padding: 0.75rem 0.75rem 1rem 0;
  }
}

/* ========================================
   Embedding Styles
======================================== */

.embedded .logo-container {
  margin-bottom: 1.5rem;
}

.embedded .hero-title {
  font-size: 1.75rem;
  margin-bottom: 2rem;
}

/* Additional embedded styles for better integration */
.embedded.compact .logo-container {
  display: none;
}

.embedded.compact .hero {
  display: none;
}

.embedded.compact .main-content {
  padding: 1rem;
}

.embedded.compact .form-section {
  padding: 1rem;
}

/* Auto-validation in progress indicator */
.postal-input.prefilled.validating {
  border-color: #f59e0b;
  background-color: #fffbeb;
}

.input-wrapper.validating::after {
  content: "⏳";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: #f59e0b;
  z-index: 2;
}

/* ========================================
   Accessibility
======================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .postal-input {
    border-width: 3px;
  }

  .cta-button {
    border: 2px solid currentColor;
  }
}

/* Focus indicators */
*:focus {
  outline: 2px solid #592f96;
  outline-offset: 2px;
}

.cta-button:focus,
.postal-input:focus,
.form-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(89, 47, 150, 0.3);
}

/* ========================================
   Print Styles
======================================== */

@media print {
  .map-section,
  .cta-button,
  .loading-overlay {
    display: none !important;
  }

  .main-content {
    display: block;
  }

  .form-section {
    padding: 0;
  }
}
