/* ───────────────────────────────────────────────────────────────
   Geoportal de Villa El Chocón — hoja de estilos única.
   Paleta: estepa patagónica (áridos cálidos) sobre el azul del embalse.
   ─────────────────────────────────────────────────────────────── */

:root {
  --fondo:        #f4f2ee;
  --superficie:   #ffffff;
  --superficie-2: #faf8f5;
  --borde:        #ddd6cc;
  --borde-suave:  #ebe5dc;
  --texto:        #23201c;
  --texto-2:      #6b635a;
  --acento:       #0b6e99;
  --acento-2:     #08536f;
  --acento-suave: #e2f0f6;
  --arena:        #b8703a;
  --verde:        #4a7c2f;
  --alerta:       #b3261e;
  --sombra:       0 1px 2px rgba(35,32,28,.06), 0 8px 24px rgba(35,32,28,.08);
  --radio:        10px;
  --barra-alto:   58px;
  --panel-ancho:  380px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo:        #17171a;
    --superficie:   #1f1f23;
    --superficie-2: #26262b;
    --borde:        #35353c;
    --borde-suave:  #2b2b31;
    --texto:        #ecebe8;
    --texto-2:      #a09a92;
    --acento:       #4bb3dd;
    --acento-2:     #7fcbe8;
    --acento-suave: #10313f;
    --arena:        #d98f55;
    --verde:        #7fb356;
    --sombra:       0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font-family: var(--sans);
  font-size: 15px; line-height: 1.5;
  color: var(--texto); background: var(--fondo);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

/* ───────── Barra superior ───────── */

.barra {
  height: var(--barra-alto);
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
  position: relative; z-index: 1200;
}

.marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.marca-icono { width: 30px; height: 30px; color: var(--acento); flex: none; }
.marca h1 { font-size: 15px; white-space: nowrap; }
.marca p  { margin: 0; font-size: 11.5px; color: var(--texto-2); white-space: nowrap; }

.buscador { position: relative; flex: 1 1 260px; max-width: 460px; display: flex; gap: 6px; }
.buscador input {
  flex: 1; min-width: 0;
  padding: 7px 11px; font: inherit; font-size: 14px;
  color: var(--texto); background: var(--superficie-2);
  border: 1px solid var(--borde); border-radius: var(--radio);
}
.buscador input:focus { outline: 2px solid var(--acento); outline-offset: -1px; }
.buscador button {
  padding: 7px 13px; font: inherit; font-size: 14px; font-weight: 500;
  color: #fff; background: var(--acento);
  border: 0; border-radius: var(--radio); cursor: pointer;
}
.buscador button:hover { background: var(--acento-2); }

.resultados {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 340px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none;
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra); z-index: 1300;
}
.resultados li { padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.resultados li:hover, .resultados li:focus { background: var(--acento-suave); }
.resultados b { font-family: var(--mono); font-size: 12px; }
.resultados span { display: block; color: var(--texto-2); font-size: 11.5px; }
.resultados .vacio { color: var(--texto-2); cursor: default; }

.pestanas { display: flex; gap: 2px; margin-left: auto; flex: none; }
.pestana {
  padding: 7px 13px; font: inherit; font-size: 13.5px;
  color: var(--texto-2); background: none;
  border: 1px solid transparent; border-radius: var(--radio); cursor: pointer;
}
.pestana:hover { background: var(--superficie-2); }
.pestana.activa { color: var(--acento); background: var(--acento-suave); font-weight: 600; }

/* ───────── Cuerpo ───────── */

.cuerpo { display: flex; height: calc(100% - var(--barra-alto)); }

.panel {
  width: var(--panel-ancho); flex: none;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 16px 40px;
  background: var(--superficie);
  border-right: 1px solid var(--borde);
  position: relative;
}
.panel.oculto { display: none; }
.panel h2 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--texto-2); margin: 22px 0 9px;
}
.panel h2:first-of-type { margin-top: 4px; }

.panel-cerrar, .panel-abrir {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px; padding: 0; line-height: 1;
  font-size: 18px; color: var(--texto-2);
  background: var(--superficie-2); border: 1px solid var(--borde);
  border-radius: 7px; cursor: pointer;
}
.panel-abrir {
  position: absolute; top: 10px; left: 10px; right: auto;
  width: 34px; height: 34px; font-size: 16px; z-index: 900;
  background: var(--superficie); box-shadow: var(--sombra);
}

.hoja { display: none; }
.hoja.activa { display: block; }

.mapa-envoltorio { flex: 1; position: relative; min-width: 0; }
#mapa { position: absolute; inset: 0; background: var(--superficie-2); }

.pie-mapa {
  position: absolute; left: 8px; bottom: 8px; z-index: 900;
  display: flex; gap: 10px; align-items: center;
  padding: 3px 9px; font-family: var(--mono); font-size: 11px;
  color: var(--texto-2); background: rgba(255,255,255,.82);
  border-radius: 6px; pointer-events: none;
}
@media (prefers-color-scheme: dark) { .pie-mapa { background: rgba(20,20,23,.8); } }
#estado-carga:not(:empty)::before { content: "· "; }

/* ───────── Controles del panel ───────── */

.lista-bases { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.lista-bases button {
  padding: 8px 9px; font: inherit; font-size: 12.5px; text-align: left;
  color: var(--texto); background: var(--superficie-2);
  border: 1px solid var(--borde); border-radius: 8px; cursor: pointer;
}
.lista-bases button small { display: block; color: var(--texto-2); font-size: 10.5px; }
.lista-bases button.activa { border-color: var(--acento); background: var(--acento-suave); color: var(--acento-2); font-weight: 600; }

.lista-capas { display: flex; flex-direction: column; gap: 3px; }
.fila-capa {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
}
.fila-capa:hover { background: var(--superficie-2); }
.fila-capa input { accent-color: var(--acento); width: 15px; height: 15px; flex: none; }
.fila-capa .titulo { flex: 1; min-width: 0; }
.fila-capa .grupo { font-size: 10.5px; color: var(--texto-2); text-transform: uppercase; letter-spacing: .05em; }
.fila-capa .ayuda { font-size: 11.5px; color: var(--texto-2); display: block; }

.segmentado { display: flex; gap: 2px; padding: 2px; background: var(--superficie-2);
  border: 1px solid var(--borde); border-radius: 9px; }
.segmentado button {
  flex: 1; padding: 6px 4px; font: inherit; font-size: 12.5px;
  color: var(--texto-2); background: none; border: 0; border-radius: 7px; cursor: pointer;
}
.segmentado button.activa { background: var(--superficie); color: var(--acento); font-weight: 600; box-shadow: var(--sombra); }
.segmentado.chico button { font-size: 11.5px; padding: 5px 3px; }

.campo { display: block; margin: 9px 0; font-size: 12.5px; color: var(--texto-2); }
.campo span { display: block; margin-bottom: 4px; }
.campo select, .campo input[type="range"] {
  width: 100%; padding: 6px 8px; font: inherit; font-size: 13.5px;
  color: var(--texto); background: var(--superficie-2);
  border: 1px solid var(--borde); border-radius: 8px;
}
.campo input[type="range"] { padding: 0; accent-color: var(--acento); }

.selector-periodo { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.selector-periodo input { flex: 1; accent-color: var(--acento); }
.selector-periodo output {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  min-width: 62px; text-align: right; color: var(--acento);
}

.nota { margin: 7px 0; font-size: 12px; color: var(--texto-2); }

/* ───────── Leyendas, fichas y tablas ───────── */

.leyenda { display: flex; flex-wrap: wrap; gap: 5px 12px; margin: 8px 0; font-size: 11.5px; color: var(--texto-2); }
.leyenda i { width: 12px; height: 12px; border-radius: 3px; display: inline-block;
  margin-right: 5px; vertical-align: -2px; border: 1px solid rgba(0,0,0,.15); }
.leyenda-rosa i { border-radius: 2px; }

.ficha {
  padding: 11px 12px; margin: 8px 0;
  background: var(--superficie-2); border: 1px solid var(--borde-suave);
  border-radius: var(--radio); font-size: 12.5px;
}
.ficha dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.ficha dt { color: var(--texto-2); }
.ficha dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.ficha .aviso {
  margin: 8px 0 0; padding: 7px 9px; font-size: 11.5px;
  color: var(--texto); background: color-mix(in srgb, var(--arena) 12%, transparent);
  border-left: 3px solid var(--arena); border-radius: 0 6px 6px 0;
}
.ficha a { color: var(--acento); }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; margin: 10px 0; }
.tarjeta {
  padding: 8px 9px; background: var(--superficie-2);
  border: 1px solid var(--borde-suave); border-radius: 9px; text-align: center;
}
.tarjeta b { display: block; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--acento); }
.tarjeta span { font-size: 10.5px; color: var(--texto-2); }

.tabla-envoltorio { overflow-x: auto; margin: 8px 0; }
table.metodos { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.metodos th, table.metodos td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--borde-suave); }
table.metodos th:first-child, table.metodos td:first-child { text-align: left; white-space: normal; min-width: 150px; }
table.metodos thead th { color: var(--texto-2); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
table.metodos td { font-variant-numeric: tabular-nums; }
table.metodos .punto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.descargas { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.descargas a {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 10px; font-size: 12.5px; color: var(--texto); text-decoration: none;
  background: var(--superficie-2); border: 1px solid var(--borde-suave); border-radius: 8px;
}
.descargas a:hover { border-color: var(--acento); color: var(--acento); }
.descargas em { font-style: normal; color: var(--texto-2); font-size: 11px; font-family: var(--mono); }

/* ───────── Gráficos y rosa ───────── */

.grafico { margin: 8px 0; }
.grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico .eje  { stroke: var(--borde); stroke-width: 1; }
.grafico .rejilla { stroke: var(--borde-suave); stroke-width: 1; stroke-dasharray: 2 3; }
.grafico text { fill: var(--texto-2); font-size: 9.5px; font-family: var(--sans); }
.grafico .etiqueta-valor { fill: var(--texto); font-size: 9px; font-variant-numeric: tabular-nums; }
.grafico .serie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.grafico .serie-punto { stroke: var(--superficie); stroke-width: 1.2; }
.grafico .ensamble { stroke-dasharray: 5 3; stroke-width: 2.5; }
.grafico .barra { }
.grafico .tendencia { stroke: var(--alerta); stroke-width: 1.4; stroke-dasharray: 4 3; opacity: .8; }
.grafico-leyenda { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--texto-2); margin-top: 4px; }
.grafico-leyenda i { width: 14px; height: 3px; display: inline-block; vertical-align: 3px; margin-right: 5px; border-radius: 2px; }

.rosa svg { display: block; width: 100%; height: auto; }
.rosa .anillo { fill: none; stroke: var(--borde-suave); stroke-width: 1; }
.rosa .radial { stroke: var(--borde-suave); stroke-width: 1; }
.rosa .rumbo  { fill: var(--texto-2); font-size: 10px; font-weight: 600; }
.rosa .rumbo-menor { fill: var(--texto-2); font-size: 8px; opacity: .65; }
.rosa .escala { fill: var(--texto-2); font-size: 8.5px; }
.rosa .petalo { stroke: var(--superficie); stroke-width: .5; }
.rosa .petalo:hover { stroke: var(--texto); stroke-width: 1; }
.rosa .centro-calma { fill: var(--superficie-2); stroke: var(--borde); }
.rosa .centro-texto { fill: var(--texto-2); font-size: 8px; text-anchor: middle; }

/* ───────── Ficha de parcela ───────── */

.ficha-parcela {
  position: absolute; right: 14px; bottom: 34px; z-index: 1000;
  width: min(330px, calc(100vw - 28px)); max-height: 62vh; overflow-y: auto;
  padding: 14px 15px;
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra);
}
.ficha-parcela h3 { font-size: 13px; font-family: var(--mono); color: var(--acento); margin-bottom: 2px; }
.ficha-parcela .ubic { font-size: 12px; color: var(--texto-2); margin: 0 0 10px; }
.ficha-parcela dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12px; }
.ficha-parcela dt { color: var(--texto-2); }
.ficha-parcela dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.ficha-cerrar {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px;
  font-size: 16px; line-height: 1; color: var(--texto-2);
  background: var(--superficie-2); border: 1px solid var(--borde);
  border-radius: 6px; cursor: pointer;
}

/* ───────── Sobreescrituras de Leaflet ───────── */

.leaflet-container { font-family: var(--sans); background: var(--superficie-2); }
.leaflet-control-attribution {
  font-size: 10px; background: rgba(255,255,255,.82) !important; color: var(--texto-2);
}
.leaflet-control-attribution a { color: var(--acento); }
@media (prefers-color-scheme: dark) {
  .leaflet-control-attribution { background: rgba(20,20,23,.8) !important; }
  .leaflet-control-zoom a { background: var(--superficie) !important; color: var(--texto) !important;
    border-color: var(--borde) !important; }
}
.leaflet-popup-content-wrapper { border-radius: var(--radio); }
.marcador-rosa { pointer-events: none; }
.etiqueta-viento {
  padding: 2px 6px; font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: #fff; background: rgba(11,110,153,.85); border: 0; border-radius: 5px;
  box-shadow: none; white-space: nowrap;
}
.etiqueta-viento::before { display: none; }

/* ───────── Adaptación a pantallas chicas ───────── */

@media (max-width: 900px) {
  :root { --panel-ancho: 320px; }
  .marca p { display: none; }
}

@media (max-width: 720px) {
  .barra { flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 8px; }
  .cuerpo { flex-direction: column-reverse; height: auto; min-height: calc(100% - 100px); }
  .panel { width: 100%; max-height: 55vh; border-right: 0; border-top: 1px solid var(--borde); }
  .mapa-envoltorio { height: 45vh; flex: none; }
  .buscador { order: 3; max-width: none; flex-basis: 100%; }
  .pestanas { margin-left: 0; }
  .ficha-parcela { right: 8px; left: 8px; width: auto; }
}

/* ───────── Capas de viento sobre el mapa ───────── */

.capa-viento { position: absolute; top: 0; left: 0; z-index: 350; }
.flecha-viento { background: none; border: 0; }
.flecha-viento svg { display: block; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.35)); }
.marcador-rosa svg {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.3));
  opacity: .92;
}
.marcador-rosa .anillo, .marcador-rosa .radial { stroke: rgba(255,255,255,.55); }
.marcador-rosa .rumbo { fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.45); stroke-width: 2px; }
.marcador-rosa .centro-calma { fill: rgba(255,255,255,.85); stroke: none; }
