html, body { height: 100%; margin: 0; }
#map3-root { height: 100%; width: 100%; position: relative; }
#map { height: 100%; width: 100%; }

.overlay {
  position: absolute;
  z-index: 1000;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.topbar {
  top: 12px; left: 12px; right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.60);
  color: #fff;
  border-radius: 12px;
  backdrop-filter: blur(4px);
}

.brand-title { font-weight: 700; font-size: 14px; display: block; }
.brand-sub { font-size: 12px; opacity: 0.9; display: block; }

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 140, 0, 0.95);
  color: #000;
  font-weight: 700;
  font-size: 12px;
}
.status { margin-left: 10px; font-size: 12px; opacity: 0.95; }

/* ===== Sidebar (kept for future use, but hidden for Public Map3) ===== */
.sidebar {
  top: 70px;
  left: 12px;
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 90px);
  overflow: auto;
  padding: 12px;
  background: rgba(255,255,255,0.95);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.sidebar-title { font-weight: 800; font-size: 14px; }

.sidebar-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,0.08); }
.label { display: block; font-weight: 700; font-size: 12px; margin-bottom: 8px; opacity: 0.85; }

.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.row { display: flex; justify-content: space-between; font-size: 13px; margin: 4px 0; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.fab {
  bottom: 14px;
  left: 14px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 0;
  background: rgba(0,0,0,0.70);
  color: #fff;
  cursor: pointer;
  display: none;
}

.logbox {
  margin: 0;
  padding: 10px;
  background: rgba(0,0,0,0.06);
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.popup-title { font-weight: 800; margin-bottom: 8px; }
.popup-row { font-size: 12px; margin: 4px 0; }
.pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255,140,0,0.18);
  margin-left: 6px;
  font-weight: 700;
}

/* Mobile */
@media (max-width: 899px) {
  .sidebar { width: calc(100vw - 24px); }
  .fab { display: block; }
}

/* ===== PUBLIC MAP3: hide sidebar immediately (prevent flicker) ===== */
#sidebar,
#sidebar-open,
#sidebar-toggle {
  display: none !important;
}

/* Map legend (Leaflet control) */
.map-legend {
  background: rgba(255,255,255,0.92);
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.18);
  font-size: 12px;
  line-height: 1.3;
}
.map-legend .lg-title {
  font-weight: 800;
  margin-bottom: 6px;
}
.map-legend .lg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.map-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  border: 2px solid rgba(0,0,0,0.25);
}
.map-legend .dot-sos { background: #ff8c00; }
.map-legend .dot-az  { background: #4b6bff; }
.map-legend .dot-test{ background: #777777; }

/* --- MAP3 hard fix: ensure map is visible and sized --- */
html, body { height: 100%; }
#map {
  display: block !important;
  width: 100% !important;
  height: calc(100vh - 72px) !important;
  min-height: 420px !important;
  background: #e6e6e6 !important;
  position: relative !important;
  z-index: 1 !important;
}
.leaflet-container { background: #e6e6e6 !important; }

/* Marker icons (SVG divIcon) */
.mk-wrap { background: transparent !important; border: 0 !important; }
.mk { width: 26px; height: 26px; display: grid; place-items: center; }
.mk svg { filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25)); }

/* ====== Basemap selector (Leaflet layers control) ====== */
.leaflet-control-layers {
  border: 0 !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 30px rgba(0,0,0,.20) !important;
  overflow: hidden;
}

.leaflet-control-layers-expanded {
  padding: 10px 12px !important;
  background: rgba(255,255,255,.92) !important;
  backdrop-filter: blur(6px);
}

.leaflet-control-layers .layers-title {
  font-weight: 700;
  font-size: 13px;
  margin: 0 0 6px 0;
  color: #111827;
}

.leaflet-control-layers label {
  font-size: 13px;
  line-height: 18px;
  color: #111827;
}

/* ===== SOS Abruzzo badge overlay (top-right) ===== */
:root{
  /* allineamento verticale badge: metti lo stesso valore del top del pannello filtri */
  --filters-top: 72px;      /* fallback */
  --sos-badge-top: var(--filters-top);
}

#sos-badge{
  position: absolute;
  top: var(--sos-badge-top);
  right: 16px;
  z-index: 1200; /* sopra leaflet tiles/controls */
  display: block;
  background: rgba(255,255,255,0.85);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

#sos-badge img{
  display: block;
  width: 64px;
  height: auto;
  border-radius: 8px;
}

/* opzionale: leggero adattamento su mobile */
@media (max-width: 640px){
  :root{
    --filters-top: 60px;
  }
  #sos-badge{
    right: 12px;
    padding: 5px;
    transform: scale(0.9);
    transform-origin: top right;
  }
  #sos-badge img{
    width: 54px;
  }
}
