/* ------------------------------------------------------------------
   Explorador de Água Subterrânea — MT
   Paleta: noite de rio (fundo), areia do cerrado (texto),
   divergente vermelho→azul (dado).
------------------------------------------------------------------- */
:root {
  --bg: #0c1517;          /* água profunda à noite (mapa) */
  --topbar-h: 64px;

  /* painel lateral: cinza claro */
  --panel: #dedfe4;
  --panel-edge: #dcdfe3;
  --card-bg: #f0f0f0;
  --ink: #1f2430;
  --ink-dim: #141518;
  --accent: #0f8a80;      /* teal — contraste sobre cinza claro */
  --critical: #d7301f;
  --high: #2b8cbe;
  --mono: "IBM Plex Mono", monospace;
  --body: "Inter", system-ui, sans-serif;
  --display: "Bricolage Grotesque", var(--body);
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

/* ---------------------------------------------------------- topo */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--panel-edge);
}

.logo { height: 34px; width: auto; object-fit: contain; }
.logo-app { height: 48px; }

#map {
  position: absolute;
  top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  background: var(--bg);
}

/* ---------------------------------------------------------- painel */
#panel {
  position: absolute;
  top: var(--topbar-h); left: 0; bottom: 0;
  width: 380px;
  max-width: 92vw;
  z-index: 1000;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--panel-edge);
  color: var(--ink);
  padding: 28px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.1;
}

/* --------------------------------------------------------- controle */
.control label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 10px 12px;
  font: 500 14px var(--body);
  color: var(--ink);
  background: var(--card-bg);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
}
select:focus-visible,
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-row { display: flex; gap: 8px; margin-top: 10px; }

.btn {
  flex: 1;
  padding: 9px 10px;
  font: 600 13px var(--body);
  color: #ffffff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }

.btn-ghost {
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--panel-edge);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-dim); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--ink-dim);
  background: var(--card-bg);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------------------------------------------------------- legenda */
.legend-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

.legend-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    #7f1d1d, #d7301f, #fcae91, #f7f7f7, #a6bddb, #2b8cbe, #08306b);
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-dim);
  margin-top: 4px;
}

/* ---------------------------------------------------------- gráfico */
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 16px;
}
.chart-card.hidden { display: none; }

.chart-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.chart-meta h2 {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.slope {
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
}
.slope.down { color: var(--critical); }
.slope.up   { color: var(--high); }

.chart-wrap { height: 220px; margin-top: 10px; }

.chart-note {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 10px;
  line-height: 1.4;
}

.status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  min-height: 16px;
}
.status.error { color: var(--critical); }

.panel-foot {
  margin-top: auto;
  font-size: 11px;
  color: var(--ink-dim);
  line-height: 1.5;
  border-top: 1px solid var(--panel-edge);
  padding-top: 12px;
}

/* --------------------------------------------------- labels das microbacias */
.leaflet-tooltip.basin-label {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  font-family: var(--body);
  font-weight: 600;
  font-size: var(--basin-label-size, 11px);
  color: #163832;
  white-space: nowrap;
  pointer-events: none;
  text-shadow:
    -1px -1px 0 #fff, 1px -1px 0 #fff,
    -1px  1px 0 #fff, 1px  1px 0 #fff,
     0px -1px 0 #fff, 0px  1px 0 #fff,
    -1px  0px 0 #fff, 1px  0px 0 #fff;
}
.leaflet-tooltip.basin-label::before { display: none; }

/* --------------------------------------------------- controle de camadas */
.leaflet-control-layers {
  font-family: var(--body);
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
}
.leaflet-control-layers-toggle { border-radius: 8px !important; }
.leaflet-control-layers label { font-size: 13px; }

/* --------------------------------------------------------- mobile */
@media (max-width: 720px) {
  #panel {
    top: auto;
    height: 55vh;
    width: 100%;
    max-width: none;
    border-right: none;
    border-top: 1px solid var(--panel-edge);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
