/* =========================================================
   Varela Digital — Map page (clean)
   - Desktop: app layout (no page scroll)
   - Sidebar scrolls internally
   - Map fills remaining viewport height
   - No footer on map page
   - Header title scaled down (proportional)
   ========================================================= */

/* ---------- Base layout (all screens) ---------- */

body.vd-map .vd-map-page {
  /* fixed navbar offset */
  padding-top: 5rem;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
}

/* Keep header width nice */
body.vd-map .vd-map-header {
  max-width: 1100px;
  margin: 0 auto;
}

/* Header typography (scaled down) */
body.vd-map .vd-map-header h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 0.25rem 0;
  font-weight: 700;
}

body.vd-map .vd-map-header .vd-lead {
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0;
  max-width: 720px;
}

body.vd-map .vd-map-layout {
  /* layout width handled by bootstrap container */
  width: 100%;
}

body.vd-map .vd-map-card {
  background: #fff;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* Default (mobile/tablet): map has a sensible fixed height */
body.vd-map .vd-leaflet-map {
  width: 100%;
  height: 70vh;
  min-height: 520px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

/* ---------- Sidebar (filters) ---------- */

body.vd-map .map-filters {
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

body.vd-map .filter-group + .filter-group {
  margin-top: 1rem;
}

body.vd-map .filter-group-title {
  font-weight: 700;
  margin-bottom: 0.6rem;
}

body.vd-map .vd-filter-label {
  font-weight: 500;
  margin-top: 0.45rem;
  margin-bottom: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.50rem;
}

body.vd-map .vd-check {
  margin-top: 0.75rem;
}

body.vd-map .vd-filters-actions {
  margin-top: 1rem;
}

body.vd-map .map-status {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 0.75rem;
}

body.vd-map .map-status-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.2rem 0;
}

body.vd-map .map-status-label {
  opacity: 0.75;
}

body.vd-map .map-status-value {
  font-weight: 300;
}

/* ---------- Popup ---------- */

body.vd-map .vd-popup h6 {
  margin: 0 0 0.35rem 0;
  font-weight: 800;
}

body.vd-map .vd-popup .vd-popup-meta {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 0.35rem;
}

body.vd-map .vd-popup ul {
  margin: 0.25rem 0 0 1.1rem;
  padding: 0;
}

body.vd-map .vd-popup li {
  margin: 0.15rem 0;
}

/* ---------- Responsive (mobile/tablet) ---------- */

@media (max-width: 991px) {
  body.vd-map .vd-map-header h1 {
    font-size: 1.85rem;
  }

  body.vd-map .vd-map-header .vd-lead {
    font-size: 0.95rem;
  }

  body.vd-map .vd-leaflet-map {
    height: 62vh;
    min-height: 420px;
  }
}

/* =========================================================
   Desktop: app layout, NO overflow beyond viewport
   ========================================================= */

@media (min-width: 992px) {
  /* No page scroll on desktop */
  html,
  body.vd-map {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* Main occupies the viewport (navbar handled via padding-top) */
  body.vd-map .vd-map-page {
    height: calc(100dvh - 5px);
    overflow: hidden;
    box-sizing: border-box;
  }

  /* IMPORTANT:
     This layout assumes your <main class="vd-map-page"> contains a bootstrap container
     (e.g., <div class="container-xxl"> ... header + row ... </div>).
     We rely on that container to define a 2-row grid: header / content. */
  body.vd-map .vd-map-page > .container-xxl,
  body.vd-map .vd-map-page > .container-xl,
  body.vd-map .vd-map-page > .container-lg,
  body.vd-map .vd-map-page > .container,
  body.vd-map .vd-map-page > .container-fluid {
    height: 100%;
    overflow: hidden;

    display: grid;
    grid-template-rows: auto 1fr;
    gap: 1rem;
  }

  /* Header stays compact */
  body.vd-map .vd-map-header {
    margin: 0;
  }

  /* Content row must be allowed to shrink inside the grid */
  body.vd-map .vd-map-layout {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  /* IMPORTANT: Bootstrap columns need min-height:0 so children can scroll/fill */
  body.vd-map .vd-map-layout > aside,
  body.vd-map .vd-map-layout > section {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  /* Sidebar scrolls internally */
  body.vd-map .map-filters {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 1.25rem;
  }

  /* Map column fills vertically */
  body.vd-map .vd-map-card {
    height: 100%;
    min-height: 0;
  }

  /* On desktop, map fills 100% of its column height (no vh/min-height) */
  body.vd-map .vd-leaflet-map {
    height: 100%;
    min-height: 0;
  }

  /* Map page has NO footer (override global styles.css safely) */
  body.vd-map .vd-footer {
    display: none !important;
  }
}

/* =========================================================
   Leaflet aesthetic tuning (site-friendly palette)
   ========================================================= */

body.vd-map .leaflet-container {
  background: #f6f2ec;
  font-family: inherit;
}

body.vd-map .leaflet-control-attribution {
  background: rgba(253, 253, 251, 0.85);
  border-radius: 10px;
  padding: 0.2rem 0.5rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

body.vd-map .leaflet-bar a {
  background: rgba(253, 253, 251, 0.92);
  color: #2f3b2c;
  border: 1px solid rgba(0, 0, 0, 0.10);
}

body.vd-map .leaflet-bar a:hover {
  background: rgba(253, 253, 251, 1);
}

/* ---------- Protect marker colors from global CSS ---------- */

body.vd-map .leaflet-overlay-pane svg path.leaflet-interactive {
  vector-effect: non-scaling-stroke;
}

/* Sending markers */
body.vd-map .leaflet-overlay-pane svg path.leaflet-interactive.vd-marker-sending {
  fill: #4e7a5a !important;
  stroke: #2f5d3a !important;
  fill-opacity: 0.62 !important;
  stroke-opacity: 0.95 !important;
}

/* Mentioned markers */
body.vd-map .leaflet-overlay-pane svg path.leaflet-interactive.vd-marker-mentioned {
  fill: #b56a5a !important;
  stroke: #7a3e34 !important;
  fill-opacity: 0.62 !important;
  stroke-opacity: 0.95 !important;
}

/* All places markers */
body.vd-map .leaflet-overlay-pane svg path.leaflet-interactive.vd-marker-all {
  fill: #6b6b6b !important;
  stroke: rgba(0, 0, 0, 0.45) !important;
  fill-opacity: 0.58 !important;
  stroke-opacity: 0.9 !important;
}

/* Hover/focus */
body.vd-map .leaflet-overlay-pane svg path.leaflet-interactive.vd-marker-sending:hover,
body.vd-map .leaflet-overlay-pane svg path.leaflet-interactive.vd-marker-mentioned:hover,
body.vd-map .leaflet-overlay-pane svg path.leaflet-interactive.vd-marker-all:hover {
  fill-opacity: 0.78 !important;
  stroke-width: 2 !important;
}

/* ---------- Legend ---------- */

body.vd-map .vd-map-legend {
  background: rgba(253, 253, 251, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  font-size: 0.95rem;
  color: #2f3b2c;
}

/* =========================================================
   Advanced filters (accordion)
   ========================================================= */

body.vd-map .vd-advanced-filters {
  margin-top: 1rem;
}

body.vd-map .vd-advanced-filters .accordion-item {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(253, 253, 251, 0.92);
}

body.vd-map .vd-advanced-filters .accordion-button {
  font-weight: 700;
  color: #2f3b2c;
  background: rgba(253, 253, 251, 0.92);
  box-shadow: none;
  padding: 0.75rem 0.9rem;
}

body.vd-map .vd-advanced-filters .accordion-button:not(.collapsed) {
  background: rgba(248, 245, 239, 0.95);
}

body.vd-map .vd-advanced-filters .accordion-body {
  padding: 0.85rem 0.9rem 0.95rem 0.9rem;
}

body.vd-map .vd-advanced-filters .filter-group + .filter-group {
  margin-top: 0.85rem;
}

/* Threshold badge */
body.vd-map #thresholdValue {
  border: 1px solid rgba(0, 0, 0, 0.10);
  font-weight: 700;
}

body.vd-map #thresholdValueInline {
  font-weight: 800;
}

/* =========================================================
   Density slider (threshold) — match site palette
   ========================================================= */

body.vd-map #thresholdFilter {
  --track-bg: rgba(78, 122, 90, 0.22);
  --thumb-bg: #4e7a5a;
  --thumb-border: #2f5d3a;
  --track-height: 4px;

  appearance: none;
  -webkit-appearance: none;

  width: 100%;
  height: var(--track-height);
  background: var(--track-bg);
  border-radius: 999px;
  outline: none;
  margin-top: 0.35rem;
}

/* WebKit */
body.vd-map #thresholdFilter::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;

  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--thumb-bg);
  border: 2px solid var(--thumb-border);
  cursor: pointer;
  margin-top: calc(-8px + var(--track-height) / 2);
}

/* Firefox */
body.vd-map #thresholdFilter::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--thumb-bg);
  border: 2px solid var(--thumb-border);
  cursor: pointer;
}

body.vd-map #thresholdFilter::-moz-range-track {
  height: var(--track-height);
  background: var(--track-bg);
  border-radius: 999px;
}

/* =========================================================
   Inline help button (tooltip trigger)
   ========================================================= */

body.vd-map .vd-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  background: rgba(253, 253, 251, 0.92);
  color: #2f3b2c;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

body.vd-map .vd-help:hover {
  background: rgba(248, 245, 239, 0.95);
}

/* Temporal play progress */
body.vd-map #yearPlayProgress {
  background: #4e7a5a;
}

/* Play button – green */
body.vd-map #playYearsBtn.btn-outline-primary {
  --bs-btn-color: #4e7a5a;
  --bs-btn-border-color: #4e7a5a;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: #4e7a5a;
  --bs-btn-hover-border-color: #4e7a5a;
  --bs-btn-active-bg: #3f684c;
  --bs-btn-active-border-color: #3f684c;
  --bs-btn-disabled-color: #8aae9a;
  --bs-btn-disabled-border-color: #8aae9a;
}

/* Stop button – neutral */
body.vd-map #stopYearsBtn.btn-outline-secondary {
  opacity: 0.85;
}

/* Dropdown current page — site palette */
.vd-navbar .dropdown-item.is-current {
  background: rgba(78, 122, 90, 0.12); /* verde suave do site */
  color: #2f3b2c;
  font-weight: 600;
}

/* Evita azul do Bootstrap */
.vd-navbar .dropdown-item.is-current:active,
.vd-navbar .dropdown-item.is-current:hover {
  background: rgba(78, 122, 90, 0.18);
  color: #2f3b2c;
}