* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin:0; padding:0; background:#f4f6f8; color:#333; }
header { background:#0b5394; color:white; padding:12px 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
header > div { display: flex; align-items: center; justify-content: space-between; }
header h1 { margin:0; font-size:22px; font-weight:600; }
header nav { margin-left: auto; }
header p { margin:4px 0 0; font-size:14px; opacity:0.9; }
main { padding:16px 20px; max-width:1400px; margin:0 auto; }
#controls { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; align-items:center; }
#controls input { padding:8px 12px; border:1px solid #ccc; border-radius:4px; font-size:14px; flex:1; min-width:200px; }
#controls button { padding:8px 16px; border:none; background:#0b5394; color:white; border-radius:4px; cursor:pointer; font-size:14px; }
#controls button:hover { background:#094176; }
#controls button:disabled { background:#ccc; cursor:not-allowed; }
#pager { display:flex; gap:8px; align-items:center; }
#pageinfo { font-weight:600; }
#stations { display:grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap:12px; }
.station-row { background:white; padding:0; border-radius:8px; box-shadow:0 2px 4px rgba(0,0,0,0.1); transition:box-shadow 0.2s; overflow:hidden; }
.station-row:hover { box-shadow:0 4px 12px rgba(0,0,0,0.15); }
.station-header { background:#0b5394; color:white; padding:12px 16px; margin-bottom:0; }
.station-row .name { font-size:18px; font-weight:600; margin:0 0 4px 0; }
.station-row .last-date { font-size:13px; opacity:0.9; }

/* Secciones principales */
.section-mediciones, .section-precipitaciones, .section-temp-extremas { margin-bottom:0; }
.section-title { background:#0b5394; color:white; padding:8px 16px; margin:0; font-size:14px; font-weight:600; text-align:center; }
.mediciones-grid, .precipitaciones-grid, .temp-extremas-grid { padding:12px 16px; }
.precipitaciones-grid { display: grid; grid-template-columns: 1fr; gap: 0; }

/* Items de mediciones, precipitaciones y temperaturas extremas */
.measurement-item, .precipitation-item, .temp-extrema-item { display:flex; justify-content:space-between; align-items:center; padding:6px 0; border-bottom:1px solid #f0f0f0; }
.measurement-item:last-child, .precipitation-item:last-child, .temp-extrema-item:last-child { border-bottom:none; }
.measurement-label, .precipitation-label, .temp-extrema-label { font-size:13px; color:#333; }
.measurement-value, .precipitation-value, .temp-extrema-value { font-weight:600; color:#0b5394; font-size:14px; }

/* Valores N/A con estilo diferenciado */
.measurement-item .value:contains("N/A"), .precipitation-item .value:contains("N/A") { color:#999; font-weight:400; font-style:italic; }
.measurement-item:has(.value:contains("N/A")) { opacity:0.5; }

/* Estados sin datos */
.no-data { color:#999; font-style:italic; text-align:center; padding:8px 0; }

/* Estaciones sin datos recientes */
.station-row.no-recent-data { opacity:0.7; border-left:4px solid #ffc107; }
.station-row.no-recent-data .station-header { background:#6c757d; }
.station-row.no-recent-data .section-title { background:#6c757d; }

/* Botones de paginación deshabilitados */
#controls button:disabled { background:#6c757d; cursor:not-allowed; opacity:0.6; }
.hidden { display:none; }
#modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none; /* Oculto por defecto */
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#modal.show {
  display: flex; /* Se muestra cuando tiene clase 'show' */
}
.modal-content { background:white; padding:20px; border-radius:8px; width:90%; max-width:900px; max-height:80vh; overflow:auto; position:relative; }
.modal-content button#close { position:absolute; top:10px; right:10px; padding:6px 12px; border:none; background:#dc3545; color:white; border-radius:4px; cursor:pointer; }
.modal-content button#close:hover { background:#c82333; }
@media (max-width: 768px) {
  #stations { grid-template-columns: 1fr; }
  #controls { flex-direction:column; align-items:stretch; }
  #controls input { min-width:100%; }
  
  /* Logo más pequeño en móvil */
  header svg[width="48"] { width: 36px; height: 36px; }
  header h1 { font-size: 18px; }
  header p { font-size: 11px; }
  
  /* Menú hamburguesa en móvil */
  .menu-toggle {
    display: block !important;
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: auto;
  }
  
  header nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 83, 148, 0.97); /* Azul del header con transparencia */
    z-index: 1000;
    flex-direction: column;
    padding: 60px 20px 20px;
    gap: 0;
  }
  
  header nav.active {
    display: flex !important;
  }
  
  header nav a {
    margin: 0 !important;
    padding: 16px 20px !important;
    font-size: 18px !important;
    border-radius: 0 !important;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    justify-content: flex-start;
  }
  
  .close-menu {
    display: block;
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
  }
  
  header > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

/* Estilos para desktop */
@media (min-width: 769px) {
  .menu-toggle {
    display: none !important;
  }
  
  .close-menu {
    display: none !important;
  }
  
  header nav {
    display: flex !important;
    gap: 10px;
  }
  
  header nav a {
    white-space: nowrap;
  }
  
  /* Ocultar texto en desktop, solo mostrar iconos */
  header nav .nav-text {
    display: none;
  }
}

/* Mostrar texto en menú móvil */
@media (max-width: 768px) {
  header nav .nav-text {
    display: inline;
  }
}
