/* ============================================================
   main.css — Variables, reset, tipografía, layout base
   MeteoMontaña PWA
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* Fondo con profundidad — no negro plano */
  --bg-primary:      #080C14;
  --bg-layer1:       #0F1623;
  --bg-layer2:       #141C2E;
  --bg-card:         rgba(255,255,255,0.05);
  --bg-card-alt:     rgba(255,255,255,0.08);
  --bg-input:        rgba(255,255,255,0.06);
  --bg-overlay:      rgba(8, 12, 20, 0.88);

  /* Glass */
  --glass-bg:        rgba(15, 22, 35, 0.72);
  --glass-border:    rgba(255, 255, 255, 0.08);
  --glass-blur:      20px;

  --color-primary:   #34C759;
  --color-secondary: #30B350;
  --color-accent:    #5DDC7C;
  --color-text:      #F0F4FA;
  --color-text-muted:#6B7A99;
  --color-border:    rgba(255, 255, 255, 0.07);

  --color-optimo:    #22C55E;
  --color-aceptable: #F59E0B;
  --color-adverso:   #EF4444;

  --border-radius:   16px;
  --border-radius-sm: 12px;
  --border-radius-xs: 8px;

  --font-body:       'Inter', system-ui, -apple-system, sans-serif;
  --font-heading:    'Inter', system-ui, -apple-system, sans-serif;

  --nav-height:      60px;
  --header-height:   56px;

  --shadow-card:     0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-dropdown: 0 16px 40px rgba(0, 0, 0, 0.7);
  --shadow-glow-primary: 0 0 20px rgba(52, 199, 89, 0.25);
  --transition:      all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--bg-primary);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: pan-x pan-y;
  /* Gradiente de fondo sutil para dar profundidad */
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(52,199,89,0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(52,199,89,0.04) 0%, transparent 50%);
}

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; letter-spacing: -0.3px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

p   { font-size: 14px; line-height: 1.5; color: var(--color-text-muted); }
a   { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { list-style: none; }

img { max-width: 100%; display: block; }

button { cursor: pointer; font-family: var(--font-body); }
input, select, textarea {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
}

/* ── Scrollbar personalizado ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }

/* ── Layout SPA ─────────────────────────────────────────────── */
#app {
  position: fixed;
  /* Respeta la barra de estado (notch / isla dinámica) */
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.screen.active {
  display: flex;
  animation: screenSlideIn 0.28s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.screen.slide-back.active {
  animation: screenSlideBack 0.28s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes screenSlideIn {
  from { opacity: 0; transform: translateX(22px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes screenSlideBack {
  from { opacity: 0; transform: translateX(-22px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Las pantallas tienen padding-bottom para que el bottom-nav no tape el contenido */
.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 24px);
}

/* Login: sin nav, centrado */
#screen-login {
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #0D1F3A 0%, var(--bg-primary) 100%);
}

/* ── Números condensados (7B) ───────────────────────────────── */
.num {
  font-weight: 900;
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  line-height: 1;
}
.num-xl  { font-size: 36px; }
.num-lg  { font-size: 28px; }
.num-md  { font-size: 22px; }

/* ── Header de pantalla (9B — oculta al bajar, reaparece al subir) */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
  min-height: var(--header-height);
  flex-shrink: 0;
  /* Transición suave */
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1), opacity 0.28s ease;
  will-change: transform;
}

.screen-header.header-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

/* El body del screen sube cuando el header desaparece */
.screen-header + * {
  transition: margin-top 0.28s cubic-bezier(0.4,0,0.2,1);
}

.screen-header.header-hidden + * {
  margin-top: calc(-1 * var(--header-height));
}

.screen-header h1,
.screen-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.3px;
}

/* ── Bottom Navigation ──────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--glass-border);
}

#bottom-nav.hidden          { display: none; }
#bottom-nav.keyboard-hidden { display: none; }

/* Botón inactivo: solo icono */
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  transition: var(--transition);
  padding: 8px 0 6px;
  position: relative;
}

.nav-btn .nav-icon  { font-size: 22px; line-height: 1; transition: var(--transition); }
.nav-btn .nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.2px; display: none; }

/* Activo: icono + etiqueta + dot indicator */
.nav-btn.active {
  color: var(--color-primary);
}
.nav-btn.active .nav-icon  { transform: translateY(-1px); }
.nav-btn.active .nav-label { display: block; }

/* Dot debajo del activo */
.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--color-primary);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--color-primary);
}

.nav-btn:active { opacity: 0.6; transform: scale(0.92); }

/* ── Utilidades ─────────────────────────────────────────────── */
.hidden        { display: none !important; }
.text-muted    { color: var(--color-text-muted); }
.text-primary  { color: var(--color-primary); }
.text-center   { text-align: center; }
.flex-between  { display: flex; justify-content: space-between; align-items: center; }
.mt-8          { margin-top:  8px; }
.mt-16         { margin-top: 16px; }
.mt-24         { margin-top: 24px; }
.mb-8          { margin-bottom:  8px; }
.mb-16         { margin-bottom: 16px; }


/* Loading overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 8888;
}
#loading-overlay.hidden { display: none; }
#loading-overlay p { color: var(--color-text-muted); font-size: 13px; }

.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Slide-up (17B): contenido que aparece al cargar datos ──────────────── */
@keyframes slideUpIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.slide-up-in {
  animation: slideUpIn 0.32s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (min-width: 768px) {
  .screen-body { padding: 24px; padding-bottom: calc(var(--nav-height) + 24px); }
  h1 { font-size: 24px; }
}
