/* General */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: #e6f0ff;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Login */
.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 12px;
  padding: 2rem;
  margin: auto;
  box-shadow: 0 4px 20px rgba(0, 51, 102, 0.15);
  transition: all 0.3s ease-in-out;
}

h1 {
  text-align: center;
  color: #003366;
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

label {
  font-weight: 600;
  color: #003366;
}

.btn-primary {
  background-color: #003366;
  border-color: #003366;
  transition: background-color 0.3s ease;
}

.btn-primary:hover {
  background-color: #00509e;
  border-color: #00509e;
}

#login-error {
  text-align: center;
  margin-top: 0.75rem;
  color: #cc0000;
  font-size: 0.9rem;
}

/* Secciones */
.seccion {
  margin-top: 56px;
  padding: 20px;
}

.d-none {
  display: none !important;
}

.visible {
  display: block;
}

table {
  margin-top: 1rem;
}

/* Navegación */
.nav-tabs {
  z-index: 1000;
  position: fixed;
  top: 0;
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid #ccc;
}

.nav-tabs .nav-link {
  color: #003366;
  font-weight: bold;
}

.nav-tabs .nav-link.active {
  color: #00509e;
  border-color: #00509e #00509e #fff;
}

/* Mapa */
#map {
  width: 100vw;
  height: calc(100vh - 56px);
  position: fixed;
  top: 56px;
  left: 0;
  z-index: 1;
}

/* Gráficos de viento */
#wind-chart-container {
  position: fixed;
  top: 70px;
  left: 20px;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 500;
}

#wind-chart {
  max-width: 250px;
  max-height: 250px;
}

/* Panel derecho */
#panel-derecho {
  position: absolute;
  top: 56px;
  right: 0;
  width: 30%;
  height: calc(100vh - 56px);
  background: white;
  border-left: 2px solid #ccc;
  overflow-y: auto;
  padding: 20px;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.15);
  z-index: 999;
}

#panel-derecho table {
  width: 100%;
  border-collapse: collapse;
}

#panel-derecho th,
#panel-derecho td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
}

#panel-derecho th {
  background: #f5f5f5;
}

/* Forecast container */
#forecast-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  max-height: 220px;
  background: rgba(255, 255, 255, 0.95);
  overflow-y: auto;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
  z-index: 800;
  padding: 10px;
}

#forecast-container h4 {
  margin-top: 0;
  font-size: 16px;
  font-weight: bold;
  color: #003366;
}

#forecast-table-wrapper {
  max-height: 160px;
  overflow-y: auto;
}

#forecast-container table {
  width: 100%;
  font-size: 12px;
}

#forecast-container th,
#forecast-container td {
  padding: 4px 6px;
  text-align: center;
  border: 1px solid #ddd;
}

/* Flechas */
.arrow-icon {
  display: inline-block;
  transform-origin: center;
  font-size: 18px;
  font-weight: bold;
  color: white;
  background: #003366;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  text-align: center;
  line-height: 24px;
}

/* Mejoras responsivas */
@media (max-width: 768px) {
  #panel-derecho {
    width: 100%;
    position: static;
    height: auto;
    border-left: none;
    box-shadow: none;
  }

  #forecast-container {
    max-height: 160px;
  }
}


/* Subtabs específicas dentro de Datos */
#datos .nav-tabs {
  position: relative;
  top: auto;
  margin-top: 20px;
  background: none;
  border-bottom: 1px solid #ddd;
}


td.fecha {
  white-space: nowrap;
}

/* ========================
   Ajustes visuales suaves
   ======================== */

/* El nav ya es fixed; esto ayuda a anclas/hashes si usas alguna */
html {
  scroll-padding-top: 56px;
}

/* Mejor contraste del tab activo y borde inferior */
.nav-tabs .nav-link.active {
  color: #003366;
  border-color: #00509e #00509e #fff;
  font-weight: 700;
}

/* Resaltar encabezados en tablas del panel derecho */
#panel-derecho th {
  background: #eef4ff;
  color: #003366;
  font-weight: 700;
}

/* Hover sencillo para filas (solo visual, no funcional) */
#panel-derecho tr:hover td {
  background: #f8fbff;
}

/* Las flechas se ven bien, pero en fondos claros queda mejor el borde */
.arrow-icon {
  border: 1px solid rgba(0,0,0,0.08);
}

/* ========================
   Móvil / pantallas pequeñas
   ======================== */
@media (max-width: 768px) {
  /* Cuando el panel se vuelve estático, el mapa no debe ser fixed
     para evitar solaparse y permitir scroll natural */
  #map {
    position: relative;
    top: 0;
    height: 45vh;         /* antes fixed casi pantalla completa */
    width: 100%;
  }

  /* El contenedor del wind chart acompaña al mapa en relativo */
  #wind-chart-container {
    position: absolute;   /* relativo al contenedor más cercano posicionado */
    top: 10px;
    left: 10px;
  }

  /* Forecast más compacto en móvil */
  #forecast-container {
    max-height: 140px;
  }
}

/* ========================
   Detalles de layout en escritorio
   ======================== */

/* Si prefieres que el mapa NO quede cubierto por el panel derecho,
   puedes reducirle ancho visual en escritorio. Si no, omite este bloque. */
/*
@media (min-width: 992px) {
  #map {
    width: calc(100vw - 30%);  // 30% del panel
  }
}
*/

/* Opcional: botón login al hacer foco */
.btn-primary:focus {
  box-shadow: 0 0 0 0.25rem rgba(0,80,158,.25);
}


/* === 1) Variable de ancho del panel para mantener todo sincronizado === */
:root { --panel-w: 30%; }            /* mismo valor que #panel-derecho */

/* Usa la variable en el panel (opcional si quieres mantener una sola fuente de verdad) */
#panel-derecho { width: var(--panel-w); }

/* === 2) Forecast que no invada el panel === */
#forecast-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: var(--panel-w);              /* <-- en lugar de width:100vw */
  width: auto;                        /* deja que el right defina el ancho */
  max-height: 220px;
  background: rgba(255, 255, 255, 0.95);
  overflow-y: auto;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
  z-index: 800;
  padding: 10px;
}

/* === 3) Scroll horizontal real del contenido de la tabla === */
/* Ojo: en el HTML el div es #forecast-matrix (no #forecast-table-wrapper) */
#forecast-matrix {
  overflow-x: auto;                   /* barra horizontal */
  -webkit-overflow-scrolling: touch;  /* scroll suave en móvil */
  white-space: nowrap;                /* que las celdas no se rompan */
}

#forecast-matrix table {
  width: max-content;                 /* que crezca según contenido */
  font-size: 12px;
}

/* === 4) Responsive: cuando el panel pasa a estático/ancho completo, el forecast vuelve a ocupar todo === */
@media (max-width: 768px) {
  :root { --panel-w: 0%; }            /* el panel ya no ocupa lateral */
  #forecast-container { right: 0; }   /* forecast a todo el ancho */
}
.arrow-icon {
  width: 24px; height: 24px;
  color: #fff;               /* relleno del path */
  background: #003366;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08);
  padding: 3px;              /* deja margen interno para la cabeza */
  box-sizing: border-box;
}
