/*! (c) 2025 @meteobezana - Bezana Explorer. Todos los derechos reservados. */

/* ══════════════════════════════════════════════════
   BOTTOM NAV — Solo visible en móvil (≤ 768px)
   ══════════════════════════════════════════════════ */

/* ── La barra en sí ── */
#bottom-nav {
  display: none; /* se muestra solo en móvil via media query */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 8000;
  height: calc(58px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--glass-bg-strong, rgba(255,255,255,.96));
  border-top: 1px solid var(--ink-12, rgba(15,23,42,.1));
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -4px 24px rgba(15,23,42,.08);
  /* Animación de entrada */
  animation: bnSlideUp .32s cubic-bezier(.34,1.2,.64,1) both;
}

@keyframes bnSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Contenedor de tabs ── */
.bn-tabs {
  display: flex;
  align-items: stretch;
  height: 58px;
}

/* ── Tab individual ── */
.bn-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: background .14s;
  /* Quitar tap highlight nativo */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  border-radius: 0;
  font-family: var(--font-ui, 'Inter', sans-serif);
}

.bn-tab:active {
  background: rgba(59,125,216,.06);
}

/* ── Borde activo arriba ── */
.bn-tab::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2.5px;
  border-radius: 0 0 3px 3px;
  background: var(--c-accent, #3b7dd8);
  opacity: 0;
  transform: scaleX(0);
  transition: opacity .2s, transform .22s cubic-bezier(.34,1.4,.64,1);
}

.bn-tab.active::before {
  opacity: 1;
  transform: scaleX(1);
}

/* ── Icono ── */
.bn-icon {
  font-size: 22px !important;
  line-height: 1;
  color: var(--ink-30, rgba(15,23,42,.35));
  transition: color .18s, transform .2s cubic-bezier(.34,1.4,.64,1);
  display: block;
}

.bn-tab.active .bn-icon {
  color: var(--c-accent, #3b7dd8);
  transform: translateY(-1px) scale(1.08);
}

/* ── Badge de notificación (para Meteo) ── */
.bn-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 14px);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #dc2626;
  border: 1.5px solid var(--glass-bg-strong, #fff);
  display: none;
}

/* ── Etiqueta ── */
.bn-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-30, rgba(15,23,42,.35));
  letter-spacing: .01em;
  transition: color .18s;
  white-space: nowrap;
  line-height: 1;
}

.bn-tab.active .bn-label {
  color: var(--c-accent, #3b7dd8);
}

/* ── Pill de fondo activo ── */
.bn-pill {
  position: absolute;
  inset: 6px 8px;
  border-radius: 12px;
  background: rgba(59,125,216,.1);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.bn-tab.active .bn-pill {
  opacity: 1;
}


/* ══════════════════════════════════════════════════
   AJUSTES DEL MAPA cuando el nav está visible
   ══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #bottom-nav {
    display: block;
  }

  /* Empujar el mapa y controles hacia arriba para no quedar tapados */
  #map-wrap,
  #map {
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* FABs: subir para que no queden detrás del nav */
  #map-controls {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 14px) !important;
  }

  /* Panel de capas: cuando está abierto en móvil, limitamos la altura
     para que quede por encima de la bottom nav */
  #panel {
    max-height: calc(85dvh - 58px - env(safe-area-inset-bottom, 0px)) !important;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Modal POI: no solapar */
  #modal {
    margin-bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Paneles de medir y compartir */
  #measure-panel,
  #share-panel {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 14px) !important;
    top: auto !important;
    transform: none !important;
  }

  /* Toast: sobre el nav */
  #toast {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 14px) !important;
  }

  /* Ocultar los botones de la topbar que ahora están en el nav */
  #layers-btn,
  #info-btn,
  .tb-right--desktop-only {
    display: none !important;
  }

  /* La barra de búsqueda ocupa todo el ancho disponible */
  #search-wrap {
    flex: 1 1 auto !important;
  }

  /* Escalar el mapa: leaflet zoom */
  .leaflet-bottom.leaflet-right {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 6px) !important;
  }
}


/* ══════════════════════════════════════════════════
   DARK MODE
   ══════════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  #bottom-nav {
    background: rgba(17, 20, 24, .97);
    border-top-color: rgba(255,255,255,.1);
    box-shadow: 0 -4px 24px rgba(0,0,0,.35);
  }
  .bn-pill {
    background: rgba(59,125,216,.18);
  }
  .bn-tab:active {
    background: rgba(255,255,255,.05);
  }
}

/* ══════════════════════════════════════════════════
   METEO TAB — color especial (cyan)
   ══════════════════════════════════════════════════ */
#bn-meteo.active .bn-icon,
#bn-meteo.active .bn-label {
  color: #0ea5a0;
}
#bn-meteo.active .bn-pill {
  background: rgba(14,165,160,.12);
}
#bn-meteo.active::before {
  background: #0ea5a0;
}

/* ══════════════════════════════════════════════════
   CONTRIBUIR TAB — color especial (coral/amber)
   ══════════════════════════════════════════════════ */
#bn-contrib.active .bn-icon,
#bn-contrib.active .bn-label {
  color: #d97706;
}
#bn-contrib.active .bn-pill {
  background: rgba(217,119,6,.1);
}
#bn-contrib.active::before {
  background: #d97706;
}

/* ══════════════════════════════════════════════════
   Animación tap (ripple ligero)
   ══════════════════════════════════════════════════ */
.bn-tab .bn-ripple {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: var(--c-accent, #3b7dd8);
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.bn-tab.tapped .bn-ripple {
  opacity: .08;
  transform: scale(1.2);
}
