/* ═══════════════════════════════════════════════════════════════════════
   MOBILE FULL-SCREEN MAP OVERLAY
   Applies only on ≤768px screens during the draw step.
   Does NOT affect desktop layout (≥769px) in any way.
   Z-index stack:
     50  – map stage (position:fixed behind everything)
     60  – draw-screen wrapper (transparent, pointer-events:none)
     65  – mob-map-overlay children (interactive overlays)
    110  – mob-map-dock + mob-more-menu (above bottom-nav z-index:100)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 0. Mobile overlay is always hidden unless activated ── */
.mob-map-overlay {
  display: none !important;
}

/* ── 1. DESKTOP: No changes — overlay stays hidden ── */
@media (min-width: 769px) {
  .mob-map-overlay {
    display: none !important;
  }
}

/* Customer quote maps: hide base/layer selector controls. */
body[data-active-view="quote"] #quoteMap .turflynk-base-align-control,
body[data-active-view="quote"] #quoteMap .layer-selector,
body[data-active-view="quote"] #quoteMap .basemap-selector,
body[data-active-view="quote"] #quoteMap .base-layer-selector,
body[data-active-view="quote"] #quoteMap .map-layer-selector,
body[data-active-view="quote"] #quoteMap #layerSelector,
body[data-active-view="quote"] #quoteMap #basemapSelector,
body[data-active-view="quote"] #quoteMap #mapBaseAlignmentSelect {
  display: none !important;
}

/* Draw step: remove default MapLibre zoom UI clutter. */
body[data-active-view="quote"][data-quote-flow-step="draw"] #quoteMap .maplibregl-ctrl-zoom,
body[data-active-view="quote"][data-quote-flow-step="draw"] #quoteMap .maplibregl-ctrl-group:has(.maplibregl-ctrl-zoom-in),
body[data-active-view="quote"][data-quote-flow-step="draw"] #quoteMap .maplibregl-ctrl-group:has(.maplibregl-ctrl-zoom-out),
body[data-active-view="quote"][data-quote-flow-step="draw"] #quoteMap .maplibregl-ctrl-top-left > .maplibregl-ctrl-group {
  display: none !important;
}

/* ════════════════════════════════════════════════════════════
   2. MOBILE DRAW STEP: Full-screen map + floating overlay UI
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── 2a. Prevent body scroll while in full-screen map mode ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] {
    overflow: hidden !important;
  }

  /* ── 2b. Lock the main-shell so content behind map doesn't scroll ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] .main-shell {
    overflow: hidden !important;
    padding: 0 !important;
  }

  /* ── 2c. Hide quote stepper + step header (replaced by mob title pill) ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] .quote-stepper,
  body[data-active-view="quote"][data-quote-flow-step="draw"] .qsf-header {
    display: none !important;
  }

  /* ── 2d. Hide the app-topbar in full-screen draw mode ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] .app-topbar {
    display: none !important;
  }

  /* ── 2e. Hide the mobile bottom nav (replaced by the dock CTA) ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] :is(.mobile-nav, .mobile-bottom-nav) {
    display: none !important;
  }

  /* ── 2f. Map stage: position:fixed, edge-to-edge ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] #quoteStartScreen.is-map-host-visible .map-stage {
    position: fixed !important;
    inset: 0 !important;
    height: 100svh !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: 0 !important;
    margin: 0 !important;
    z-index: 50 !important;
    box-shadow: none !important;
  }

  body[data-active-view="quote"][data-quote-flow-step="draw"] #quoteStartScreen.is-map-host-visible .map-panel,
  body[data-active-view="quote"][data-quote-flow-step="draw"] #quoteMap {
    height: 100% !important;
    min-height: 100% !important;
    max-height: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  /* ── 2g. Draw screen: transparent, fixed, full-viewport overlay ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] .draw-screen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 60 !important;
    background: transparent !important;
    pointer-events: none !important;
    display: block !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
  }

  /* ── 2h. Hide the desktop draw-controls-panel on mobile ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] .draw-controls-panel {
    display: none !important;
  }

  /* ── 2i. Override theme-premium mobile toolbar at ≤600px so it doesn't conflict ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] #mapToolsPanel:not(.hidden) {
    display: none !important;
  }

  /* ── 2i-b. Suppress MapLibre cooperative-gesture screen on mobile draw step ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] .maplibregl-cooperative-gesture-screen,
  body[data-active-view="quote"][data-quote-flow-step="draw"] .maplibregl-cooperative-gesture-screen__content {
    display: none !important;
  }

  /* ── 2j. Activate the mobile overlay ── */
  body[data-active-view="quote"][data-quote-flow-step="draw"] .mob-map-overlay {
    display: block !important;
    pointer-events: none; /* re-enabled per-child below */
    position: fixed !important;
    inset: 0 !important;
    z-index: 65 !important;
    overflow: hidden;
  }

}

/* ══════════════════════════════════════════════════════════
   3. MOBILE OVERLAY COMPONENT STYLES
   Always defined (safe: hidden on desktop by section 0/1)
   ══════════════════════════════════════════════════════════ */

/* Glass pill mixin (reused across overlays) */
.mob-glass-pill {
  background: rgba(18, 20, 18, 0.72);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

/* ── 3a. Top bar ── */
.mob-map-topbar {
  position: absolute;
  top: env(safe-area-inset-top, 0px);
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 6px;
  pointer-events: auto;
  z-index: 66;
  margin-top: 8px;
}

.mob-map-back {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(18, 20, 18, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

.mob-map-back .ui-icon {
  width: 18px;
  height: 18px;
  filter: invert(1);
  opacity: 0.92;
}

.mob-map-title-pill {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 14px;
  background: rgba(18, 20, 18, 0.72);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

.mob-map-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #f0f7eb;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mob-map-subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(200, 220, 195, 0.75);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 3b. Address pill ── */
.mob-map-addr-pill {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  left: 10px;
  right: 60px; /* leave space for compass */
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 7px 12px;
  background: rgba(18, 20, 18, 0.72);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  z-index: 66;
}

.mob-addr-pin {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  filter: invert(0.8) sepia(1) hue-rotate(70deg) saturate(2);
  opacity: 0.85;
}

.mob-addr-text {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(220, 235, 215, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mob-addr-gps-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(74, 124, 47, 0.35);
  cursor: pointer;
  padding: 0;
}

.mob-addr-gps-btn .ui-icon {
  width: 14px;
  height: 14px;
  filter: invert(1);
  opacity: 0.9;
}

.mob-addr-gps-btn[aria-busy="true"] .ui-icon {
  animation: mob-spin 1s linear infinite;
}

/* ── 3c. Compass ── */
.mob-map-compass {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  right: 12px;
  width: 42px;
  height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(18, 20, 18, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  pointer-events: auto;
  z-index: 66;
  padding: 0;
}

.mob-compass-svg {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
}

.mob-compass-n {
  display: none; /* label hidden, compass needle speaks for itself */
}

/* ── 3d. Zoom rail (right side, below compass) ── */
.mob-map-zoom-rail {
  position: absolute;
  right: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 114px);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 20, 18, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  z-index: 66;
}

.mob-map-ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.mob-map-ctrl-btn .ui-icon {
  width: 18px;
  height: 18px;
  filter: invert(1);
  opacity: 0.88;
}

.mob-map-ctrl-btn:active {
  background: rgba(74, 124, 47, 0.3);
}

.mob-zoom-divider {
  width: 28px;
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
}

/* ── 3e. Estimate badge (center-left, above dock) ── */
.mob-map-est-badge {
  position: absolute;
  left: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 148px);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: rgba(18, 20, 18, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(200, 220, 195, 0.85);
  pointer-events: none;
  z-index: 66;
  transition: opacity 0.2s;
}

.mob-map-est-badge strong {
  color: #7dcd50;
  font-weight: 900;
}

.mob-map-est-badge[data-empty="true"] {
  opacity: 0;
  pointer-events: none;
}

/* ── 3f. Bottom dock ── */
.mob-map-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 110;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px) 0;
  background: rgba(14, 18, 14, 0.88);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.36);
}

/* ── 3g. More menu (expands above dock) ── */
.mob-more-menu {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 10px 10px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(14, 18, 14, 0.92);
  animation: mob-menu-in 0.16s ease-out;
}

.mob-more-menu[hidden] {
  display: none !important;
}

@keyframes mob-menu-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mob-more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(220, 235, 215, 0.88);
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  min-height: 56px;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s;
}

.mob-more-item:active,
.mob-more-item:hover {
  background: rgba(74, 124, 47, 0.22);
  border-color: rgba(74, 124, 47, 0.4);
}

.mob-more-item .ui-icon {
  width: 18px;
  height: 18px;
  filter: invert(1);
  opacity: 0.82;
}

/* ── 3h. Primary tool rail ── */
.mob-tool-rail {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 2px;
  padding: 8px 6px 4px;
}

.mob-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  min-height: 54px;
  max-width: 80px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(220, 235, 215, 0.82);
  font-size: 0.64rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s, color 0.12s;
}

.mob-tool-btn:active,
.mob-tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.mob-tool-btn.mob-active-tool {
  color: #7dcd50;
  background: rgba(74, 124, 47, 0.2);
}

.mob-tool-btn .ui-icon {
  width: 20px;
  height: 20px;
  filter: invert(1);
  opacity: 0.82;
}

.mob-tool-btn.mob-active-tool .ui-icon {
  opacity: 1;
  filter: invert(0.8) sepia(1) hue-rotate(70deg) saturate(2.5);
}

/* AI Detect — green accent */
.mob-tool-ai {
  color: #7dcd50;
}

.mob-tool-ai .ui-icon {
  filter: invert(0.75) sepia(1) hue-rotate(70deg) saturate(2.5);
  opacity: 1;
}

.mob-tool-ai[aria-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
}

.mob-tool-ai[aria-busy="true"] .ui-icon {
  animation: mob-spin 1s linear infinite;
}

/* More button — highlight when menu open */
.mob-tool-more[aria-expanded="true"] {
  color: #7dcd50;
  background: rgba(74, 124, 47, 0.18);
}

/* ── 3i. CTA button ── */
.mob-map-cta-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: calc(100% - 24px);
  margin: 6px 12px 10px;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #4a7c2f 0%, #3d6826 100%);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 18px rgba(61, 104, 38, 0.45);
  transition: opacity 0.15s, transform 0.1s;
}

.mob-map-cta-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.mob-map-cta-btn[disabled],
.mob-map-cta-btn[aria-busy="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.mob-cta-label {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.mob-cta-sub {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.75;
  line-height: 1.2;
}

/* ── 3j. Spinner animation ── */
@keyframes mob-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── 3k-0. Gesture hint pill: replaces MapLibre cooperative-gesture popup ── */
#mobGestureHint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 184px);
  white-space: nowrap;
  padding: 7px 16px;
  background: rgba(18, 20, 18, 0.82);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.32);
  font-size: 0.74rem;
  font-weight: 600;
  color: rgba(220, 235, 215, 0.88);
  pointer-events: none;
  z-index: 67;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#mobGestureHint.mob-hint-visible {
  opacity: 1;
}

/* ── 3k. Lasso drawing: collapse dock so drawing handles are fully accessible ── */
body[data-lasso-armed="true"][data-active-view="quote"][data-quote-flow-step="draw"] .mob-map-dock,
body[data-lasso-drawing="true"][data-active-view="quote"][data-quote-flow-step="draw"] .mob-map-dock {
  transform: translateY(100%);
  transition: transform 0.18s ease;
  pointer-events: none;
}

/* When lasso is NOT active, restore dock */
body[data-active-view="quote"][data-quote-flow-step="draw"]:not([data-lasso-armed="true"]):not([data-lasso-drawing="true"]) .mob-map-dock {
  transform: translateY(0);
  transition: transform 0.18s ease;
}

/* Floating Finish button: shown only while drawing a lasso stroke */
.mob-lasso-finish-float {
  display: none;
}

body[data-lasso-drawing="true"][data-active-view="quote"][data-quote-flow-step="draw"] .mob-lasso-finish-float {
  display: flex;
  position: fixed;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 115;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  background: #4a7c2f;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 800;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(61, 104, 38, 0.5);
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
}

/* ── 3l. Estimate badge: shift up when dock is taller ── */
@media (max-height: 640px) {
  .mob-map-est-badge {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 170px);
  }
}
