/* app-mobile.css — SOLO home (body.page-index) y SOLO móvil (<=768px).
   No toca escritorio ni el resto del sitio. Ver APP_MOVIL_PLAN.md. */
@media (max-width: 768px) {

  /* Mientras carga (antes de extraer los datos reales) ocultar solo
     visualmente para no romper el lazy-load del page-builder */
  body.page-index:not(.app-mobile-ready) #header,
  body.page-index:not(.app-mobile-ready) .header-nav,
  body.page-index:not(.app-mobile-ready) #content.page-home > .ApRow {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  /* Una vez extraídos los datos reales, quitar el contenido viejo del todo
     (display:none) para que deje de descargar imágenes/recursos de fondo */
  body.page-index.app-mobile-ready #header,
  body.page-index.app-mobile-ready .header-nav,
  body.page-index.app-mobile-ready #content.page-home > .ApRow {
    display: none !important;
  }

  /* El footer real NO se oculta con display:none: el widget del chat
     (panteraai) vive dentro de él en el DOM, y display:none en un
     ancestro apaga también sus descendientes con position:fixed. Se
     oculta solo visualmente (el footer es ligero, sin el problema de
     rendimiento de los carruseles de #content) — position:fixed SÍ
     escapa de un overflow:hidden sin transform en el ancestro. */
  #footer.footer-container {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  body.page-index.app-mobile-ready {
    padding-top: 56px;
    padding-bottom: 64px;
  }

  /* ---------- Cabecera compacta ---------- */
  #app-mobile-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 12px;
    background: linear-gradient(135deg, #0a1a33 0%, #0f2a52 55%, #163a6b 100%);
    box-shadow: 0 2px 10px rgba(10,26,51,.35);
  }
  #app-mobile-header .amh-logo { display: flex; align-items: center; height: 34px; }
  #app-mobile-header .amh-logo img { height: 34px; width: auto; }
  #app-mobile-header .amh-spacer { flex: 1; }
  #app-mobile-header .amh-icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,.12); color: #fff;
    border: 0; position: relative; font-size: 18px;
  }
  #app-mobile-header .amh-badge {
    position: absolute; top: -2px; right: -2px;
    min-width: 16px; height: 16px; padding: 0 3px;
    border-radius: 8px; background: #ff5a3c; color: #fff;
    font-size: 10px; line-height: 16px; text-align: center; font-weight: 700;
  }
  #app-mobile-header .amh-badge.is-empty { display: none; }

  /* buscador desplegable real (mueve el widget original, no lo duplica) */
  #app-mobile-search-panel {
    position: fixed; top: 56px; left: 0; right: 0; z-index: 1190;
    background: #fff; padding: 10px 12px;
    box-shadow: 0 6px 10px rgba(0,0,0,.12);
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: transform .15s ease, opacity .15s ease;
  }
  #app-mobile-search-panel.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  #app-mobile-search-panel #leo_search_block_top { width: 100%; }

  /* ---------- Hero + ofertas ---------- */
  #app-mobile-shell { padding: 12px; }
  .amh-banner { display: block; border-radius: 14px; overflow: hidden; margin-bottom: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
  .amh-banner img { display: block; width: 100%; height: auto; }
  .amh-banner--hero {
    border-radius: 0; box-shadow: none;
    width: 100vw; margin-left: calc(50% - 50vw); margin-top: -12px; margin-bottom: 16px;
  }

  /* ---------- Franja de garantías ---------- */
  .amh-guarantees {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
    margin-bottom: 16px;
  }
  .amh-guarantees .amh-g-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 10px; text-align: center; color: #0f3f66; font-weight: 600;
  }
  .amh-guarantees .amh-g-item .amh-g-icon { font-size: 18px; }

  /* ---------- Categorías ---------- */
  .amh-section-title { font-size: 15px; font-weight: 700; color: #0f3f66; margin: 0 0 10px; }
  .amh-categories { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 8px; margin-bottom: 20px; }
  .amh-cat-card {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-decoration: none;
  }
  .amh-cat-card .amh-cat-thumb {
    width: 72px; height: 72px; border-radius: 16px; background: #f1f5f9;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
  }
  .amh-cat-card .amh-cat-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .amh-cat-card .amh-cat-name { font-size: 11px; text-align: center; color: #16324a; font-weight: 600; line-height: 1.2; }

  /* ---------- Pestañas de productos ---------- */
  .amh-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
  .amh-tabs .amh-tab {
    flex: 1; padding: 9px 0; border-radius: 999px; border: 1px solid #e2e8f0;
    background: #fff; color: #7c93a8; font-size: 12px; font-weight: 700;
  }
  .amh-tabs .amh-tab.is-active {
    background: linear-gradient(135deg, #0f2a52 0%, #163a6b 100%);
    color: #fff; border-color: transparent;
    box-shadow: 0 2px 8px rgba(15,42,82,.25);
  }

  /* ---------- Grid de productos ---------- */
  .amh-products { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
  .amh-product-card {
    background: #fff; border: 1px solid #eef1f4; border-radius: 14px; padding: 8px;
    display: flex; flex-direction: column; text-decoration: none; color: inherit;
    position: relative;
  }
  .amh-product-card .amh-p-thumb { width: 100%; aspect-ratio: 1/1; border-radius: 10px; overflow: hidden; background: #f7f9fb; margin-bottom: 8px; }
  .amh-product-card .amh-p-thumb img { width: 100%; height: 100%; object-fit: contain; }
  .amh-product-card .amh-p-name { font-size: 12px; color: #16324a; line-height: 1.3; min-height: 31px; margin-bottom: 4px; }
  .amh-product-card .amh-p-price { font-size: 14px; font-weight: 700; color: #0f3f66; }
  .amh-product-card .amh-p-price .amh-p-old { font-size: 11px; color: #94a3b8; text-decoration: line-through; font-weight: 500; margin-right: 4px; }
  .amh-fav-btn {
    position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,.9); border: 0; display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #cbd5e1;
  }
  .amh-fav-btn.is-fav { color: #ff5a3c; }

  /* El tamaño/posición del botón del chat ahora se controla globalmente
     desde footer.tpl (todas las páginas) — ver footer.tpl. */
  /* Ocultar el acceso directo de WhatsApp del propio widget de chat en esta versión móvil */
  body.page-index.app-mobile-ready .panteraai-grip__card--wa,
  body.page-index.app-mobile-ready a[href*="wa.me"],
  body.page-index.app-mobile-ready a[href*="api.whatsapp.com"],
  body.page-index.app-mobile-ready a[href^="whatsapp://"] {
    display: none !important;
  }

  /* ---------- Barra inferior ---------- */
  #app-mobile-bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200;
    display: flex; background: #fff; border-top: 1px solid #eef1f4;
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  }
  #app-mobile-bottomnav .amb-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 8px 0 6px; color: #7c93a8; text-decoration: none; font-size: 10px; font-weight: 600;
    border: 0; background: none; position: relative;
  }
  #app-mobile-bottomnav .amb-item.is-active { color: #0f3f66; }
  #app-mobile-bottomnav .amb-icon { font-size: 19px; line-height: 1; }
  #app-mobile-bottomnav .amb-badge {
    position: absolute; top: 2px; right: calc(50% - 20px);
    min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
    background: #ff5a3c; color: #fff; font-size: 9px; line-height: 15px; text-align: center; font-weight: 700;
  }
  #app-mobile-bottomnav .amb-badge.is-empty { display: none; }

  /* ---------- Footer minimal ---------- */
  .amh-footer-minimal {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 18px 0 12px; margin-top: 4px; border-top: 1px solid #eef1f4;
  }
  .amh-footer-minimal img { height: 20px; width: auto; opacity: .85; }
  .amh-footer-minimal .amh-footer-links {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px;
  }
  .amh-footer-minimal a {
    font-size: 10px; color: #9aa8b5; text-decoration: none;
  }
  .amh-footer-minimal .amh-footer-copy { font-size: 9px; color: #c2cbd3; }

  /* ---------- Drawer de favoritos (localStorage) ---------- */
  #app-mobile-fav-drawer {
    position: fixed; inset: 0; z-index: 1300; background: rgba(15,25,35,.4);
    display: none;
  }
  #app-mobile-fav-drawer.is-open { display: block; }
  #app-mobile-fav-drawer .amfd-panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 70vh; overflow-y: auto;
    background: #fff; border-radius: 16px 16px 0 0; padding: 16px;
  }
  #app-mobile-fav-drawer .amfd-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  #app-mobile-fav-drawer .amfd-close { border: 0; background: #f1f5f9; width: 30px; height: 30px; border-radius: 50%; font-size: 16px; }
  #app-mobile-fav-drawer .amfd-empty { color: #7c93a8; font-size: 13px; text-align: center; padding: 24px 0; }
  #app-mobile-fav-drawer .amfd-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f5f9; text-decoration: none; color: inherit; }
  #app-mobile-fav-drawer .amfd-item img { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: #f7f9fb; }
  #app-mobile-fav-drawer .amfd-item .amfd-name { font-size: 12px; flex: 1; }
}

/* Fuera de móvil o fuera de home: nada de esto debe existir/mostrarse */
@media (min-width: 769px) {
  #app-mobile-header, #app-mobile-bottomnav, #app-mobile-shell, #app-mobile-search-panel, #app-mobile-fav-drawer {
    display: none !important;
  }
}
body:not(.page-index) #app-mobile-header,
body:not(.page-index) #app-mobile-bottomnav,
body:not(.page-index) #app-mobile-shell {
  display: none !important;
}
