/* ---------- Theme variables ---------- */
:root{
  --brand: #007D1C;
  --brand-dark: #006316;
  --brand-light: #19a13a;

  --bg: #f6f7f8;
  --text: #1f2937;

  --header-h: 52px;
  --footer-h: 40px;

  --card: #ffffff;
  --shadow: 0 6px 16px rgba(0,0,0,0.12);
  --soft-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* System fonts for crisp UI */
html, body{
  margin:0; padding:0;
  height:100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
}

/* ---------- Header ---------- */
#header{
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  box-shadow: var(--shadow);
  z-index: 1000;
}

#header p{ margin:0; font-size: 1.05rem; }

/* ---------- Map ---------- */
#map{
  position: absolute;
  top: var(--header-h);
  left: 0; right: 0;
  bottom: var(--footer-h);
  background: #eef2f7;
}

/* Make Leaflet tiles & controls feel a bit crisper */
.leaflet-container{
  font: 14px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* ---------- Footer ---------- */
#footer{
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.12);
  font-size: 12.5px;
  padding: 6px 10px;
  z-index: 1000;
}

#footer p{ margin:0; }
.footer-powered{
  font-size:10px;
  opacity:0.75;
  letter-spacing:0.4px;
}


/* ---------- Layer control polish ---------- */
.leaflet-control-layers{
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.leaflet-control-layers-toggle{
  border-radius: 8px !important;
  box-shadow: var(--soft-shadow);
}

.leaflet-control-layers-expanded{
  padding: 10px 10px 8px 10px;
}

.leaflet-control-layers-separator{
  border-top: 1px solid rgba(0,0,0,0.06);
  margin: 8px 0;
}

/* ---------- Popups & tooltips ---------- */
.leaflet-popup-content{
  margin: 10px 12px;
}

#map .leaflet-popup-content table{
  border-collapse: collapse;
  font-size: 13px;
}

#map .leaflet-popup-content th{
  text-align: left;
  font-weight: 600;
  color: #111827;
  padding: 3px 10px 3px 0;
  white-space: nowrap;
}

#map .leaflet-popup-content td{
  color: #374151;
  padding: 3px 0;
}

.leaflet-popup-content-wrapper{
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.leaflet-popup-tip{
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* ---------- Scale & attribution ---------- */
.leaflet-control-scale{
  background: var(--card);
  border-radius: 6px;
  box-shadow: var(--soft-shadow);
  padding: 2px 6px;
}

.leaflet-control-attribution{
  background: rgba(255,255,255,0.9);
  border-radius: 8px 0 0 0;
  box-shadow: var(--soft-shadow);
}

/* ---------- Marker highlight behavior ---------- */
/* Your JS toggles .highlighted-marker on the marker element */
.leaflet-marker-icon.highlighted-marker{
  transform: scale(1.15);
  transition: transform 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 0 0 3px rgba(255, 221, 0, 0.65);
  border-radius: 50%;
}

/* CircleMarkers get their style from JS, so this adds a soft glow */
path.leaflet-interactive.highlighted-marker{
  filter: drop-shadow(0 0 4px rgba(255,221,0,0.75));
}

/* Optional: specific style for your pump DivIcon wrapper */
.pump-icon{
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}

/* ---------- Scrollbar subtlety on Windows ---------- */
*{
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.25) transparent;
}
*::-webkit-scrollbar{ height: 8px; width: 8px; }
*::-webkit-scrollbar-thumb{ background: rgba(0,0,0,0.25); border-radius: 10px; }
*::-webkit-scrollbar-track{ background: transparent; }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 720px){
  :root{ --header-h: 48px; --footer-h: 36px; }
  #header p{ font-size: 0.98rem; }
  .leaflet-control-layers{ font-size: 13px; }
}

/* Photo popups */
/* Single photo (block) vs multi-photo (2-up grid) */
.popup-photos{ display:block; margin-top:8px; }
.popup-photos.grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.popup-photos img{
  width:100%; height:auto; border-radius:8px;
  box-shadow:0 2px 6px rgba(0,0,0,0.15);
}


/* ---------- Measure & cross-section controls ---------- */
.measure-control,
.cross-section-control{
  border-radius:8px;
  overflow:hidden;
  box-shadow: var(--soft-shadow);
}
.measure-control a,
.cross-section-control a{
  display:flex;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
  background:#fff;
  color:#1f2937;
  text-decoration:none;
  border-bottom:1px solid rgba(0,0,0,0.08);
}
.measure-control a:last-child,
.cross-section-control a:last-child{ border-bottom:0; }
.measure-control a:hover,
.cross-section-control a:hover{ background:#f2f2f2; }
.measure-control a.active{
  background:#ff9800;
  color:#fff;
}
.cross-section-control a.active{
  background:#3949ab;
  color:#fff;
}
.measure-control a.disabled,
.cross-section-control a.disabled{
  opacity:0.45;
  pointer-events:none;
}
.measure-control a svg,
.cross-section-control a svg{ pointer-events:none; }
.measure-control .measure-clear{
  font-size:20px;
  font-weight:600;
  line-height:1;
}

.leaflet-container.measure-active{ cursor:crosshair; }

.leaflet-container.cross-section-active{ cursor:crosshair; }

.measure-hint-panel{
  position:absolute;
  top:calc(var(--header-h) + 12px);
  left:50%;
  transform:translateX(-50%);
  background:rgba(17,24,39,0.92);
  color:#fff;
  padding:6px 14px;
  border-radius:999px;
  font-size:13px;
  box-shadow:var(--soft-shadow);
  pointer-events:none;
  z-index:1100;
}

.measure-tooltip{
  background:rgba(17,24,39,0.92);
  color:#fff;
  border-radius:6px;
  padding:6px 10px;
  box-shadow:var(--soft-shadow);
  font-size:12px;
  line-height:1.3;
}
.measure-tooltip .measure-value{
  white-space:nowrap;
}
.measure-tooltip .measure-tip-sub{
  font-size:11px;
  opacity:0.75;
  margin-top:4px;
}


/* ---------- Cross-section panel ---------- */
.cross-section-panel{
  min-width:260px;
  max-width:min(88vw, 320px);
  background: var(--card);
  border-radius:12px;
  box-shadow: var(--soft-shadow);
  padding:12px 14px;
  font-size:13px;
  line-height:1.35;
}
.cross-section-panel-head{
  font-weight:600;
  margin-bottom:8px;
  color:#1f2937;
}
.cross-section-panel-body{
  margin-bottom:10px;
  color:#374151;
}
.cross-section-panel-body:last-child{
  margin-bottom:0;
}
.cross-section-panel-divider{
  border-top:1px solid rgba(0,0,0,0.08);
  margin:10px 0;
}
.cross-section-loading{
  color:#3949ab;
  font-weight:600;
}
.cross-section-chart{
  display:block;
  width:100%;
  height:140px;
  background:#f5f7fb;
  border-radius:8px;
  border:1px solid rgba(0,0,0,0.08);
}
.cross-section-metrics{
  display:flex;
  flex-wrap:wrap;
  gap:6px 12px;
  font-size:12px;
  margin-bottom:8px;
}
.cross-section-metrics span{
  color:#1f2937;
}
.cross-section-table{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
  margin:8px 0;
}
.cross-section-table th,
.cross-section-table td{
  padding:4px 6px;
  border-bottom:1px solid rgba(0,0,0,0.08);
  text-align:left;
}
.cross-section-table th{
  font-weight:600;
  color:#1f2937;
}
.cross-section-table td{
  color:#374151;
}
.cross-section-hint{
  font-size:11px;
  margin:6px 0 0;
  color:#4b5563;
}
.cross-section-actions{
  margin-top:8px;
  display:flex;
  justify-content:flex-end;
}
.cross-section-panel-clear{
  border:0;
  background:#3949ab;
  color:#fff;
  padding:4px 12px;
  border-radius:6px;
  font-size:12px;
  cursor:pointer;
}
.cross-section-panel-clear:hover{
  background:#303f9f;
}
.cross-section-error{
  color:#b00020;
  margin:0;
}

/* Basemap tint toggle control */
/* Removed empty ruleset for .leaflet-control.tint-toggle, .tint-toggle */

.tint-toggle .btn{
  display:flex;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
  text-decoration:none;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  border-radius:8px;
}

.tint-toggle { /* container */
  border-radius:8px;
  overflow:hidden;
}

.tint-toggle .btn{
  background:#fff;
  color:#222;
}

.tint-toggle .btn:hover{
  background:#f2f2f2;
}

.tint-toggle.active .btn{
  background:#111827;   /* active background */
  color:#fff;           /* active text */
}

.tint-toggle .btn svg{
  display:block;
}

/* Pannellum container in popup */
.pano-box{
  width: min(80vw, 520px);
  height: min(50vw, 300px);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  margin-top: 8px;
  background: #111; /* optional: so a blank viewer isn't white */
}

/* basemap gallery removed per request */

/* ---------- Legend control ---------- */
.legend{
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--soft-shadow);
  padding: 10px 12px;
  line-height: 1.25;
}
.legend .title{ font-weight: 600; margin-bottom: 6px; }
.legend .item{ display:flex; align-items:center; margin: 4px 0; }
.legend .swatch{ width: 18px; height: 4px; margin-right: 8px; border-radius: 3px; }
.legend .dot{ width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; border: 2px solid #000; }

/* Minimizable legend header + content */
.legend .legend-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  cursor:pointer;
  user-select:none;
  padding-bottom:6px;
  border-bottom:1px solid rgba(0,0,0,0.06);
  margin-bottom:6px;
}
.legend .legend-title{ font-weight:600; }
.legend .legend-toggle{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:20px; height:20px;
  border-radius:4px;
  background:#f3f4f6;
  color:#111827;
  line-height:1;
  font-size:12px;
}
.legend .legend-content{ max-height: 280px; overflow:auto; }
.legend.minimized .legend-content{ display:none; }
.legend.minimized .legend-toggle{ transform: rotate(-90deg); }

/* Optional: slightly larger search box */
.leaflet-control-geocoder{
  box-shadow: var(--soft-shadow);
}

/* ---------- Locate (GPS) control ---------- */
.locate-control{
  border-radius:8px;
  overflow:hidden;
  box-shadow: var(--soft-shadow);
}
.locate-control a{
  display:flex;
  align-items:center;
  justify-content:center;
  width:36px; height:36px;
  background:#fff;
  color:#1f2937;
  text-decoration:none;
  border-bottom:1px solid rgba(0,0,0,0.08);
}
.locate-control a:last-child{ border-bottom:0; }
.locate-control a:hover{ background:#f2f2f2; }
.locate-control.active a.locate-follow{ background:#2563eb; color:#fff; }

/* optional slight tint for clear button */
.locate-control a.locate-clear:hover{ background:#fee2e2; color:#991b1b; }

/* locate status row */
.locate-status{
  display:none;
  align-items:center;
  gap:6px;
  background:#fff;
  color:#1f2937;
  padding:6px 8px;
  font-size:12px;
  border-top:1px solid rgba(0,0,0,0.08);
}
.locate-status .spinner{
  width:12px; height:12px;
  border:2px solid #93c5fd;
  border-top-color:#2563eb;
  border-radius:50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Screenshot control ---------- */
.screenshot-control{
  border-radius:8px;
  overflow:hidden;
  box-shadow: var(--soft-shadow);
}
.screenshot-control a{
  display:flex;
  align-items:center;
  justify-content:center;
  width:36px; height:36px;
  background:#fff; color:#1f2937; text-decoration:none;
}
.screenshot-control a:hover{ background:#f2f2f2; }
