/* =========================================================
   style.css — Tu territorio desde el cielo · Latitud Ciencias 2025
   Departamento de Geografía · Facultad de Ciencias · UdelaR
   ========================================================= */
:root {
  --bg:         #f5f4f0;
  --surface:    #ffffff;
  --border:     #e2e0db;
  --text:       #1a1916;
  --muted:      #6b6860;
  --accent:     #1a1916;
  --sidebar-w:  290px;
  --header-h:   72px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── LOADER ──────────────────────────────────────────────── */
#loader {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; z-index: 9999; transition: opacity .4s;
}
#loader.hidden { opacity: 0; pointer-events: none; }
.loader-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.loader-text { font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── HEADER ──────────────────────────────────────────────── */
header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  z-index: 1000;
}
.header-logo { height: 64px; width: auto; }
.header-div  { width: 1px; height: 48px; background: var(--border); flex-shrink: 0; }
.header-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.header-inst  { font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.header-title {
  font-size: 13px; font-weight: 600; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-spacer { flex: 1; }

/* HEADER BADGE (comparación temporal, estilo pill como privacy-badge) */
.header-badge {
  display: flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 500;
  color: #1a5c35; background: #f0f9f3; border: 1px solid #2d8a52;
  padding: 4px 10px; border-radius: 20px; margin-right: 4px; flex-shrink: 0;
  font-family: 'DM Mono', monospace;
}
.header-badge::before { content:''; width:7px; height:7px; border-radius:50%; background:#2d8a52; flex-shrink:0; }

/* HEADER ACTIONS */
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-action-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 11px; font-weight: 500;
  text-decoration: none; cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.header-action-btn:hover {
  border-color: var(--accent); background: var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,.08); transform: translateY(-1px);
}
.header-btn-web, .header-btn-ig {
  padding: 0; width: 32px; height: 32px; justify-content: center; border-radius: 50%;
}
.header-btn-ig {
  color: #fff; border: none;
  background: linear-gradient(135deg,#f58529,#dd2a7b,#8134af,#515bd4);
}
.header-btn-ig:hover { opacity: .85; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.15); }

/* ── LAYOUT ──────────────────────────────────────────────── */
.layout {
  display: flex;
  padding-top: var(--header-h);
  height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
aside {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 12px; gap: 10px;
  display: flex; flex-direction: column;
}

/* cada bloque de la sidebar como tarjeta, al estilo chart-card */
.aside-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px;
}

.section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}

/* CONTROL GROUP (slider temporal) */
.control-group { display: flex; flex-direction: column; gap: 4px; }
.control-row {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px;
}
.control-name { font-size: 12px; font-weight: 500; }
.control-badge {
  font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 500;
  color: var(--muted); background: var(--bg);
  padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border);
  min-width: 44px; text-align: right;
}
.range-labels {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted);
  font-family: 'DM Mono', monospace;
  margin-top: 4px;
}

/* RANGE INPUT */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2px; border-radius: 2px;
  background: var(--border); outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent); cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: none;
  box-shadow: 0 0 0 1px var(--accent); cursor: pointer;
}

/* LAYER TOGGLES (interruptor deslizante, estilo map-controls del dashboard) */
.layer-toggle-group { display: flex; flex-direction: column; gap: 10px; }
.layer-row { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.layer-row input[type=checkbox] { display: none; }
.toggle-track {
  position: relative; width: 28px; height: 16px; flex-shrink: 0;
  border-radius: 8px; background: var(--border); cursor: pointer; transition: background .2s;
}
.toggle-track::after {
  content: ''; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  left: 3px; top: 3px; background: #fff; transition: transform .2s;
}
.layer-row input:checked + .toggle-track { background: var(--accent); }
.layer-row input:checked + .toggle-track::after { transform: translateX(12px); }
.dot-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }

/* BUTTON */
button {
  width: 100%;
  padding: 8px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px; font-weight: 500;
  background: var(--accent); color: var(--surface);
  border: 1px solid var(--accent); border-radius: 8px;
  cursor: pointer; transition: all .15s;
}
button:hover { opacity: .85; }
button.active { background: #2d8a52; border-color: #2d8a52; }

/* INFO PANEL */
#info-panel {
  font-size: 11px; color: var(--muted); line-height: 1.55;
  display: flex; flex-direction: column; gap: 6px;
}
.info-source { font-family: 'DM Mono', monospace; font-size: 10px; }

/* LEGEND */
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* colores */
.dot.amarillo { background: #d4a017; }
.dot.verde    { background: #2d8a52; }
.dot.usuario  { background: #1d6fa4; }

/* COORD PANEL */
#coord-panel {
  font-size: 11px; padding: 8px 10px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--muted); font-family: 'DM Mono', monospace; line-height: 1.5;
}

/* ── MAPA ────────────────────────────────────────────────── */
#map {
  flex: 1; min-width: 0;
  position: relative; overflow: hidden;
}

/* DIVISOR */
#divider {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 44px;
  transform: translateX(-50%); z-index: 650; cursor: ew-resize;
}
#divider-line {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 2px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 0 10px rgba(0,0,0,0.45);
  transform: translateX(-50%); pointer-events: none;
}
#divider-handle {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  user-select: none; transition: filter .15s;
}
#divider-handle:hover { filter: drop-shadow(0 3px 10px rgba(0,0,0,0.6)); }

/* ETIQUETAS DE AÑO */
.map-label {
  position: absolute; top: 80px; z-index: 700;
  background: rgba(26,25,22,0.82); color: #fff;
  font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 500;
  padding: 4px 10px; border-radius: 4px;
  pointer-events: none; letter-spacing: .06em;
}
.left-label  { left:  14px; }
.right-label { right: 14px; }

/* ── LEAFLET OVERRIDES ───────────────────────────────────── */
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.08) !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  font-family: 'DM Sans', sans-serif !important;
  color: var(--muted) !important;
  background: var(--surface) !important;
  border: none !important;
}
.leaflet-control-zoom a:hover { background: var(--bg) !important; }

.leaflet-control-layers {
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.08) !important;
  font-family: 'DM Sans', sans-serif !important;
  font-size: 12px !important;
  background: var(--surface) !important;
  padding: 8px 12px !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.1) !important;
  font-family: 'DM Sans', sans-serif !important;
  font-size: 12px !important;
  padding: 0 !important;
}
.leaflet-popup-content { margin: 12px 14px !important; }
.leaflet-popup-tip { background: var(--surface) !important; }

.popup-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.popup-desc  { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.popup-coords { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); }

.popup-remove {
  width: auto; padding: 4px 10px;
  font-size: 11px; margin-top: 6px;
  background: #c0392b; border-color: #c0392b;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .header-title { display: none; }
  .header-div   { display: none; }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 100%; }
  .layout { flex-direction: column; }
  aside { width: 100%; height: 280px; border-right: none; border-bottom: 1px solid var(--border); }
  .header-actions .header-action-btn:not(.header-btn-web):not(.header-btn-ig) span.btn-label { display: none; }
  .header-badge { display: none; }
}
