/* ============================================================
   MOBILE LISTING HEADER (mobile-listing.css)
   ------------------------------------------------------------
   Styles for the phone-only search summary + quick filter bar
   that sits between the hero and the results list on
   pages/html/hourly-hotels/hotel-main-page.php.

   Two blocks are covered:
     1. the search section  -> 3 summary segments (location,
        check-in, duration), the "Search hotels" field and the
        quick filter chips;
     2. the filter/results card -> the compact "N Properties
        Found" card with the live badge.

   Every rule is scoped to <=768px, so the desktop listing page
   is untouched.
   ============================================================ */

/* Above the phone breakpoint the whole phone bar is removed from layout. */
@media (min-width: 769px) {
  #mobileListingBar { display: none !important; }
}

@media (max-width: 768px) {
  /* The compact summary card replaces the tall hero form on phones. The rule
     is gated on html.mlb-active (added with the bar) so a phone that never
     gets the bar - JS blocked, script 404, mount failure - still has the
     original hero search form instead of no search at all. */
  html.mlb-active .hero-header .search-bar-modern,
  html.mlb-active .hero-header .dsb-bar { display: none !important; }

  /* ---------------------------------------------------------
     1. SEARCH SECTION
     --------------------------------------------------------- */
  #mobileListingBar {
    display: block !important;
    padding: 0 12px !important;
    margin: 14px 0 0 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .mlb-row {
    display: block !important;
    width: 100% !important;
  }

  /* --- 1a. Location / Check-in / Duration summary card --- */
  .mlb-card {
    display: flex !important;
    align-items: stretch !important;
    width: 100% !important;
    background: var(--m-card) !important;
    border: 1px solid var(--m-border) !important;
    border-radius: var(--m-radius) !important;
    box-shadow: var(--m-shadow) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .mlb-seg {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0 !important;
    padding: 12px 10px 12px 14px !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    font-family: inherit !important;
    text-align: left !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: background 0.18s ease !important;
  }
  .mlb-seg + .mlb-seg {
    border-left: 1px solid var(--m-border-soft) !important;
  }
  .mlb-seg:active { background: #f6f8fc !important; }

  .mlb-seg i {
    font-size: 0.95rem !important;
    line-height: 1 !important;
    color: var(--m-primary) !important;
    margin: 0 0 8px !important;
    width: auto !important;
    height: auto !important;
    background: none !important;
  }
  .mlb-seg-label {
    display: block !important;
    font-size: 0.58rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.07em !important;
    text-transform: uppercase !important;
    color: var(--m-muted) !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    white-space: normal !important;
  }
  .mlb-seg-value {
    display: block !important;
    margin: 3px 0 0 !important;
    max-width: 100% !important;
    font-size: 0.84rem !important;
    font-weight: 800 !important;
    color: var(--m-text) !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* --- 1b. "Search hotels" field --- */
  .mlb-search {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    height: 48px !important;
    margin: 10px 0 0 !important;
    padding: 0 12px 0 14px !important;
    box-sizing: border-box !important;
    background: var(--m-card) !important;
    border: 1px solid var(--m-border) !important;
    border-radius: 14px !important;
    box-shadow: var(--m-shadow) !important;
  }
  .mlb-search > i.fa-search,
  .mlb-search > i.fas.fa-search {
    font-size: 0.95rem !important;
    color: var(--m-muted) !important;
    flex: 0 0 auto !important;
  }
  .mlb-search-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: 100% !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit !important;
    font-size: 0.92rem !important;
    font-weight: 600 !important;
    color: var(--m-text) !important;
    appearance: none !important;
    -webkit-appearance: none !important;
  }
  .mlb-search-input::placeholder {
    color: var(--m-muted) !important;
    font-weight: 500 !important;
  }
  .mlb-search-clear {
    flex: 0 0 auto !important;
    width: 26px !important;
    height: 26px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #eef1f6 !important;
    border: none !important;
    border-radius: 999px !important;
    color: var(--m-text2, #475569) !important;
    font-size: 0.72rem !important;
    cursor: pointer !important;
  }
  .mlb-search-clear[hidden] { display: none !important; }

  .mlb-date-seg {
    position: relative !important;
  }

  .mlb-native-date {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    font-size: 16px !important;
    opacity: 0 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
  }
  .mlb-native-date::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
  }
  .mlb-date-seg:focus-within {
    outline: 2px solid var(--m-primary, #635bff);
    outline-offset: -2px;
  }
  .mlb-row { position: relative !important; }

  /* --- 1c. Quick filter chips --- */
  .mlb-chips {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 10px 0 0 !important;
    padding: 0 !important;
  }
  .mlb-chip {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    height: 40px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    background: var(--m-card) !important;
    border: 1.5px solid var(--m-border) !important;
    border-radius: var(--m-radius-pill) !important;
    box-shadow: none !important;
    color: var(--m-text) !important;
    font-family: inherit !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease !important;
  }
  .mlb-chip i { font-size: 0.82rem !important; color: var(--m-primary) !important; }
  .mlb-chip span {
    display: block !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-width: 0 !important;
  }
  .mlb-chip:active { background: #f6f8fc !important; }

  /* One chip is a toggle: the pressed state is the filter being on. */
  .mlb-chip.is-active {
    background: #eef2ff !important;
    border-color: var(--m-primary-light) !important;
    color: var(--m-primary-dark) !important;
  }
  .mlb-chip.is-active i { color: var(--m-primary-dark) !important; }

  /* ---------------------------------------------------------
     2. FILTER / RESULTS CARD
     The toolbar (sort, locate, filters) moved into the chips
     above, so the card keeps only the count and the live badge.
     --------------------------------------------------------- */
  .results-header {
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas: "summary badge" !important;
    align-items: center !important;
    padding: 14px !important;
  }
  .results-header .sort-by-section,
  .results-header .nearby-optin,
  .results-header .mobile-filters-toggle {
    display: none !important;
  }
  .results-summary { align-items: center !important; }
  .results-count h3 { white-space: normal !important; }

  /* ---------------------------------------------------------
     3. OPTION SHEET (location / duration / sort)
     --------------------------------------------------------- */
  /* The sheet and its backdrop sit ABOVE the fixed bottom nav (z-index 10050,
     see mobile-app.css) and the sticky book bar (10040). While they were below
     the nav, the nav painted over the sheet's final row - which is why "Thane"
     in Location and "Full Day & Night" in Duration looked like they were
     missing rather than simply out of view. */
  .mlb-sheet-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10075 !important;
    background: rgba(15, 23, 42, 0.45) !important;
    opacity: 0 !important;
    transition: opacity 0.22s ease !important;
  }
  .mlb-sheet-backdrop.show { opacity: 1 !important; }

  .mlb-sheet {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 10080 !important;
    max-height: 78vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background: var(--m-card) !important;
    border-radius: 22px 22px 0 0 !important;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.24) !important;
    transform: translateY(100%) !important;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    /* The sheet covers the bottom nav now, so only the home indicator has to
       be cleared - no 62px nav gap is needed. */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 4px) !important;
  }
  .mlb-sheet.open { transform: translateY(0) !important; }

  .mlb-sheet-head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 16px 18px 12px !important;
    border-bottom: 1px solid var(--m-border-soft) !important;
  }
  .mlb-sheet-head h4 {
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 9px !important;
    font-size: 1rem !important;
    font-weight: 800 !important;
    color: var(--m-text) !important;
  }
  .mlb-sheet-head h4 i { color: var(--m-primary) !important; }
  .mlb-sheet-close {
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f1f5f9 !important;
    border: none !important;
    border-radius: 999px !important;
    color: #475569 !important;
    font-size: 1rem !important;
    cursor: pointer !important;
  }

  .mlb-time-hint {
    margin: 8px 18px !important;
    color: var(--m-muted) !important;
    font-size: 0.85rem !important;
  }
  .mlb-time-periods {
    display: flex !important;
    gap: 8px !important;
    padding: 8px 18px !important;
  }
  .mlb-time-periods button {
    flex: 1 !important;
    padding: 10px !important;
    border: 1px solid var(--m-border) !important;
    border-radius: 10px !important;
    background: var(--m-card) !important;
    color: var(--m-text) !important;
    font: inherit !important;
    cursor: pointer !important;
  }
  .mlb-time-periods button[aria-pressed="true"] {
    background: var(--m-primary) !important;
    color: #fff !important;
  }
  .mlb-sheet-list {
    padding: 8px 12px 18px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  .mlb-option {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    width: 100% !important;
    min-height: 50px !important;
    padding: 12px 14px !important;
    background: transparent !important;
    border: 1.5px solid transparent !important;
    border-radius: 14px !important;
    font-family: inherit !important;
    font-size: 0.92rem !important;
    font-weight: 700 !important;
    color: var(--m-text) !important;
    text-align: left !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }
  .mlb-option:active { background: #f6f8fc !important; }
  .mlb-option.is-selected {
    background: #eef2ff !important;
    border-color: var(--m-primary-light) !important;
    color: var(--m-primary-dark) !important;
  }
  .mlb-option-main {
    display: flex !important;
    align-items: center !important;
    gap: 11px !important;
    min-width: 0 !important;
  }
  .mlb-option-main i { color: var(--m-primary) !important; width: 18px !important; text-align: center !important; }
  .mlb-option-check {
    color: var(--m-primary) !important;
    font-size: 0.95rem !important;
    opacity: 0 !important;
    flex: 0 0 auto !important;
  }
  .mlb-option.is-selected .mlb-option-check { opacity: 1 !important; }

  .mlb-time-sheet {
    left: 12px !important;
    right: 12px !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
    width: calc(100% - 24px) !important;
    max-width: 330px !important;
    max-height: calc(100vh - env(safe-area-inset-bottom, 0px) - 24px) !important;
    max-height: calc(100dvh - env(safe-area-inset-bottom, 0px) - 24px) !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    padding-bottom: 0 !important;
    border: 1px solid #e4e8f0 !important;
    border-radius: 20px !important;
    background: #fff !important;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.22) !important;
    transform: translateY(calc(100% + 24px)) !important;
  }
  .mlb-time-sheet .mlb-sheet-head {
    padding: 14px 16px 12px !important;
    border-bottom-color: #e4e8f0 !important;
  }
  .mlb-time-sheet .mlb-time-hint {
    margin: 5px 0 0 !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
  }
  .mlb-time-sheet .mlb-time-periods {
    margin: 12px 16px 0 !important;
    padding: 4px !important;
    gap: 6px !important;
    border-radius: 999px !important;
    background: #f1f4fa !important;
  }
  .mlb-time-sheet .mlb-time-periods button {
    min-height: 34px !important;
    padding: 6px 8px !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: transparent !important;
    color: var(--m-muted) !important;
    font-size: 0.84rem !important;
    font-weight: 800 !important;
  }
  .mlb-time-sheet .mlb-time-periods button[aria-pressed="true"] {
    background: #fff !important;
    color: var(--m-primary) !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1) !important;
  }
  .mlb-time-sheet .mlb-sheet-list {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    padding: 14px 16px 16px !important;
  }
  .mlb-time-sheet .mlb-option {
    justify-content: center !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 8px 2px !important;
    border: 1.5px solid #e4e8f0 !important;
    border-radius: 12px !important;
    background: #fbfcff !important;
    font-size: 0.8rem !important;
    font-weight: 800 !important;
    text-align: center !important;
    white-space: nowrap !important;
  }
  .mlb-time-sheet .mlb-option.is-selected {
    border-color: var(--m-primary) !important;
    background: var(--m-primary) !important;
    color: #fff !important;
  }
  .mlb-time-sheet .mlb-option-main i,
  .mlb-time-sheet .mlb-option-check {
    display: none !important;
  }
  .mlb-time-sheet .mlb-sheet-list > .mlb-time-hint {
    grid-column: 1 / -1 !important;
    line-height: 1.5 !important;
  }
  .mlb-time-sheet button:focus-visible {
    outline: 2px solid var(--m-primary) !important;
    outline-offset: 2px !important;
  }

  /* Very small phones: tighten the chips so all three stay on one row. */
  @media (max-width: 380px) {
    .mlb-chip {
      padding: 0 10px !important;
      gap: 5px !important;
      font-size: 0.72rem !important;
    }
    .mlb-seg { padding: 11px 8px 11px 11px !important; }
    .mlb-seg-value { font-size: 0.78rem !important; }
  }
}
/* ---------- location notice + "locating" state ----------
   The outcome of "Near me" is reported by an inline, dismissible notice rather
   than by a red error toast: it is actionable (it explains how to re-allow
   location in the browser), it never stacks up, and it does not time out
   before the guest has read it. See showNearbyNotice() in main-page-script.js. */

.nearby-notice {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid #f2d291;
  border-radius: 12px;
  background: #fffaf0;
  color: #6b4b12;
  font-size: 0.8rem;
  line-height: 1.45;
}

.nearby-notice__icon {
  flex: 0 0 auto;
  margin-top: 2px;
  color: #d08b12;
}

.nearby-notice__text {
  margin: 0;
  flex: 1 1 auto;
}

.nearby-notice__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nearby-notice__retry {
  border: 1px solid #e0aa3e;
  background: #fff;
  color: #8a5a00;
  font: inherit;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.nearby-notice__retry:hover { background: #fff3d9; }

.nearby-notice__close {
  border: 0;
  background: none;
  color: #8a5a00;
  font-size: 1.15rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}

/* Inside the phone bar the notice spans the full width, under the chips. */
#mobileListingBar .nearby-notice { margin: 10px 12px 12px; }

/* Toolbar control while a fix is being resolved. */
.nearby-optin.is-loading,
.nearby-optin[aria-busy="true"] {
  opacity: 0.65;
  cursor: progress;
}

.nearby-optin.is-loading i { animation: nearbyPulse 1.1s ease-in-out infinite; }

@keyframes nearbyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* Location segment in the phone bar while the permission popup and the
   device fix are pending. */
.mlb-seg.is-busy { cursor: progress; }
.mlb-seg.is-busy .mlb-seg-value { color: var(--m-primary) !important; }
.mlb-seg.is-busy i { animation: nearbyPulse 1.1s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .nearby-optin.is-loading i,
  .mlb-seg.is-busy i { animation: none; }
}
