/* =========================================
   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;
}

body { padding-top: 60px; }

/* =========================================
   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;
}

.btn-primary:focus {
  box-shadow: 0 0 0 0.25rem rgba(0,80,158,.25);
}

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

/* =========================================
   SECCIONES Y TABLAS
========================================= */
.seccion {
  margin-top: 56px;
  padding: 20px;
}

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

table { margin-top: 1rem; }

td.fecha { white-space: nowrap; }

/* =========================================
   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;
  font-weight: 700;
}

.nav-logo {
  height: 32px;
  width: auto;
  display: block;
}

@media (min-width: 992px) {
  .nav-logo { height: 36px; }
}

/* =========================================
   MAPA
========================================= */
#map {
  width: 100vw;
  height: calc(100vh - 56px - 220px); /* deja espacio para el forecast */
  position: fixed;
  top: 56px;
  left: 0;
  z-index: 1;
  transition: height 0.3s ease-in-out;
}

/* =========================================
   GRÁFICOS DE VIENTO (ROSA)
========================================= */
#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: var(--panel-w, 30%);
  height: calc(100vh - 56px - 220px); /* se ajusta según forecast */
  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;
  transition: height 0.3s ease-in-out;
}

#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: #eef4ff;
  color: #003366;
  font-weight: 700;
}

#panel-derecho tr:hover td {
  background: #f8fbff;
}

/* =========================================
   FORECAST CONTAINER (FOOTER EXPANDIBLE)
========================================= */
#forecast-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid #ccc;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
  z-index: 800;
  padding: 10px;

  /* comportamiento expandible */
  height: 35vh;
  min-height: 220px;
  max-height: 80vh;
  resize: vertical;
  overflow-y: auto;
  transition: height 0.25s ease-in-out;
}

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

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

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

/* =========================================
   ICONOS DE FLECHA
========================================= */
.arrow-icon {
  width: 24px;
  height: 24px;
  color: #fff;
  background: #003366;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08);
  padding: 3px;
  box-sizing: border-box;
  display: inline-block;
  text-align: center;
  transform-origin: center;
  font-size: 18px;
  font-weight: bold;
  line-height: 24px;
}

/* =========================================
   SUBTABS DE SECCIÓN DATOS
========================================= */
#datos .nav-tabs {
  position: relative;
  top: auto;
  margin-top: 20px;
  background: none;
  border-bottom: 1px solid #ddd;
}

/* =========================================
   AJUSTES VISUALES SUAVES
========================================= */
html { scroll-padding-top: 56px; }

/* =========================================
   RESPONSIVE (MÓVILES)
========================================= */
@media (max-width: 768px) {
  /* Mapa relativo (scroll natural) */
  #map {
    position: relative;
    top: 0;
    height: 45vh;
    width: 100%;
  }

  /* Rosa de vientos relativa */
  #wind-chart-container {
    position: absolute;
    top: 10px;
    left: 10px;
  }

  /* Panel derecho apilado */
  #panel-derecho {
    width: 100%;
    position: static;
    height: auto;
    border-left: none;
    box-shadow: none;
  }

  /* Forecast compacto */
  #forecast-container {
    position: relative;
    bottom: 0;
    max-height: 180px;
  }

  :root { --panel-w: 0%; }
}

/* === Barra de agarre para expandir forecast hacia arriba === */
#forecast-handle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 6px;
  background: #ccc;
  border-radius: 3px;
  cursor: ns-resize;
  transition: background 0.2s;
}

#forecast-handle:hover {
  background: #888;
}
