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

body {
  background: #000805;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  color: #00ff88;
}

canvas { display: block; }

#cesiumContainer {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

/* Ocultar UI interna de Cesium */
.cesium-widget-credits,
.cesium-credit-container,
.cesium-viewer-toolbar { display: none !important; }

/* ── Scanlines ── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.07) 3px,
    rgba(0, 0, 0, 0.07) 4px
  );
  pointer-events: none;
  z-index: 500;
}

/* ── HUD corners ── */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
}
.hud-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  opacity: 0.5;
}
.hud-corner.tl { top: 14px;    left: 280px;  border-top: 1px solid #00ff44; border-left:  1px solid #00ff44; }
.hud-corner.tr { top: 14px;    right: 14px;  border-top: 1px solid #00ff44; border-right: 1px solid #00ff44; }
.hud-corner.bl { bottom: 14px; left: 280px;  border-bottom: 1px solid #00ff44; border-left:  1px solid #00ff44; }
.hud-corner.br { bottom: 14px; right: 14px;  border-bottom: 1px solid #00ff44; border-right: 1px solid #00ff44; }
#hud-readout {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #00ff44;
  opacity: 0.3;
  white-space: nowrap;
}

/* ── Panel ── */
#panel {
  position: fixed;
  top: 0; left: 0;
  width: 262px;
  height: 100vh;
  background: rgba(0, 6, 2, 0.96);
  backdrop-filter: blur(14px);
  color: #00cc66;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0, 255, 68, 0.18);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

#panel.hidden { transform: translateX(-100%); }

#panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid rgba(0, 255, 68, 0.1);
  flex-shrink: 0;
}

#panel-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #00ff88;
  text-transform: uppercase;
  text-shadow: 0 0 10px #00ff88;
}

#panel-toggle {
  background: none;
  border: 1px solid rgba(0, 255, 68, 0.18);
  color: #005533;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 1px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  transition: all 0.15s;
}
#panel-toggle:hover {
  color: #00ff88;
  border-color: rgba(0, 255, 68, 0.5);
  box-shadow: 0 0 6px rgba(0, 255, 68, 0.15);
}

#panel-open {
  position: fixed;
  top: 16px; left: 16px;
  z-index: 99;
  display: none;
  background: rgba(0, 6, 2, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 255, 68, 0.25);
  color: #00aa55;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 1px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  transition: all 0.15s;
}
#panel-open:hover { color: #00ff88; box-shadow: 0 0 10px rgba(0, 255, 68, 0.2); }
#panel.hidden ~ #panel-open { display: block; }

#bottom-controls {
  position: fixed;
  bottom: 60px; left: 50%; transform: translateX(-50%);
  z-index: 99;
  display: flex;
  flex-direction: row;
  gap: 6px;
  align-items: center;
}
#bottom-controls button {
  background: rgba(0, 6, 2, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 255, 68, 0.25);
  color: #00aa55;
  cursor: pointer;
  width: 38px; height: 38px;
  border-radius: 1px;
  font-size: 18px;
  font-family: 'Courier New', monospace;
  line-height: 1;
  transition: all 0.15s;
}
#bottom-controls button:hover { color: #00ff88; box-shadow: 0 0 10px rgba(0, 255, 68, 0.2); }

#panel-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

/* ── Grupos de control ── */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.control-group > label {
  font-size: 9px;
  color: #005533;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.control-group strong { color: #00ff88; font-size: 15px; text-shadow: 0 0 6px #00ff88; }

/* Slider */
input[type="range"] {
  width: 100%;
  accent-color: #00ff88;
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #003322;
}

/* Botones de período */
.btn-group { display: flex; gap: 4px; }

.period-btn {
  flex: 1;
  padding: 6px 2px;
  background: rgba(0, 255, 68, 0.03);
  border: 1px solid rgba(0, 255, 68, 0.1);
  color: #005533;
  cursor: pointer;
  border-radius: 1px;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.15s;
}
.period-btn:hover { background: rgba(0, 255, 68, 0.08); color: #00cc66; }
.period-btn.active {
  background: rgba(0, 255, 68, 0.1);
  border-color: rgba(0, 255, 68, 0.45);
  color: #00ff88;
  text-shadow: 0 0 6px #00ff88;
}

/* Fechas personalizadas */
#custom-dates { display: none; }

input[type="date"], input[type="number"] {
  background: rgba(0, 255, 68, 0.04);
  border: 1px solid rgba(0, 255, 68, 0.18);
  color: #00cc66;
  padding: 6px 8px;
  border-radius: 1px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  width: 100%;
}
input[type="number"] { width: 56px; }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.5) sepia(1) saturate(5) hue-rotate(90deg);
  cursor: pointer;
}

/* Botón aplicar */
#apply-btn {
  width: 100%;
  padding: 10px;
  background: rgba(0, 255, 68, 0.07);
  border: 1px solid rgba(0, 255, 68, 0.35);
  color: #00ff88;
  cursor: pointer;
  border-radius: 1px;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  transition: all 0.2s;
}
#apply-btn:hover {
  background: rgba(0, 255, 68, 0.14);
  box-shadow: 0 0 14px rgba(0, 255, 68, 0.18);
  text-shadow: 0 0 6px #00ff88;
}
#apply-btn:disabled { opacity: 0.2; cursor: not-allowed; }

/* Stats */
#stats { font-size: 10px; min-height: 16px; letter-spacing: 0.5px; }
#loading-msg { color: #005533; display: none; }
#loading-msg::before { content: '> '; }
#count-msg { color: #00aa55; display: none; }
#count-msg::before { content: '// '; }

hr { border: none; border-top: 1px solid rgba(0, 255, 68, 0.07); }

/* Toggle switch */
.alert-row { display: flex; align-items: center; gap: 8px; }

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px; height: 21px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #000a04;
  border-radius: 2px;
  cursor: pointer;
  transition: 0.2s;
  border: 1px solid rgba(0, 255, 68, 0.12);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 15px; height: 15px;
  left: 3px; top: 2px;
  background: #002211;
  border-radius: 1px;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(0, 255, 68, 0.09);
  border-color: #00ff44;
  box-shadow: 0 0 8px rgba(0, 255, 68, 0.18);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(17px);
  background: #00ff88;
  box-shadow: 0 0 6px #00ff88;
}

#alert-status { font-size: 10px; color: #004422; letter-spacing: 0.5px; }
#wind-status  { font-size: 10px; color: #004422; letter-spacing: 0.5px; }
#wind-legend  { display: none; margin-top: 6px; }
#wind-legend .leyenda-item { margin-bottom: 3px; }

#risk-status  { font-size: 10px; color: #004422; letter-spacing: 0.5px; }
#risk-legend  { display: none; margin-top: 6px; }
#risk-legend .leyenda-item { margin-bottom: 3px; }

#risk-top-zones { display: none; margin-top: 8px; }
.risk-zone-row {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(0, 255, 68, 0.05);
  letter-spacing: 0.5px;
}
.risk-disclaimer {
  font-size: 8px;
  color: #003322;
  letter-spacing: 0.5px;
  margin-top: 6px;
  line-height: 1.5;
  display: block;
}

/* ── Notificación de alerta ── */
@keyframes slideIn {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

#alert-notif {
  position: fixed;
  top: 20px; right: 20px;
  background: rgba(16, 6, 0, 0.96);
  backdrop-filter: blur(12px);
  color: #ffaa00;
  padding: 14px 16px;
  border-radius: 1px;
  border: 1px solid rgba(255, 160, 0, 0.35);
  border-left: 2px solid #ffaa00;
  display: none;
  align-items: flex-start;
  gap: 12px;
  max-width: 300px;
  z-index: 200;
  box-shadow: 0 0 20px rgba(255, 160, 0, 0.1);
  font-family: 'Courier New', monospace;
  animation: slideIn 0.3s ease;
}
#alert-content { flex: 1; }
#alert-title {
  display: block;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 2px;
  text-transform: uppercase;
  animation: blink 1.2s infinite;
}
#alert-body  { font-size: 11px; opacity: 0.8; line-height: 1.5; }
#alert-close {
  background: none;
  border: none;
  color: #ffaa00;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.45;
  padding: 0;
  font-family: 'Courier New', monospace;
}
#alert-close:hover { opacity: 1; }

/* ── Leyenda ── */
#leyenda {
  position: fixed;
  bottom: 24px; right: 24px;
  background: rgba(0, 5, 2, 0.9);
  backdrop-filter: blur(8px);
  color: #009944;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  padding: 12px 16px;
  border-radius: 1px;
  border: 1px solid rgba(0, 255, 68, 0.12);
  pointer-events: none;
}
.leyenda-titulo {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: #00ff88;
  opacity: 0.6;
}
.leyenda-item { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.leyenda-footer { margin-top: 10px; font-size: 9px; opacity: 0.25; letter-spacing: 0.5px; }

/* ── Tooltip terremoto ── */
#eq-info {
  position: fixed;
  display: none;
  background: rgba(0, 5, 2, 0.96);
  backdrop-filter: blur(8px);
  color: #00ff88;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  padding: 10px 14px;
  border-radius: 1px;
  border: 1px solid rgba(0, 255, 68, 0.2);
  border-left: 2px solid #00ff44;
  pointer-events: none;
  max-width: 260px;
  line-height: 1.7;
  z-index: 50;
  letter-spacing: 0.3px;
}

/* ── Atribución de tiles ── */
#map-attr {
  position: fixed;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: #003322;
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 90;
  white-space: nowrap;
}
#map-attr a {
  color: #004433;
  text-decoration: none;
  pointer-events: all;
}
#map-attr a:hover { color: #00ff88; }

/* ── Scrollbar ── */
#panel::-webkit-scrollbar { width: 3px; }
#panel::-webkit-scrollbar-track { background: #000805; }
#panel::-webkit-scrollbar-thumb { background: #003311; }
#panel::-webkit-scrollbar-thumb:hover { background: #006622; }

/* ── Acordeón ── */
details { border-top: 1px solid rgba(0,255,68,0.12); }
details:first-child { border-top: none; }
details summary {
  padding: 12px 0 10px;
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 2px;
  color: #00ff88;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: '▸';
  opacity: 0.5;
  transition: transform 0.2s;
}
details[open] summary::after { transform: rotate(90deg); }
details > .control-group,
details > button,
details > #stats { margin-top: 4px; }

/* ── Mobile ── */
@media (max-width: 640px) {
  #panel {
    width: 100%;
    height: auto;
    max-height: 72vh;
    top: auto; bottom: 0; left: 0;
    border-right: none;
    border-top: 1px solid rgba(0, 255, 68, 0.2);
    overflow-y: auto;
    transform: translateY(0);
    border-radius: 8px 8px 0 0;
  }
  #panel.hidden { transform: translateY(100%); }

  .hud-corner.tl, .hud-corner.bl { left: 14px; }

  /* Ocultar el panel-open original en mobile — lo reemplaza panel-btn-mob */
  #panel-open { display: none !important; }
  #panel.hidden ~ #panel-open { display: none !important; }

  /* Mostrar el ☰ en el bottom-controls solo en mobile */
  #panel-btn-mob { display: flex !important; }

  /* Bottom controls más grandes para touch */
  #bottom-controls {
    bottom: 20px;
    gap: 8px;
  }
  #bottom-controls button {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  #leyenda { display: none; }

  /* Tooltip fijo abajo en mobile (no hay cursor) */
  #eq-info {
    left: 50% !important;
    top: auto !important;
    bottom: 90px;
    transform: translateX(-50%);
    width: 90vw;
    max-width: 360px;
  }

  /* Panel body más espaciado para touch */
  #panel-body { padding: 12px 16px 24px; gap: 0; }
  details summary { padding: 14px 0; font-size: 11px; }

  .toggle-switch { width: 42px; height: 24px; }
  .toggle-slider::before { width: 18px; height: 18px; }
  input[type="range"] { height: 36px; }
  .btn-group button, #apply-btn { min-height: 40px; }
}

/* En desktop, ocultar el botón ☰ del bottom-controls */
@media (min-width: 641px) {
  #panel-btn-mob { display: none; }
}
