/**
 * CRITICAL FIX for Address Fields Desktop Layout
 * Fixes the issue where address fields appear on the right side
 * instead of below the main form
 */

/* ============================================ */
/* FIX: Hide unwanted route name display */
/* ============================================ */

/* Hide any route name text that might appear in address section */
#ctb-quick-address-fields [id*="route-name"],
#ctb-quick-address-fields [class*="route-name"],
#ctb-quick-address-fields [class*="selected-route"],
#ctb-quick-address-fields .route-display,
#ctb-quick-address-fields .selected-route-name {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* ============================================ */
/* FIX: Force address fields to new row */
/* ============================================ */

/* Make sure the form doesn't create side-by-side layout */
#ctb-quick-booking-form {
  display: block !important;
  /* Override any flex */
  width: 100%;
}

/* Force address fields container to be full width on new line */
#ctb-quick-address-fields {
  width: 100% !important;
  max-width: 100% !important;
  flex: 0 0 100% !important;
  /* Force full width if parent has flex */
  clear: both;
  /* Clear any floats */
  display: flex !important;
  flex-wrap: wrap;
  margin-top: 20px !important;
  padding-top: 20px;
  border-top: 2px solid #f7c400;
}

/* Ensure address fields don't overflow */
#ctb-quick-address-fields .col-lg-6,
#ctb-quick-address-fields .col-md-6 {
  flex: 0 0 calc(50% - 10px);
  max-width: calc(50% - 10px);
  width: calc(50% - 10px);
  margin: 0 5px;
}

/* Make sure inputs don't overflow */
#ctb-quick-pickup-address,
#ctb-quick-dropoff-address {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* ============================================ */
/* DESKTOP LAYOUT (992px+) */
/* ============================================ */

@media (min-width: 992px) {

  /* Container should not be flex in the problematic way */
  .ctb-quick-booking-wrapper {
    display: block;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
  }

  /* Main form row - horizontal */
  #ctb-quick-booking-form>.row.g-3:first-child {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    margin-bottom: 0;
  }

  /* Address fields row - MUST be on new line */
  #ctb-quick-address-fields {
    display: flex !important;
    flex-wrap: wrap;
    width: 100% !important;
    margin-top: 25px !important;
    padding-top: 25px;
    border-top: 2px solid #f7c400;
    gap: 20px;
    position: relative;
  }

  /* Each address field column */
  #ctb-quick-address-fields .col-lg-6 {
    flex: 1 1 calc(50% - 10px);
    max-width: calc(50% - 10px);
    min-width: 0;
    /* Prevent overflow */
  }

  /* Address input styling */
  #ctb-quick-pickup-address,
  #ctb-quick-dropoff-address {
    height: 50px;
    font-size: 15px;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
  }

  /* Editable fields */
  #ctb-quick-pickup-address:not(.readonly-airport),
  #ctb-quick-dropoff-address:not(.readonly-airport) {
    background: #ffffff;
  }

  #ctb-quick-pickup-address:not(.readonly-airport):focus,
  #ctb-quick-dropoff-address:not(.readonly-airport):focus {
    border-color: #f7c400;
    box-shadow: 0 0 0 0.25rem rgba(247, 196, 0, 0.15);
    outline: none;
  }

  /* Read-only airport fields */
  #ctb-quick-pickup-address.readonly-airport,
  #ctb-quick-dropoff-address.readonly-airport {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: #dee2e6;
    font-weight: 600;
    color: #495057;
    cursor: not-allowed;
    font-style: italic;
  }

  /* Section label */
  #ctb-quick-address-fields::before {
    content: "PICKUP & DROPOFF ADDRESSES";
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    padding: 0 15px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #f7c400;
    white-space: nowrap;
  }

  /* Hide any route name text that appears in address fields container */
  #ctb-quick-address-fields>*:not(.col-lg-6):not(.col-md-6):not(.row) {
    display: none !important;
  }

  /* If route name is being added as text node, hide it with this */
  #ctb-quick-address-fields::after {
    content: none !important;
    display: none !important;
  }
}

/* ============================================ */
/* TABLET (768px - 991px) */
/* ============================================ */

@media (min-width: 768px) and (max-width: 991px) {
  #ctb-quick-address-fields {
    flex-direction: column;
    width: 100% !important;
  }

  #ctb-quick-address-fields .col-lg-6,
  #ctb-quick-address-fields .col-md-6 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100%;
    margin: 0 0 15px 0;
  }
}

/* ============================================ */
/* MOBILE (< 768px) */
/* ============================================ */

@media (max-width: 767px) {
  #ctb-quick-address-fields {
    width: 100% !important;
    flex-direction: column;
    margin-top: 15px !important;
    padding-top: 15px;
  }

  #ctb-quick-address-fields .col-lg-6,
  #ctb-quick-address-fields .col-md-6 {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 10px 0;
  }

  #ctb-quick-address-fields::before {
    display: none;
  }
}

/* ============================================ */
/* ADDITIONAL FIXES */
/* ============================================ */

/* Hide any unwanted text/elements in address fields container */
#ctb-quick-address-fields>div:not([class*="col-"]) {
  display: none !important;
}

#ctb-quick-address-fields>p,
#ctb-quick-address-fields>span:not([class]),
#ctb-quick-address-fields>text {
  display: none !important;
}

/* Ensure only the column divs are visible */
#ctb-quick-address-fields {
  font-size: 0;
  /* Hide any text nodes */
}

#ctb-quick-address-fields>.col-lg-6,
#ctb-quick-address-fields>.col-md-6 {
  font-size: 1rem;
  /* Restore font size for actual content */
}

/* Make sure labels are visible */
#ctb-quick-address-fields .form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

/* Icon styling */
#ctb-quick-address-fields .bi-geo-alt-fill {
  color: #f7c400;
  margin-right: 5px;
}

/* Helper text */
#ctb-quick-address-fields .form-text {
  display: block;
  font-size: 12px;
  margin-top: 5px;
  color: #6c757d;
}

/* Error messages */
#ctb-quick-address-fields .invalid-feedback {
  display: block;
  font-size: 12px;
  margin-top: 5px;
  color: #dc3545;
}

/* Success state */
#ctb-quick-pickup-address:valid:not(:placeholder-shown):not(.readonly-airport),
#ctb-quick-dropoff-address:valid:not(:placeholder-shown):not(.readonly-airport) {
  border-color: #28a745;
}

