/**
 * PropGlen MOBILE-UX-R1
 * Public mobile corrections. Loaded after propglen-mobile-ux-consistency-01.css.
 * Does not restyle cookie consent or the Agent Directory.
 */

/* —— 1. Rental search: one Sort, the floating bar —— */
@media (max-width: 900px) {
  html body.listings-page.bayut-serp-page:not(.sale-page):not(.commercial-page) .bayut-serp__toolbar .bayut-sort.filter-select {
    display: none !important;
  }

  html body.listings-page.bayut-serp-page:not(.sale-page):not(.commercial-page) .bayut-mobile-bar {
    display: grid;
  }

  html body.listings-page.bayut-serp-page:not(.sale-page):not(.commercial-page) .bayut-serp__toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  html body.listings-page.bayut-serp-page:not(.sale-page):not(.commercial-page) .bayut-serp__toolbar-actions .bayut-view-toggle {
    flex: 1 1 9.5rem;
    min-width: 0;
    margin-left: auto;
  }
}

/* —— 2. Bottom nav: restrained glass, WhatsApp control as the reference —— */
@media (max-width: 959px) {
  .mobile-app-nav {
    gap: 4px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 22px;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.72) inset,
      0 8px 22px rgba(16, 24, 40, 0.12);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
  }

  .mobile-app-nav a:not(:last-child) {
    border-right: 0;
  }

  .mobile-app-nav a {
    min-height: 44px;
    border-radius: 16px;
  }

  .mobile-app-nav__icon {
    width: 44px;
    height: 32px;
    border-radius: 999px;
  }

  .mobile-app-nav a[aria-current="page"] .mobile-app-nav__icon {
    box-shadow: 0 6px 16px rgba(11, 163, 96, 0.28);
  }

  .mobile-app-nav a:focus-visible {
    outline: 2px solid rgba(11, 163, 96, 0.55);
    outline-offset: 2px;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .mobile-app-nav {
    background: rgba(255, 255, 255, 0.96);
  }
}

/* —— 3. Inputs stay at least 16px so iOS does not zoom on focus —— */
@media (max-width: 900px) {
  html body:not([class*="staff-"]):not([class*="admin-"]):not([class*="agent-auth"]):not([class*="agent-app"]):not([class*="portal-app"]) input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="file"]):not([type="image"]),
  html body:not([class*="staff-"]):not([class*="admin-"]):not([class*="agent-auth"]):not([class*="agent-app"]):not([class*="portal-app"]) select,
  html body:not([class*="staff-"]):not([class*="admin-"]):not([class*="agent-auth"]):not([class*="agent-app"]):not([class*="portal-app"]) textarea,
  html body:not([class*="staff-"]):not([class*="admin-"]):not([class*="agent-auth"]):not([class*="agent-app"]):not([class*="portal-app"]) .custom-select-trigger {
    font-size: max(16px, 1rem);
  }
}

/* —— 4. Popup Close labels stay readable —— */
.image-viewer-close,
.bayut-mobile-filters__close,
.rv-saved-search-dialog__close,
.rv-badge-dialog-close,
#ask-close,
.detail-quick-actions-close {
  width: auto;
  min-width: 44px;
  min-height: 44px;
  height: auto;
  padding: 0 14px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.1;
}

.detail-quick-actions-close__x {
  display: none;
}

.leaflet-popup-close-button,
.bayut-map-leaflet-popup .leaflet-popup-close-button,
.leaflet-popup.bayut-map-popup-dock .leaflet-popup-close-button {
  width: auto !important;
  min-width: 44px;
  height: auto !important;
  min-height: 36px;
  padding: 6px 10px !important;
  font-size: 0.85rem !important;
  font-weight: 700;
  line-height: 1.2 !important;
  text-decoration: none !important;
}

.bayut-map-popup__title,
.bayut-map-popup__body {
  padding-right: 4.75rem;
}

/* —— 5. Compact popup Enquire —— */
.bayut-map-popup__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.bayut-map-popup__enquire {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  color: #fff;
  background: #0ba360;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(11, 163, 96, 0.28);
  text-decoration: none;
}

.bayut-map-popup[data-card-segment="for_sale"] .bayut-map-popup__enquire {
  background: #062b5b;
  box-shadow: 0 6px 16px rgba(6, 43, 91, 0.22);
}

.bayut-map-popup__enquire svg {
  width: 18px;
  height: 18px;
  display: block;
}

.bayut-map-popup__enquire:focus-visible {
  outline: 2px solid rgba(11, 163, 96, 0.55);
  outline-offset: 2px;
}

.bayut-map-popup__actions .bayut-map-popup__cta {
  flex: 1 1 auto;
  min-height: 44px;
}

.leaflet-container .bayut-map-popup a.bayut-map-popup__enquire,
.leaflet-container .bayut-map-popup a.bayut-map-popup__enquire:visited {
  color: #fff !important;
  background-color: #0ba360 !important;
  text-decoration: none !important;
}

.leaflet-container .bayut-map-popup[data-card-segment="for_sale"] a.bayut-map-popup__enquire,
.leaflet-container .bayut-map-popup[data-card-segment="for_sale"] a.bayut-map-popup__enquire:visited {
  background-color: #062b5b !important;
}

/* —— 6. "Swipe for more" uses the same inset as .container —— */
@media (max-width: 959px) {
  .sale-detail-page [data-sale-similar]::after,
  .sale-detail-page [data-sale-recent]::after {
    width: min(100% - 32px, var(--container, 1160px));
    margin-right: auto;
    margin-left: auto;
    padding-left: 0;
    box-sizing: border-box;
    text-align: left;
  }
}

@media (max-width: 760px) {
  .sale-detail-page [data-sale-similar]::after,
  .sale-detail-page [data-sale-recent]::after {
    width: min(100% - 24px, var(--container, 1160px));
  }
}

@media (max-width: 520px) {
  .sale-detail-page [data-sale-similar]::after,
  .sale-detail-page [data-sale-recent]::after {
    width: min(100% - 20px, var(--container, 1160px));
  }
}

/* —— 7. Map attribution on the map edge; labels and CTAs stay usable —— */
@media (max-width: 900px) {
  body.upm-map-body .leaflet-bottom,
  body.bayut-map-body .leaflet-bottom,
  body.map-body .leaflet-bottom,
  body.map-page .leaflet-bottom,
  .unified-map-page .leaflet-bottom,
  body.listings-page.is-mobile-map-view .leaflet-bottom {
    bottom: 0 !important;
    margin-bottom: 0 !important;
  }

  body.upm-map-body .leaflet-bottom.leaflet-right,
  body.bayut-map-body .leaflet-bottom.leaflet-right,
  body.listings-page.is-mobile-map-view .leaflet-bottom.leaflet-right {
    width: auto;
    max-width: 11.5rem;
  }

  body.upm-map-body .leaflet-control-attribution,
  body.bayut-map-body .leaflet-control-attribution,
  body.listings-page.is-mobile-map-view .leaflet-control-attribution,
  body.listing-detail-page .leaflet-control-attribution {
    margin: 0 4px 4px 0 !important;
    padding: 2px 6px;
    width: max-content;
    max-width: 11rem;
    font-size: 11px;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: break-word;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.92);
    color: #344054;
  }

  body.upm-map-body .leaflet-control-attribution a,
  body.bayut-map-body .leaflet-control-attribution a,
  body.listings-page.is-mobile-map-view .leaflet-control-attribution a {
    color: #062b5b;
  }

  body.upm-map-body .upm-live .upm-map-disclaimer,
  body.upm-map-body .upm-map-disclaimer,
  body.bayut-map-body .bayut-map-disclaimer,
  body.bayut-map-body .upm-map-disclaimer {
    left: 8px;
    right: auto;
    bottom: 8px;
    max-width: calc(100% - 12.5rem);
    pointer-events: none;
  }

  body.upm-map-body .leaflet-control-zoom,
  body.listings-page.is-mobile-map-view .leaflet-bottom.leaflet-right .leaflet-control-zoom {
    margin-bottom: 28px;
  }

  body.upm-map-body .upm-map-tools {
    top: 8px;
    left: 46px;
    right: auto;
    max-width: calc(46% - 40px);
    z-index: 650;
  }

  body.upm-map-body .upm-map-tools .upm-btn {
    max-width: 100%;
    min-height: 44px;
    white-space: normal;
    text-align: center;
  }

  body.upm-map-body .upm-legend {
    top: 8px;
    right: 8px;
    left: auto;
    max-width: calc(48% - 16px);
    grid-template-columns: 1fr;
    z-index: 651;
  }

  body.upm-map-body .upm-legend__item {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.upm-map-body .upm-cluster__glyph {
    right: 0;
    bottom: 0;
  }

  body.upm-map-body .upm-seg {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  body.upm-map-body .upm-seg button,
  body.upm-map-body .upm-card__details,
  body.upm-map-body .upm-card__actions .bayut-card__fav,
  body.upm-map-body .upm-btn {
    min-height: 44px;
    position: relative;
    z-index: 2;
  }

  body.upm-map-body .upm-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  body.listings-page.is-mobile-map-view .bayut-map-pin__price,
  body.bayut-map-body .bayut-map-pin__price {
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* —— 8. Floating chrome stays off enquiry controls and open popups —— */
@media (max-width: 900px) {
  .bayut-mobile-bar {
    z-index: 34;
  }

  .askglen-fab,
  .askglen-fab-dock {
    z-index: 33;
  }

  body:has(dialog[open]) .bayut-mobile-bar,
  body:has(dialog[open]) .mobile-app-nav,
  body:has(dialog[open]) .detail-mobile-cta,
  body:has(dialog[open]) .askglen-fab,
  body:has(.ask-drawer:not([hidden])) .bayut-mobile-bar,
  body:has(.ask-drawer:not([hidden])) .mobile-app-nav,
  body:has(.image-viewer:not([hidden])) .bayut-mobile-bar,
  body:has(.image-viewer:not([hidden])) .mobile-app-nav {
    pointer-events: none;
  }

  body.listing-detail-page .detail-enquiry-dialog-panel,
  body.listing-detail-page .detail-quick-actions-sheet,
  .rv-saved-search-dialog__panel,
  .rv-badge-dialog-panel {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  body.listing-detail-page .detail-enquiry-section,
  body.listing-detail-page [data-listing-lead-form],
  body.listing-detail-page [data-listing-enquiry-form] {
    scroll-margin-bottom: calc(var(--pg-ux01-detail-cta-h, 64px) + var(--mobile-nav-clearance, 90px) + 16px);
  }

  body.listings-page.is-mobile-map-view .bayut-serp__map-panel > .leaflet-popup.bayut-map-leaflet-popup,
  body.listings-page.is-mobile-map-view .leaflet-popup.bayut-map-leaflet-popup.bayut-map-popup-dock {
    bottom: calc(var(--mobile-filter-bar-height, 52px) + 10px) !important;
    max-height: calc(100% - var(--mobile-filter-bar-height, 52px) - 18px) !important;
  }
}

/* —— COMMERCIAL-MOBILE-UX-F1 (24 Nov 2026) ——
 * Commercial Rentals only. Mirrors accepted Residential mobile Sort / toolbar.
 * Does not alter Residential (:not(.commercial-page) rules above stay intact).
 */
@media (max-width: 900px) {
  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar .bayut-sort.filter-select {
    display: none !important;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-mobile-bar {
    display: grid;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar {
    min-height: 0;
    gap: 8px;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 0;
    margin-top: 0;
    grid-template-columns: none;
    grid-template-areas: none;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar-actions .bayut-saved-chip {
    grid-area: auto;
    flex: 0 0 auto;
    min-height: 44px;
    height: 44px;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar-actions .bayut-view-toggle {
    display: grid;
    grid-area: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex: 1 1 9.5rem;
    width: auto;
    min-width: 0;
    max-width: none;
    margin-left: auto;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar-actions .bayut-view-toggle__btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    height: 44px;
    padding-inline: 6px;
  }
}

@media (max-width: 430px) {
  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar {
    padding: 10px 10px 12px;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__count {
    min-height: 0;
    padding-bottom: 6px;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar-actions .bayut-view-toggle__btn {
    font-size: 0.8rem;
  }
}

@media (max-width: 360px) {
  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar-actions {
    gap: 6px;
  }

  html body.commercial-page.listings-page.bayut-serp-page .bayut-serp__toolbar-actions .bayut-view-toggle {
    flex: 1 1 100%;
    margin-left: 0;
  }
}
