/*
 * pwa-standalone.css — Smile Dental Lab
 * iOS + Android: barra inferior siempre visible en móvil
 */

:root {
  --app-accent: #dc2626;
  --nav-h: 58px;
}

/* ══════════════════════════════════════════════════════════
   BARRA INFERIOR — visible en móvil (iOS + Android)
══════════════════════════════════════════════════════════ */
.sdl-app-nav { display: none; }

@media (max-width: 991.98px) {
  /* Espacio inferior para que el contenido no quede tapado */
  body {
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)) !important;
  }

  .sdl-app-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 99992;
    background: #fff;
    /* Borde sutil arriba */
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 12px rgba(0,0,0,.08);
    /* Altura + safe area para el "home indicator" de iPhone */
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    align-items: stretch;
    justify-content: space-around;
    /* iOS: evitar que el contenido se mueva al hacer scroll */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
}

/* ── Ítems ── */
.sdl-app-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none !important;
  color: #6b7280;
  font-size: .58rem;
  font-weight: 700;
  padding: 4px 2px;
  position: relative;
  /* iOS: desactivar el highlight azul al tocar */
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
  border: none;
  background: none;
  cursor: pointer;
}
.sdl-app-nav__item:hover,
.sdl-app-nav__item--active {
  color: var(--app-accent) !important;
  text-decoration: none !important;
}
/* Línea roja encima del ítem activo */
.sdl-app-nav__item--active::after {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--app-accent);
  border-radius: 0 0 3px 3px;
}

.sdl-app-nav__icon  { font-size: 1.2rem; line-height: 1; }
.sdl-app-nav__label { font-size: .58rem; font-weight: 700; white-space: nowrap; margin-top: 2px; }

/* ── Carrito — ícono plano igual que los demás ítems ── */
.sdl-app-nav__item--cart {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none !important;
  color: #dc2626 !important;
  border: none;
  background: none;
  cursor: pointer;
}
.sdl-app-nav__cart-bubble {
  position: relative;
  width: auto; height: auto;
  background: none;
  border-radius: 0;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #dc2626;
  font-size: 1.2rem;
  transform: none;
  left: auto; bottom: auto;
}
.sdl-app-nav__item--cart .sdl-app-nav__label {
  font-size: .58rem;
  font-weight: 700;
  color: #dc2626;
  margin-top: 0;
  position: static;
  transform: none;
  white-space: nowrap;
}

/* Badge carrito */
.sdl-app-nav__badge {
  position: absolute;
  top: -4px; right: -8px;
  min-width: 15px; height: 15px;
  background: var(--app-accent);
  color: #fff;
  border-radius: 999px;
  font-size: .5rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1.5px solid #fff;
}
.sdl-app-nav__badge[data-count="0"],
.sdl-app-nav__badge:empty { display: none; }

/* ══════════════════════════════════════════════════════════
   HEADER MÓVIL — elementos innecesarios en móvil
══════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  .sdl-topbar { display: none !important; }
  .sdl-pwa    { display: none !important; }  /* Banner instalación — lo maneja pwa.js */
  .site-header-actions > a[href*="productos-y-servicios"] { display: none !important; }
  #wishlist-btn { display: none !important; }
  /* Ocultar megamenu en móvil — incluye el override de product-page */
  .megamenu-bar { display: none !important; }
  body.product-page .megamenu-bar { display: none !important; }
  /* Quitar carrito y cuenta del header en móvil — están en la barra inferior */
  #headerCartDropdown { display: none !important; }
  #headerUserDropdown { display: none !important; }
  .back-to-top {
    bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px)) !important;
    right: 14px !important;
  }
  /* Logo del diente centrado en header móvil */
  .site-header-top {
    justify-content: center !important;
    padding: 10px 0 !important;
  }
  .navbar-brand {
    position: static !important;
    transform: none !important;
    margin: 0 auto !important;
  }
  .site-header-actions {
    display: none !important;
  }
}

/* ══════════════════════════════════════════════════════════
   CATEGORÍAS — panel que sube desde abajo en móvil
══════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  .megamenu-allcats-panel {
    position: fixed !important;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)) !important;
    left: 0 !important; right: 0 !important; top: auto !important;
    width: 100% !important; max-width: 100% !important;
    max-height: 70vh !important;
    border-radius: 20px 20px 0 0 !important;
    box-shadow: 0 -8px 40px rgba(0,0,0,.18) !important;
    padding: 20px 16px 16px !important;
    z-index: 999998 !important;
    overflow-y: auto !important;
  }
  .megamenu-allcats-grid { grid-template-columns: 1fr 1fr !important; }
}

/* ══════════════════════════════════════════════════════════
   STANDALONE iOS — ajustes cuando está instalada como app
══════════════════════════════════════════════════════════ */
@media (display-mode: standalone) {
  /* Fondo negro = mismo color que la barra de estado */
  html { background: #111; }

  body {
    /* Desactivar el rebote de scroll de iOS */
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
  }

  /* Header sticky con espacio para el notch/Dynamic Island */
  header {
    position: sticky !important;
    top: 0 !important;
    z-index: 10000 !important;
    background: #111 !important;
  }

  /* Relleno para la zona del notch usando safe-area-inset-top */
  header::before {
    content: '';
    display: block;
    width: 100%;
    /* env() usa el valor real del notch; 44px es el fallback para iPhone X+ */
    height: env(safe-area-inset-top, 0px);
    min-height: env(safe-area-inset-top, 44px);
    background: #111;
  }

  .site-header,
  .container-fluid.bg-white.site-header {
    background: #fff !important;
    box-shadow: 0 2px 12px rgba(0,0,0,.10) !important;
  }

  .megamenu-bar {
    background: #fff !important;
    border-bottom: 1px solid rgba(0,0,0,.08) !important;
  }

  /* Dropdowns: no quedar tapados por la nav inferior */
  .site-header-actions .dropdown-menu {
    max-height: calc(100dvh - 160px - env(safe-area-inset-bottom, 0px)) !important;
    overflow-y: auto !important;
  }
}

/* iOS específico — garantizar safe-area-inset-top mínimo de 44px */
@supports (-webkit-touch-callout: none) {
  @media (display-mode: standalone) {
    header::before { min-height: max(env(safe-area-inset-top, 0px), 44px); }
  }
}

/* ══════════════════════════════════════════════════════════
   BANNERS PWA — no tapar la nav inferior
══════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  /* El banner de instalación aparece por ENCIMA de la nav */
  .sdl-pwa {
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 99985 !important;
  }
}

/* Preview ?pwa=1 */
.pwa-sim-bar { display: none; }
html.pwa-sim .pwa-sim-bar {
  display: flex; position: fixed;
  top: 50%; right: 0; transform: translateY(-50%);
  z-index: 999999; background: #111; color: #fff;
  writing-mode: vertical-rl; font-size: 9px; font-weight: 800;
  padding: 10px 6px; border-radius: 8px 0 0 8px;
  cursor: pointer; opacity: .7; align-items: center;
}
