:root {
  --bg1:#001933;
  --bg2:#660000;
  --accent:#ff6600;
  --card: rgba(255,255,255,0.06);
}
body {
  margin:0;
  font-family:system-ui,Roboto,Arial;
  background:linear-gradient(180deg,var(--bg1),var(--bg2));
  color:white;
  min-height:100vh;
  overflow-x:hidden;
  font-size: 16px; /* Tamaño base para móviles */
  
}

/* === Pantalla de menú === */
#cityMenu {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
  gap:14px;
  padding:20px 15px;
  min-height:100vh;
  box-sizing:border-box;
}
.city-card {
  background:rgba(255,255,255,0.06);
  border-radius:14px;
  text-align:center;
  padding:18px 12px;
  cursor:pointer;
  transition:all .3s ease;
  box-shadow:0 4px 16px rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
}
.city-card:hover {
  transform:translateY(-5px);
  background:rgba(255,255,255,0.1);
}
.city-name {
  font-size:1.1rem;
  font-weight:600;
  position: relative;
  z-index: 2;
}
.city-region {
  font-size:.85rem;
  opacity:.8;
  position: relative;
  z-index: 2;
}
.city-probability {
  margin-top:6px; 
  font-size:0.9rem; 
  opacity:0.85;
  position: relative;
  z-index: 2;
}
.probability-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #4CAF50, #FFC107, #F44336);
  transition: width 0.5s ease;
}

/* === Contenedor principal === */
#appContainer {
  display:none;
  padding:15px;
  max-width:1000px;
  margin:auto;
}

button.back {
  background:transparent;
  border:1px solid rgba(255,255,255,0.3);
  border-radius:8px;
  color:white;
  padding:10px 15px;
  margin-bottom:15px;
  cursor:pointer;
  font-size: 1rem;
}

.data-block {
  background:rgba(255,255,255,0.05);
  border-radius:12px;
  padding:12px;
  margin:10px 0;
}
canvas {
  background:rgba(255,255,255,0.05);
  border-radius:12px;
  padding:8px;
  max-width: 100%;
}
img.sat {
  max-width:100%;
  border-radius:12px;
  margin-top:8px;
}

/* Estilos de la parte 2 */
.container {
  max-width:1000px;
  margin:0 auto;
  background: rgba(0,0,0,0.25);
  border-radius:14px;
  padding:15px;
  box-shadow:0 6px 30px rgba(0,0,0,0.5);
}

.satellite-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.satellite-wrapper img {
  display: block;
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

.overlay {
  position: absolute;
  color: white;
  font-family: Arial, sans-serif;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
  font-size: 0.9rem;
}

.overlay.orientation {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: bold;
  font-size: 1em;
}

.overlay.scale {
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}

.scale-bar {
  width: 80px;
  height: 6px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 2px;
}

.overlay.instrument {
  bottom: 8px;
  right: 14px;
  font-size: 0.8em;
  opacity: 0.8;
}

h1 { 
  margin:0 0 8px 0; 
  font-size:1.5rem; 
}
p.lead { 
  margin:0 0 12px 0; 
  opacity:0.9; 
  font-size: 0.95rem;
}

.controls { 
  display:flex; 
  gap:10px; 
  flex-wrap:wrap; 
  margin:12px 0; 
}

select, button, input, textarea {
  padding:12px;
  border-radius:8px;
  border:none;
  font-size:1rem;
  box-sizing:border-box;
  min-height: 44px; /* Tamaño mínimo */
}

select, input { 
  background: rgba(255,255,255,0.06); 
  color: #fff; 
  width: 100%;
}

button { 
  background:var(--accent); 
  color:#fff; 
  cursor:pointer; 
  font-weight:600; 
  flex: 1;
  min-width: 140px;
}

button.ghost { 
  background: transparent; 
  border:1px solid rgba(255,255,255,0.08); 
}

.grid { 
  display:grid; 
  grid-template-columns:1fr 420px; 
  gap:16px; 
  align-items:start; 
}

.panel { 
  background:var(--card); 
  padding:15px; 
  border-radius:10px; 
}

#result { 
  min-height:120px; 
}

.sun-times { 
  display:flex; 
  gap:8px; 
  flex-wrap:wrap; 
  justify-content:flex-start; 
  margin:10px 0; 
}
.sun-time { 
  background: rgba(255,255,255,0.04); 
  padding:10px 12px; 
  border-radius:8px; 
  font-size: 0.95rem;
}

.data-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important; /* 3 columnas */
    grid-auto-flow: row !important; /* los items fluyen por filas */
    gap: 10px !important;
    width: 100% !important;
}
.data-item {
    background: #2a2a2a;
    padding: 8px;
    border-radius: 6px;
    font-size: 14px;
}

.predictions { 
  display:flex; 
  gap:10px; 
  margin-top:15px;
  flex-wrap: wrap;
}

.probability {
    font-size: 32px;         
    font-weight: bold;
    text-align: center;
    padding: 15px;
    border-radius: 10px;
    margin-top: 10px;
    width: 100%;
    box-sizing: border-box; 
    display: flex;
    flex-direction: column;
    justify-content: center; 
    align-items: center;     
    line-height: 1.2;        
}

.probability span {
    font-size: 40px;         
}

.high-prob { 
  background: rgba(255,204,0,0.18); 
  color:#ffd24d; 
}
.medium-prob { 
  background: rgba(255,153,102,0.12); 
  color:#ffb07a; 
}
.low-prob { 
  background: rgba(204,102,51,0.12); 
  color:#e09b79; 
}

#satelliteImage { 
  width:100%; 
  height:auto; 
  max-height: 300px;
  object-fit:cover; 
  border-radius:8px; 
  display:block; 
  margin-top:8px; 
}

.loading { 
  display:inline-block; 
  width:18px; 
  height:18px; 
  border:3px solid rgba(255,255,255,0.2); 
  border-top-color:#fff; 
  border-radius:50%; 
  animation:spin 1s linear infinite; 
}
@keyframes spin { 
  to { transform: rotate(360deg); } 
}

.charts {
  display: flex;
  flex-direction: column;
  margin-top: 15px;
  height: 400px; /* Altura fija para todo el contenedor */
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* Canvas del gráfico con altura controlada */
#cloudChart {
  flex: 1;
  min-height: 0; /* Importante para que flex funcione correctamente */
  width: 100% !important;
  height: 100% !important;
}

/* Leyenda de horas (amanecer/atardecer/hora actual) */
.chart-time-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 5px 0 10px 0;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  z-index: 5;
  order: 1; /* Se asegura que esté antes del gráfico */
}

/* Para móvil */
@media (max-width: 768px) {
  .charts {
    height: 420px;
  }
  
  .chart-time-legend {
    gap: 8px;
    margin: 3px 0 8px 0;
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .charts {
    height: 380px;
    margin-top: 12px;
  }
  
  .chart-time-legend {
    gap: 6px;
    margin: 2px 0 6px 0;
    padding: 5px 8px;
    font-size: 0.75rem;
  }
}

/* Asegurar que el gráfico de Chart.js no se desborde */
.chartjs-render-monitor {
  position: relative !important;
  height: 100% !important;
  width: 100% !important;
}

/* Ajustar el padding del contenedor del gráfico */
.chartjs-container {
  flex: 1;
  position: relative;
  min-height: 0;
}

.footer {
  background-color: #1e1e1e;
  color: #e0e0e0;
  text-align: center;
  padding: 10px;
  position: relative;
  bottom: 0px;
  width: 100%;
}

.footer a {
    margin: 0;
    font-size: 10px;
}

.footer p {
    margin: 0 0 1px 0;
    font-size: 12px;
}

.footer nav a {
    color: #ccc;
    text-decoration: none;
    margin: 0 2px;
    font-size: 12px;
    transition: color 0.3s ease, text-decoration 0.3s ease;
}

.footer nav a:hover {
    color: #1e90ff; /* Cambia a un color azul cuando el cursor está sobre el enlace */
    text-decoration: underline; /* Subraya el enlace */
}

.footer nav a:active {
    color: #f39c12; /* Cambia el color cuando se hace clic */
}

.footer nav .fa-instagram:hover {
    color: #e4405f; /* Cambia el color del icono de Instagram al pasar el cursor */
}

.footer nav a.fa {
    font-size: 20px;
    margin: 0 10px;
    transition: transform 0.3s ease;
}

.footer nav a.fa:hover {
    transform: scale(1.2); /* Agranda el icono ligeramente al pasar el cursor */
}

.titulo-sticky {
    position: sticky;
    top: 0;
    background: #fff;
    padding: 10px 0;
    text-align: center;
    font-size: 1.6rem;
    border-bottom: 1px solid #ddd;
    z-index: 10;
}

/* ========== ESTILOS ESPECÍFICOS PARA MAPA Y LEYENDA ========== */
/* MAPA CON HEXÁGONOS */
.map-wrapper {
  position: relative;
  height: 450px;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 10px;
}

#map {
  height: 100%;
  width: 100%;
}

/* LEYENDA CENTRADA ABAJO CON GRADIENTE ORIGINAL */
.probability-legend {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 0.8rem;
  z-index: 1000;
  min-width: 250px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.legend-title {
  margin-bottom: 8px;
  font-weight: bold;
}

.legend-gradient {
  height: 8px;
  width: 100%;
  background: linear-gradient(to right, 
    #2b83ba,  /* Azul - 0% */
    #abdda4,  /* Verde claro - 25% */
    #ffffbf,  /* Amarillo - 50% */
    #fdae61,  /* Naranja - 75% */
    #d7191c   /* Rojo - 100% */
  );
  margin-bottom: 8px;
  border-radius: 6px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  opacity: 0.9;
}

/* CONTROLES SIMPLIFICADOS DEL MAPA */
.map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.map-toggle {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border: none;
  padding: 8px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.map-toggle.active {
  background: #4CAF50;
}

/* LOG */
#log {
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  max-height: 100px;
  overflow-y: auto;
  margin-top: 10px;
}

/* ========== MEDIA QUERIES (COMPLETAS) ========== */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }
  
  #cityMenu {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    padding: 15px 10px;
  }
  
  .city-card {
    padding: 15px 8px;
  }
  
  .city-name {
    font-size: 1rem;
  }
  
  .city-region {
    font-size: 0.8rem;
  }
  
  .container {
    padding: 12px;
  }
  
  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .panel {
    padding: 12px;
  }
  
  h1 {
    font-size: 1.3rem;
  }
  
  p.lead {
    font-size: 0.9rem;
  }
  
  .controls {
    flex-direction: column;
  }
  
  button {
    width: 100%;
  }
  
  .data-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .predictions {
    flex-direction: column;
  }
  
  .probability {
    width: 100%;
    min-width: auto;
    font-size: 28px;
  }
  
  .probability span {
    font-size: 32px;
  }
  
  .sun-times {
    justify-content: space-between;
  }
  
  .sun-time {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.9rem;
  }
  
  .overlay {
    font-size: 0.8rem;
  }
  
  .overlay.scale {
    bottom: 15px;
  }
  
  .scale-bar {
    width: 60px;
  }
  
  .overlay.instrument {
    font-size: 0.7rem;
  }
  
  #satelliteImage {
    max-height: 250px;
  }
  
  /* Ajustes para el mapa en tablet */
  .map-wrapper {
    height: 400px;
  }
  
  .probability-legend {
    min-width: 220px;
    font-size: 0.75rem;
    padding: 8px 12px;
  }
  
  .legend-labels {
    font-size: 0.65rem;
  }
  
  .charts {
    height: 350px;
  }
}

@media (max-width: 480px) {
  #cityMenu {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .container {
    padding: 10px;
  }
  
  .panel {
    padding: 10px;
  }
  
  h1 {
    font-size: 1.2rem;
  }
  
  .data-item {
    padding: 8px;
    font-size: 0.85rem;
  }
  
  .probability {
    padding: 10px;
    font-size: 24px;
  }
  
  .probability span {
    font-size: 28px;
  }
  
  #satelliteImage {
    max-height: 200px;
  }
  
  .overlay.orientation {
    font-size: 0.9rem;
  }
  
  .overlay.scale {
    font-size: 0.75rem;
  }
  
  .overlay.instrument {
    font-size: 0.65rem;
  }
  
  /* Ajustes para el mapa en móvil */
  .map-wrapper {
    height: 350px;
  }
  
  .probability-legend {
    min-width: 200px;
    font-size: 0.7rem;
    padding: 8px 12px;
  }
  
  .legend-labels {
    font-size: 0.6rem;
  }
  
  .map-toggle {
    padding: 6px 10px;
    font-size: 0.75rem;
    min-width: 60px; /* Ancho mínimo */
    max-width: 100px; /* Ancho máximo */
    width: auto; /* Se ajusta al contenido */
  }
  
  .charts {
    height: 350px;
    margin-top: 12px;
  }
}

/* Desktop específico - 4 columnas para .data-grid */
@media (min-width: 769px) {
  .data-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

.lead {
  margin: 0 0 20px 0;  
  max-width: calc(100% - 40px); /* 20px a cada lado */
  opacity: 0.95;
  font-size: 0.95rem;
  padding: 20px 24px;
  background: linear-gradient(
    135deg,
    rgba(0, 25, 51, 0.7),
    rgba(102, 0, 0, 0.5)
  );
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  line-height: 1.7;
  box-shadow: 
    0 6px 20px rgba(0, 0, 0, 0.25),
    inset 0 1px 1px rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

/* Icono de información opcional */
.lead:after {
  content: "ⓘ";
  position: absolute;
  top: 10px;
  right: 12px;
  opacity: 0.3;
  font-size: 0.8rem;
}