/* Near-me pages: layout + geo overlay.
   Extracted from resources/views/gemini_near_me.blade.php inline <style>. */

/* Keep the Geo-Overlay styles as they are specific to this page.
   Map layout (padding, flex, etc.) inherits from geminicss body.map-view like town/county/postcode. */
html:has(body.near-me-page),
body.near-me-page {
  overflow-x: hidden;
  width: 100%;
  min-width: 100%;
  margin: 0 !important;
  padding: 0 !important;
}

/* flex-wrap + prices section as first child takes full first row; list|map unchanged below */
body.near-me-page .main-content-wrapper {
  flex-wrap: wrap;
}

/* Desktop: use same height as other map pages.
   Near-me renders the national prices overview *inside* the wrapper; shrinking the wrapper here
   truncates the map/list region unnecessarily. */
body.near-me-page.device-desktop .main-content-wrapper,
body.near-me-page:not(.device-mobile) .main-content-wrapper {
  /* Runtime-measured so desktop map height stays correct across font sizes / header wrapping */
  height: calc(100vh - var(--fcf-near-me-top, 220px)) !important;
  flex-wrap: nowrap; /* Ensure list+map stay side-by-side and get full height for scroll */
  /* geminicss desktop adds padding-bottom:50px to protect footer; Near Me already accounts for footer in the measurement */
  padding-bottom: 0 !important;
}

body.near-me-page.device-desktop .list-column-wrapper,
body.near-me-page:not(.device-mobile) .list-column-wrapper {
  min-height: 0; /* Allow flex child to shrink so #list-container can scroll */
}

/* Mobile only: full-width layout (desktop needs list 420px + map side-by-side) */
body.near-me-page.device-mobile .town-header-container {
  border-bottom: none;
}

body.near-me-page.device-mobile .header,
body.near-me-page.device-mobile .town-header-container,
body.near-me-page.device-mobile main,
body.near-me-page.device-mobile .main-content-wrapper,
body.near-me-page.device-mobile .list-column-wrapper,
body.near-me-page.device-mobile .main-container,
body.near-me-page.device-mobile .map-container {
  max-width: 100% !important;
  width: 100% !important;
  min-width: 0; /* Prevent flex/grid items from overflowing */
  box-sizing: border-box;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/*
  iPad portrait: UA is often "desktop" but matchMedia adds body.viewport-mobile.
  The rules above for :not(.device-mobile) force a fixed height + desktop split; that fights
  geminicss map-view mobile flex and can collapse .map-container / .geo-overlay (no visible location UI).
  Mirror device-mobile full-width and drop the fixed desktop height when viewport-mobile is active.
*/
body.near-me-page.viewport-mobile .town-header-container {
  border-bottom: none;
}

body.near-me-page.viewport-mobile .header,
body.near-me-page.viewport-mobile .town-header-container,
body.near-me-page.viewport-mobile main,
body.near-me-page.viewport-mobile .main-content-wrapper,
body.near-me-page.viewport-mobile .list-column-wrapper,
body.near-me-page.viewport-mobile .main-container,
body.near-me-page.viewport-mobile .map-container {
  max-width: 100% !important;
  width: 100% !important;
  min-width: 0;
  box-sizing: border-box;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.near-me-page.viewport-mobile:not(.device-mobile) .main-content-wrapper,
body.near-me-page.viewport-mobile.device-desktop .main-content-wrapper {
  height: auto !important;
  min-height: 0 !important;
  flex: 1 1 0 !important;
  flex-wrap: nowrap;
}

/* Guard: ensure wrapper stays a flex column and map container has height in viewport-mobile. */
body.near-me-page.viewport-mobile .main-content-wrapper {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 0 !important;
  min-height: 0 !important;
}

body.near-me-page.viewport-mobile.map-view .map-container {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

body.near-me-page.viewport-mobile.map-view #map {
  flex: 1 1 0 !important;
  min-height: 160px !important; /* if everything collapses, force a visible map box */
}

/* If the national prices <details> is opened, keep it from consuming the whole viewport on iPad portrait. */
body.near-me-page.viewport-mobile #town-prices-overview {
  max-height: 30vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 0 0 auto;
}

body.near-me-page.viewport-mobile #town-prices-overview .prices-overview-data {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ensure main fills the column when viewport-mobile (avoids flex collapse after class is applied) */
body.near-me-page.viewport-mobile.map-view main {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.geo-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box; /* Prevents width plus padding from exceeding 100% */
  background-color: rgba(240, 240, 240, 0.9);
  /* Above Leaflet tiles and fixed footer (3000); below favourites modal (3002) and location modal (3200) */
  z-index: 3001;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  padding: 20px;
  overflow-y: auto;
}

.geo-overlay .geo-btn {
  padding: 15px 30px;
  font-size: 1.2em;
  background-color: #005a6a;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: background-color 0.2s;
  margin-top: 12px;
}

.geo-overlay .geo-btn.geo-btn-inline {
  padding: 8px 16px;
  font-size: 1em;
  margin-top: 0;
}

.geo-overlay .geo-overlay-search-row {
  display: table;
  width: 100%;
  table-layout: auto;
  margin: 12px 0 2px 0;
}

.geo-overlay .geo-overlay-search-row .geo-overlay-search-label {
  display: table-cell;
  vertical-align: middle;
  white-space: nowrap;
  padding-right: 10px;
}

.geo-overlay .geo-overlay-search-row .search-box-container {
  display: table-cell;
  vertical-align: middle;
  max-width: 280px;
}

.geo-overlay .geo-overlay-button-row {
  margin-top: 14px;
}

.geo-overlay .geo-overlay-search-row .main-search-input {
  padding: 8px 40px 8px 12px;
  line-height: 1.4;
  box-sizing: border-box;
}

.geo-btn:hover {
  background-color: #004550;
}

.geo-btn:disabled {
  background-color: #888;
  cursor: not-allowed;
}

.error-msg {
  color: #c60018;
  margin-top: 10px;
  font-weight: bold;
  display: none;
}

/* Search box in overlay */
.geo-overlay .search-box-container {
  width: 100%;
  max-width: 500px;
}

.geo-overlay .live-search-wrapper {
  position: relative;
}

.geo-overlay .main-search-input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  font-size: 1em;
  border: 2px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
}

.geo-overlay .main-search-input:focus {
  outline: none;
  border-color: #005a6a;
}

.geo-overlay .search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 3000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.geo-overlay .search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.geo-overlay .search-result-item:hover {
  background-color: #f0f7f8;
}

.geo-overlay .search-result-item:last-child {
  border-bottom: none;
}

.geo-overlay h2 {
  background: none;
  color: #005a6a;
}

/* National prices section – card-style container. Desktop: full first row (list|map below).
   Mobile: flex 0 0 auto so it doesn't steal height from the map. */
.prices-overview-section {
  background-color: transparent;
  border: none;
  box-shadow: none;
  padding: 0 15px;
  margin: 10px auto;
  max-width: 600px;
  box-sizing: border-box;
}

body.near-me-page .prices-overview-section.prices-overview-desktop {
  flex: 0 0 100%;
  max-width: 600px;
}

body.near-me-page .prices-overview-section.prices-overview-mobile {
  flex: 0 0 auto;
}

.prices-overview-section summary {
  font-weight: 600;
  color: #006666;
  background: none;
  cursor: pointer;
  font-size: 1.1rem;
  text-align: center;
  outline: none;
}

.prices-overview-section .prices-overview-data {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.prices-overview-section .price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed #e2e8f0;
  color: #444;
}

.prices-overview-section .price-row:last-child {
  border-bottom: none;
}

.prices-overview-section .price-disclaimer {
  text-align: center;
  margin-top: 16px;
  color: #666;
}

.prices-overview-section .price-disclaimer small {
  font-size: 0.85em;
}
