/* ==========================================================================
   Search Results page
   ========================================================================== */

/* ==========================================================================
   Compact mobile trip summary + quick filter chips
   ========================================================================== */

.trip-summary-bar {
  display: none;
}

.date-slider-heading {
  display: none;
}

.quick-filters-row {
  display: none;
}

@media (max-width: 900px) {
  .trip-summary-bar {
    display: block;

    background: var(--color-overlay-bg);
    padding: var(--space-4) 20px var(--space-6);
  }

  .trip-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .trip-summary-route {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;

    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 18px;
    color: var(--color-overlay-text);
  }

  .trip-summary-route span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .trip-summary-route svg {
    flex-shrink: 0;
    opacity: 0.7;
  }

  .trip-summary-edit-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--color-overlay-text);
    font-size: 13px;
    font-weight: 600;
  }

  .trip-summary-sub {
    margin-top: 4px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.72);
  }

  /* The full From/To/Date form: collapsed by default on mobile, opened
     by tapping .trip-summary-edit-btn. Desktop ignores this class
     entirely (see .search-summary-inner above), so it's always visible
     there regardless. */
  .search-summary-inner.summary-form-collapsed {
    display: none;
  }

  .search-summary-inner {
    margin-top: var(--space-4);
  }

  .date-slider-heading {
    display: block;
    margin: var(--space-2) 0 var(--space-3);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    color: var(--color-overlay-text);
  }

  .quick-filters-row {
    display: flex;
    gap: 8px;
    margin-top: var(--space-4);
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .quick-filters-row::-webkit-scrollbar {
    display: none;
  }

  .quick-filter-chip {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    color: var(--color-overlay-text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
  }

  .quick-filter-chip--filters {
    background: rgba(255, 255, 255, 0.12);
  }

  .quick-filter-chip--time.active {
    background: var(--color-navy-cta);
    border-color: var(--color-navy-cta);
    color: var(--color-accent-ink);
  }

  .results-count {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 13px;
  }
}

.search-summary-bar {
  background: var(--color-overlay-bg);
  padding: var(--space-8) 40px;
}

.search-summary-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.search-summary-field {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

/* These replace what used to be inline `style="flex:..."` on each field.
   That inline flex-basis (200px / 180px) was fine while the row was laid
   out horizontally, but once .search-summary-inner switches to
   flex-direction: column on mobile, flex-basis applies to the main axis -
   which is now HEIGHT, not width. That forced every field to ~180-200px
   tall (label + input only need ~70px), which is what produced the huge
   empty gaps under each field on mobile. Fixed below by resetting these
   to flex: 1 1 auto inside the column-layout breakpoint. */
.search-summary-field--location {
  flex: 1.4 1 200px;
}

.search-summary-field--date {
  flex: 1.2 1 180px;
}

.search-summary-field label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.search-summary-field input,
.search-summary-field .dp-trigger {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-family: var(--font-heading);
  font-size: var(--fs-body);
  color: var(--color-text-body);
}

.search-summary-field input:focus,
.search-summary-field .dp-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--color-navy-cta);
  box-shadow: 0 0 0 3px rgba(0, 53, 128, 0.12);
}

.search-summary-swap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  color: var(--color-navy);
  flex-shrink: 0;
  margin-bottom: 2px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.search-summary-swap:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-ink);
  transform: rotate(180deg);
}

.search-summary-btn {
  flex: 0 0 auto;
  background: var(--color-navy-cta);
  color: var(--color-overlay-text);
  border-radius: var(--radius-md);
  padding: 13px 28px;
  font-weight: 600;
  font-size: var(--fs-small);
}

.search-summary-btn:hover {
  background: var(--color-navy-cta-hover);
}

/* ==========================================================================
   Mobile quick date strip
   ========================================================================== */

/* Hidden by default - a desktop/tablet passenger already has the full
   calendar in the field above; this swipeable strip is a mobile-only
   shortcut, shown by the @media block further down. */
.date-slider-mobile {
  display: none;
}

@media (max-width: 640px) {
  .date-slider-mobile {
    display: flex;
    gap: 8px;

    margin-top: var(--space-4);

    padding: 2px 2px 6px;

    overflow-x: auto;
    overscroll-behavior-x: contain;

    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;

    scrollbar-width: none;
  }

  .date-slider-mobile::-webkit-scrollbar {
    display: none;
  }

  .date-chip {
    flex: 0 0 auto;

    scroll-snap-align: center;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;

    width: 56px;
    min-height: 56px;
    padding: 6px 0;

    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);

    color: var(--color-text-body);

    cursor: pointer;
  }

  .date-chip .date-chip-month {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-navy);
  }

  .date-chip .date-chip-day {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
  }

  .date-chip .date-chip-weekday {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  .date-chip.active {
    background: var(--color-navy-cta);
    border-color: var(--color-navy-cta);
  }

  .date-chip.active .date-chip-day,
  .date-chip.active .date-chip-weekday,
  .date-chip.active .date-chip-month {
    color: var(--color-accent-ink);
  }
}

/* Toolbar: filters + sort */

.results-toolbar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-12) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.results-count {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--fs-body);
  color: var(--color-navy);
}

.results-sort {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.results-sort label {
  font-size: var(--fs-small);
  color: var(--color-text-muted);
}

.results-sort select {
  min-width: 205px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 38px 10px 14px;
  font-family: var(--font-heading);
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--color-text-body);
  background-color: var(--color-white);

  appearance: none;
  -webkit-appearance: none;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748B' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  background-repeat: no-repeat;
  background-position: right 14px center;

  cursor: pointer;

  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast);
}

.results-sort select:hover {
  border-color: var(--color-navy-cta);
}

.results-sort select:focus {
  outline: none;
  border-color: var(--color-navy-cta);
  box-shadow: 0 0 0 3px rgba(0, 53, 128, 0.12);
}

/* Bus list */

.bus-list {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-12) var(--space-12);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.bus-list-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  display: grid;
  grid-template-columns: 270px 1fr auto;
  align-items: center;
  gap: var(--space-6);
  transition: box-shadow var(--duration-fast);
}

.bus-list-card:hover {
  box-shadow: var(--shadow-route-card);
}

.bus-operator-col {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.bus-photo-wrap {
  width: 150px;
  height: 92px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-tag-bg);
  border: 1px solid var(--color-border);
  display: block;
  position: relative;
}

.bus-photo-wrap img.bus-result-photo {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 0 !important;
  display: block;
}

.bus-operator-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bus-operator-link {
  text-decoration: none;
  color: inherit;
}

.bus-operator-link h3 {
  margin: 0;
}

.bus-name {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.bus-operator-col img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  object-fit: cover;
  border: 1px solid var(--color-border);
  background: var(--color-tag-bg);
  flex-shrink: 0;
}

.bus-operator-col h3 {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: 2px;
}

.bus-operator-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.bus-schedule-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  /* This is the middle column of .bus-list-card's 270px/1fr/auto grid.
     A grid item's default min-width is auto (= its content's intrinsic
     width), so a long boarding/dropping stops line here could force
     this 1fr track wider than the space actually available, pushing
     the price/seats-left/button column off the right edge of the card
     (and the whole page horizontally scrollable) instead of wrapping.
     min-width: 0 lets the track actually shrink to fit. */
  min-width: 0;
}

.bus-schedule-times {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.bus-schedule-times .time {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  color: var(--color-navy);
}

.bus-schedule-times .duration-line {
  flex: 1 0 0;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bus-schedule-times .duration-line span {
  font-size: 11px;
  color: var(--color-text-muted);
}

.bus-schedule-times .duration-line .line {
  width: 100%;
  height: 1px;
  background: var(--color-border);
  position: relative;
}

.bus-schedule-times .duration-line .line::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-text-muted);
}

.bus-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.bus-price-col {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.bus-price-col .price {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 24px;
  color: var(--color-navy);
}

.bus-price-col .seats-left {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.bus-price-col .seats-left.low {
  color: #dc2626;
  font-weight: 600;
}

.bus-select-btn {
  background: var(--color-navy-cta);
  color: var(--color-overlay-text);
  border-radius: var(--radius-md);
  padding: 11px 24px;
  font-weight: 500;
  font-size: var(--fs-small);
  white-space: nowrap;
}

.bus-select-btn:hover {
  background: var(--color-navy-cta-hover);
}

@media (max-width: 1024px) {
  .bus-list-card {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .bus-photo-wrap {
    width: 100%;
    height: 160px;
  }

  .bus-operator-col {
    /* .bus-photo-wrap goes to width:100% right below - if this stays a
       row, the info block has no room left and overflows/overlaps the
       photo (the operator name getting squeezed against the edge). */
    flex-direction: column;
    align-items: stretch;
  }

  .bus-price-col {
    /* A row here squeezes price + seats-left + button into one cramped
       line at phone widths. Stack them and make the CTA a full-width
       tappable button - the standard mobile booking-card pattern. */
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-start;
    gap: var(--space-2);
    width: 100%;
  }

  .bus-price-col .price {
    text-align: left;
  }

  .bus-price-col .seats-left {
    text-align: left;
  }

  .bus-select-btn {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 900px) {
  .search-summary-bar {
    padding: var(--space-6) 20px;
  }

  .search-summary-inner {
    flex-direction: column;
    align-items: stretch;
  }

  /* See the note above .search-summary-field--location: once this
     container is a column, a leftover pixel flex-basis becomes a fixed
     height instead of a width. Reset it here. */
  .search-summary-field,
  .search-summary-field--location,
  .search-summary-field--date {
    flex: 1 1 auto;
  }

  .search-summary-swap {
    display: none;
  }

  .results-toolbar,
  .bus-list {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (max-width: 640px) {
  .results-toolbar,
  .bus-list {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .bus-schedule-times {
    flex-wrap: wrap;
  }
}

/* --- Advanced filters sidebar --- */
.results-with-filters {
  display: flex;
  gap: 24px;
  max-width: var(--max-width);
  margin: 24px auto 0;
  padding: 0 var(--space-12);
  align-items: flex-start;
}
.results-filters-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--color-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 18px;
  position: sticky;
  top: 90px;
}
.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.filters-header h3 {
  margin: 0;
  font-size: 16px;
}

/* -------------------------------
   Filters toggle (collapsible panel)
   ------------------------------- */

.filters-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--color-navy);
}

.filters-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
}

.filters-chevron {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform var(--duration-fast) ease;
}

.filters-toggle[aria-expanded="true"] .filters-chevron {
  transform: rotate(180deg);
}

.filters-body.filters-collapsed {
  display: none;
}

.filters-body-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--color-navy);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}
.filter-group {
  padding: 14px 0;
  border-top: 1px solid var(--color-border);
}
.filter-group:first-of-type {
  border-top: none;
  padding-top: 0;
}
.filter-group h4 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--color-navy);
}
.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 0;
  cursor: pointer;
  color: var(--color-text-body);
}

.filter-checkbox input[type="checkbox"],
.filter-checkbox input[type="radio"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}
#priceRangeInput {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  outline: none;
}
#priceRangeInput::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-navy-cta);
  cursor: pointer;
  border: 2px solid var(--color-white);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
#priceRangeInput::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-navy-cta);
  cursor: pointer;
  border: 2px solid var(--color-white);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
/* --- Compare feature --- */
.bus-compare-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-body);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  position: absolute;
  /* Floats slightly above the card's own top edge instead of sitting flush
     inside it - that's what left it touching the bus photo right below. */
  top: -12px;
  left: 10px;
  z-index: 2;
}
.bus-list-card {
  position: relative;
}

.compare-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-overlay-bg);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 500;
  box-shadow: var(--shadow-dropdown);
}

/* .btn-outline is styled for light backgrounds (navy text on navy
   border) - on this always-dark bar that made "Clear" invisible in
   every theme. Scoped override, not a change to .btn-outline itself. */
.compare-bar .btn-outline {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.55);
}
.compare-bar .btn-outline:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  width: auto;
}

.compare-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 20px;
}
.compare-modal-overlay.open {
  opacity: 1;
}
.compare-modal-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  padding: 32px;
}
.compare-table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
}
.compare-table td,
.compare-table th {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  font-size: 14px;
}
.compare-table th {
  color: var(--color-navy);
  font-weight: 700;
}
.compare-table td:first-child {
  color: var(--color-text-muted);
  font-weight: 500;
}

@media (max-width: 900px) {
  .results-with-filters {
    flex-direction: column;
    margin-top: 20px;
    padding: 0 var(--space-6);
  }
  .results-filters-sidebar {
    width: 100%;
    position: static;
    height: auto;
    overflow: visible;
  }

  /* The "Filters" chip up in the navy banner already opens this same
     panel - this second header inside the sidebar was a duplicate
     control sitting as a dead-looking full-width bar. Desktop still
     shows it (no chip up there to replace it with). */
  .filters-toggle {
    display: none;
  }

  .filters-body {
    margin-top: 0;
  }

  /* Collapsed by default on mobile/tablet - the filter panel used to
     always render open, pushing the actual bus results far down the
     page. Toggled by #filtersToggleBtn in search-results.js. Desktop
     ignores this class entirely, so the sidebar there stays as before:
     always open. */
  .filters-body.filters-collapsed {
    display: none;
  }
}

@media (max-width: 640px) {
  .results-with-filters {
    margin-top: 16px;
    padding: 0 var(--space-4);
  }

  .filter-checkbox input[type="checkbox"],
  .filter-checkbox input[type="radio"] {
    width: 18px;
    height: 18px;
  }

  .filter-checkbox {
    font-size: 14px;
  }
}

.bus-stops-preview {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

/* ==========================================================================
   Empty state text hierarchy
   ========================================================================== */

.empty-state-title {
  margin: var(--space-2) 0 var(--space-1);
  color: var(--color-navy);
  font-size: 18px;
}

.empty-state-hint {
  margin-top: var(--space-2);
  font-weight: 500;
  color: var(--color-text-body);
}

/* ==========================================================================
   MOBILE BACK BUTTON
   ========================================================================== */

.mobile-back-btn {
  display: none;
}

@media (max-width: 640px) {
  .mobile-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 12px 0 0 16px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-white);
    color: var(--color-navy);
    cursor: pointer;
  }
}
