/* ============================================================
   ATLAS RS — mapa.css
   Reskin do motor de mapa do protótipo na paleta oficial do Atlas.
   ============================================================ */

.mapa-shell{
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 72px);
  background: var(--paper);
}
.mapa-sidebar, .mapa-main{ min-width: 0; }

/* ---------- SIDEBAR ---------- */
.mapa-sidebar{
  background: var(--bg-dark);
  color: var(--on-dark);
  padding: 22px 20px 28px;
  border-right: 1px solid var(--bg-dark-3);
  overflow-y: auto;
}
.sidebar-block{ margin-bottom: 26px; }
.sidebar-block h3{
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 12px;
}
.sidebar-search{
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-dark-2);
  border: 1px solid var(--bg-dark-3);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.sidebar-search input{
  background: transparent;
  border: 0;
  outline: none;
  color: var(--on-dark);
  font-size: .85rem;
  width: 100%;
}
.sidebar-search input::placeholder{ color: var(--on-dark-muted); }
.sidebar-search svg{ color: var(--on-dark-muted); flex: none; }

#searchResults{
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.result-chip{
  text-align: left;
  background: var(--bg-dark-2);
  border: 1px solid var(--bg-dark-3);
  color: var(--on-dark);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  cursor: pointer;
}
.result-chip:hover{ border-color: var(--accent-light); }
.result-chip small{ display: block; color: var(--on-dark-muted); font-size: .72rem; margin-top: 2px; }
.result-chip--cat{ background: rgba(134,180,107,.12); border-color: rgba(134,180,107,.35); }
.result-group-label{
  font-family: var(--font-mono);
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--on-dark-muted);
  margin: 8px 2px 2px;
}
.result-group-label:first-child{ margin-top: 0; }
.result-empty{ font-size: .8rem; color: var(--on-dark-muted); }

.mode-list{ display: flex; flex-direction: column; gap: 4px; }
.mode-btn{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--on-dark-muted);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 500;
  width: 100%;
  min-width: 0;
}
.mode-btn > span:first-child{
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}
.mode-btn .n{
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--on-dark-muted);
}
.mode-btn:hover{ background: var(--bg-dark-2); color: var(--on-dark); }
.mode-btn.active{
  background: var(--bg-dark-2);
  border-color: var(--accent-light);
  color: var(--on-dark);
}
.mode-btn.active .n{ color: var(--accent-light); }

.label-list{ display: flex; flex-direction: column; gap: 4px; }
.label-btn{
  text-align: left;
  background: transparent;
  border: 1px solid var(--bg-dark-3);
  color: var(--on-dark-muted);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: .78rem;
}
.label-btn.active{ background: var(--bg-dark-2); color: var(--on-dark); border-color: var(--accent-light); }

.sidebar-note{
  font-size: .74rem;
  line-height: 1.5;
  color: var(--on-dark-muted);
  border-top: 1px solid var(--bg-dark-3);
  padding-top: 14px;
}

/* ---------- MAP AREA ---------- */
.mapa-main{ padding: 20px 24px 40px; }

.mapa-topbar{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.mapa-topbar h1{ font-size: 1.4rem; }
.mapa-topbar p{ color: var(--ink-muted); font-size: .88rem; margin-top: 4px; max-width: 60ch; }

.dado-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  max-width: 100%;
}
.dado-badge .sw{ width: 7px; height: 7px; border-radius: 50%; }
.dado-badge--oficial{ background: rgba(134,180,107,.12); color: #416731; }
.dado-badge--oficial .sw{ background: #416731; }
.dado-badge--calculado{ background: rgba(201,154,75,.14); color: #7c5217; }
.dado-badge--calculado .sw{ background: #7c5217; }
.dado-badge--generalizado{ background: rgba(185,118,47,.14); color: #815220; }
.dado-badge--generalizado .sw{ background: #815220; }

.map-card{
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 20px;
}
.highlight-bar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(47,107,79,.08);
  border: 1px solid rgba(47,107,79,.25);
  color: #2f5233;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  margin-bottom: 12px;
}
.highlight-bar button{
  background: none; border: 0; color: inherit; font-size: .78rem;
  text-decoration: underline; cursor: pointer; white-space: nowrap;
}
.area-importada-bar{
  background: rgba(193,67,47,.08);
  border-color: rgba(193,67,47,.3);
  color: #8a3423;
}
.map-wrap{ position: relative; }
#rsMap{
  width: 100%;
  height: 70vh;
  min-height: 460px;
  max-height: 780px;
  display: block;
  background: var(--paper);
  z-index: 0;
}
.mapa-branco #rsMap{ background: var(--paper); }

/* ---------- LEAFLET: reskin pra combinar com o Atlas ---------- */
.leaflet-tooltip{
  background: var(--bg-dark);
  color: #fff;
  border: 0;
  font-size: .78rem;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.leaflet-tooltip:before{ display: none; }
.muni-label-tooltip{
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  padding: 0 !important;
  color: #17261a;
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-body);
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0 0 4px #fff;
  pointer-events: none;
}
.leaflet-control-attribution{ font-size: .62rem; }

.muni-path{
  stroke: #ffffff;
  stroke-width: .6;
  cursor: pointer;
  transition: opacity .1s;
}
.muni-path:hover{ opacity: .78; stroke: var(--ink); stroke-width: 1.4; }
.muni-nodata{ fill: #d8d3c4 !important; cursor: default; }
.muni-nodata:hover{ opacity: 1; stroke: #fff; stroke-width: .6; }

.muni-label{
  font-family: var(--font-body);
  fill: #17261a;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: .55px;
  stroke-linejoin: round;
  font-weight: 600;
}
.label-minor{ font-weight: 500; }

.zoom-controls{
  position: absolute;
  top: 12px; right: 12px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.zoom-controls button{
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: #ffffffee;
  border-radius: var(--radius-sm);
  font-size: 18px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.zoom-controls button:hover{ background: #fff; border-color: var(--brand-green); }

.map-zoom-hint{
  position: absolute;
  bottom: 10px; left: 12px;
  z-index: 8;
  background: #ffffffcc;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: .72rem;
  color: var(--ink-muted);
  pointer-events: none;
}
.map-tooltip{
  position: absolute;
  pointer-events: none;
  background: var(--bg-dark);
  color: #fff;
  font-size: .78rem;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transform: translate(-50%,-130%);
  white-space: nowrap;
  display: none;
  z-index: 9;
}

.map-legend{
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
  font-size: .78rem;
  color: var(--ink-muted);
}
.map-legend span{ display: inline-flex; align-items: center; gap: 6px; }
.map-legend .dot{ width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.hydro-gradient-bar{
  width: 90px; height: 10px; border-radius: 999px;
  background: linear-gradient(90deg, #edf1e8, #2a7c96);
  display: inline-block;
}

/* ---------- DETAIL CARD ---------- */
#detailCard{
  display: none;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-green);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}
#detailCard.show{ display: block; }
#detailCard h2{ font-size: 1.3rem; margin-bottom: 2px; }
.muni-region{
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
}
.closeBtn{
  float: right;
  background: none;
  border: 0;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: .8rem;
}
.tag-row{ display: flex; flex-wrap: wrap; gap: 10px; }
.tag{
  font-size: .8rem;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  min-width: 150px;
  position: relative;
}
.tag b{
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .75;
  margin-bottom: 4px;
}
.tag .sw{ width: 6px; height: 6px; border-radius: 50%; flex: none; }
.tag.oficial{ background: rgba(134,180,107,.12); color: #3f6b30; }
.tag.oficial .sw{ background: #4d7a3a; }
.tag.calculado{ background: rgba(201,154,75,.14); color: #7a5015; }
.tag.calculado .sw{ background: #93611c; }
.tag.generalizado{ background: rgba(185,118,47,.14); color: #8a531c; }
.tag.generalizado .sw{ background: var(--accent-warn); }

/* ---------- REGIONS / BASINS ACCORDION ---------- */
.region{
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.region-head{
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  background: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: inherit;
}
.region-head:hover{ background: #faf8f0; }
.region-badge{
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700; font-size: .8rem; color: #fff; flex: none;
}
.region-title{ flex: 1; }
.region-title h3{ font-family: var(--font-body); font-size: 1rem; font-weight: 600; }
.region-title p{ font-size: .78rem; color: var(--ink-muted); margin-top: 2px; }
.chevron{ color: #625d51; transition: transform .2s; }
.region.open .chevron{ transform: rotate(90deg); }
.basins{ max-height: 0; overflow: hidden; transition: max-height .25s ease; background: #fbfaf5; }
.region.open .basins{ max-height: 6000px; }

.basin{ border-top: 1px solid var(--line); padding: 14px 18px 16px; }
.basin-head{ display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.basin-code{
  font-family: var(--font-mono);
  font-size: .68rem; background: #efe9d8; color: #8a5a34;
  padding: 2px 7px; border-radius: 5px; font-weight: 700;
}
.basin-name{ font-size: 1rem; font-weight: 700; }
.biome-pill{
  font-size: .7rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; margin-left: auto;
}
.biome-pampa{ background: #fbf3df; color: #8a6510; }
.biome-mata{ background: #e7f1e9; color: #2f6b4f; }
.biome-mista{ background: linear-gradient(90deg,#e7f1e9 50%,#fbf3df 50%); color: #8a5a34; }
.basin-body{ margin-top: 10px; font-size: .88rem; color: var(--ink); }
.basin-body .veg-line{ margin-bottom: 8px; color: var(--ink-muted); }
.basin-body .veg-line b{ color: #785c2d; }
.basin-body .veg-line em{ font-style: normal; color: #4d7a3a; }
.muni-chips{ display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.muni-chip{
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  padding: 5px 11px; border-radius: 999px; font-size: .8rem; cursor: pointer;
}
.muni-chip:hover{ border-color: var(--brand-green); color: var(--brand-green); }

.map-hint{ font-size: .76rem; color: var(--ink-muted); margin-top: 10px; line-height: 1.5; }

@media (max-width: 900px){
  .mapa-shell{ grid-template-columns: minmax(0, 1fr); }
  .mapa-sidebar{
    border-right: 0;
    border-bottom: 1px solid var(--bg-dark-3);
  }
}

/* ---------- INTERFERÊNCIAS AMBIENTAIS ---------- */
.layer-toggle-list{ display: flex; flex-direction: column; gap: 4px; }
.layer-toggle-list label{
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid transparent;
  padding: 8px 9px; border-radius: var(--radius-sm);
  font-size: .82rem; color: var(--on-dark-muted); cursor: pointer;
}
.layer-toggle-list label:hover{ background: var(--bg-dark-2); color: var(--on-dark); }
.layer-toggle-list label:has(input:checked){ background: var(--bg-dark-2); border-color: var(--accent-light); color: var(--on-dark); }
.layer-toggle-list input{ margin: 0; flex: none; }
.layer-toggle-list small{ display: block; font-family: var(--font-mono); font-size: .64rem; color: var(--on-dark-muted); }
.layer-toggle-list label.loading{ opacity: .55; pointer-events: none; }

.interf-section{ margin-top: 10px; width: 100%; }
.interf-chip{
  display: inline-flex; align-items: baseline; gap: 5px;
  background: #f7e8e4; color: #8a3a2a; border: 1px solid #e3c3b8;
  border-radius: 999px; padding: 5px 11px; font-size: .8rem; margin: 3px 5px 3px 0;
}
.interf-chip b{ font-weight: 700; }
.interf-empty{ font-size: .82rem; color: var(--ink-muted); }
.interf-detail{
  font-size: .8rem; color: var(--ink); margin: 6px 0 8px 2px;
  border-left: 2px solid #e3c3b8; padding-left: 10px;
}
.interf-detail div{ margin-bottom: 3px; }
.interf-caveat{ font-size: .72rem; color: var(--ink-muted); line-height: 1.5; margin-top: 4px; }

/* ---------- CONTROLE DE TRANSPARÊNCIA DAS CAMADAS ---------- */
.opacity-control{ margin-top: 10px; }
.opacity-control label{
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .78rem; color: var(--on-dark-muted); margin-bottom: 6px;
}
.opacity-control label span{ font-family: var(--font-mono); color: var(--on-dark); font-weight: 600; }
.opacity-control input[type="range"]{
  width: 100%; accent-color: var(--accent-light); cursor: pointer;
  height: 4px; background: var(--bg-dark-2); border-radius: 999px;
}
