/*
 * boyaca-mobile.css
 * Mejoras de UX/CRO para dispositivos móviles + fixes de Core Web Vitals.
 * Se carga después de los estilos base para tener mayor prioridad.
 */

/* ============================================================
   0. ANTI-CLS (Cumulative Layout Shift) — reservar espacio
      para imágenes y carruseles ANTES de que carguen.
      Evita que el layout salte, mejora CLS de 0.79 → <0.1
   ============================================================ */

/* Hero banner — reservar espacio proporcional antes de cargar imágenes */
.home-hero-fullwidth .carousel-inner {
    min-height: 170px; /* mobile */
    background: #f0f0f0;
}
@media (min-width: 600px) {
    .home-hero-fullwidth .carousel-inner {
        min-height: 280px;
    }
}
@media (min-width: 768px) {
    .home-hero-fullwidth .carousel-inner {
        min-height: 380px;
    }
}
@media (min-width: 1200px) {
    .home-hero-fullwidth .carousel-inner {
        min-height: 450px;
    }
}

/* Imágenes del banner: nunca colapsar a 0 antes de cargar */
.home-hero-fullwidth .carousel-inner .item img,
.home-hero-fullwidth .carousel-inner .item a img {
    width: 100%;
    height: auto;
    display: block;
    min-height: 170px;
    object-fit: cover;
    background: #f0f0f0;
}

/* Colección items — NO tocar su aspect-ratio: ya tienen CSS propio
   con max-height:320px y hover. Solo fondo placeholder para suavizar CLS. */
.coleccion-img-wrap {
    background: #f5f5f5;
}

/* Imágenes de producto en carruseles — reservar 300x300 */
.owl-item .fam_imgGal,
.owl-item .thumbnail img,
.owl-item img.fam_imgGal {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #fafafa;
    display: block;
}

/* Carruseles owl — altura mínima para evitar colapso antes de inicializar.
   Excluye colecciones, que tienen su propia estructura. */
.owl-carousel:not(.owl-loaded):not(.colecciones-carousel) {
    min-height: 240px;
}

/* ============================================================
   1. BOTONES TÁCTILES — mínimo 44×44 px (Apple/Google HIG)
   ============================================================ */
@media (max-width: 767px) {

  /* Botón principal "Añadir al Carrito" en carruseles de home */
  .btn_add_car_det,
  .btn_add_det {
    min-height: 48px !important;
    height: auto !important;
    padding: 12px 16px !important;
    font-size: 13px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
  }

  /* Botón "Añadir al Carrito" en página de detalle */
  .btn_add_car,
  #boton_compra .btn,
  #btn_comprar,
  .btn-comprar,
  .anadirCarritoIndex_2 > .btn,
  .anadirCarritoCookiesIndex_2 > .btn {
    min-height: 52px !important;
    height: auto !important;
    padding: 14px 20px !important;
    font-size: 15px !important;
    width: 100% !important;
    border-radius: 8px !important;
  }

  /* Todos los .btn en mobile — mínimo táctil */
  .btn {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* ============================================================
     2. BARRA DE CATEGORÍAS SUPERIOR (links de 19px → 44px)
     ============================================================ */
  .categorias_mobile a,
  .combomobil_product a,
  .nav-logobar a {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  /* Quick links horizontales */
  .menu_rapido a,
  [class*="top-links"] a,
  .navbar-fixed-top .nav > li > a {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }

  /* ============================================================
     3. BÚSQUEDA — más alta y fácil de tocar
     ============================================================ */
  input[type="search"],
  input[type="text"].search-input,
  #search_box,
  .search-field,
  [class*="search"] input[type="text"] {
    min-height: 48px !important;
    font-size: 16px !important;
    padding: 10px 14px !important;
    border-radius: 6px !important;
  }

  #btn_search,
  .btn-search,
  [class*="search"] button,
  [class*="search"] input[type="submit"] {
    min-height: 48px !important;
    min-width: 48px !important;
  }

  /* ============================================================
     4. INPUTS — evitar zoom automático en iOS (font-size < 16px)
     ============================================================ */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px;
  }

  /* ============================================================
     5. PRECIOS — legibles sin hacer zoom
     ============================================================ */
  .cl_precios {
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
  }

  .rl_precios {
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  /* ============================================================
     6. MENÚ HAMBURGUESA — área táctil más amplia
     ============================================================ */
  #mostrarmenu,
  .nav-left {
    min-width: 56px !important;
    min-height: 56px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ============================================================
     7. FOOTER MÓVIL — acordeones táctiles
     ============================================================ */
  #foot_id_2 [data-toggle="collapse"],
  #foot_id_2 .accordion-toggle,
  #foot_id_2 [class*="fondoAcordion"] {
    min-height: 52px !important;
    display: flex !important;
    align-items: center !important;
    padding: 14px 16px !important;
    font-size: 14px !important;
  }

  /* ============================================================
     8. ESPACIADO GENERAL
     ============================================================ */
  .cuadro_prod {
    padding-bottom: 16px;
  }
  .cuadro_prod + .cuadro_prod {
    margin-top: 12px;
  }

  /* ============================================================
     9. MODAL / POPUP — no salirse de pantalla
     ============================================================ */
  .modal-dialog {
    margin: 10px auto !important;
    max-width: calc(100% - 20px) !important;
  }
  .modal-content {
    border-radius: 10px !important;
  }

  /* ============================================================
     10. BREADCRUMB
     ============================================================ */
  .breadcrumb {
    flex-wrap: wrap;
    font-size: 12px;
    padding: 6px 12px;
  }

  /* ============================================================
     11. Anti-CLS específico mobile
     ============================================================ */
  .home-hero-fullwidth .carousel-inner {
    min-height: 180px;
  }
  .home-hero-fullwidth .carousel-inner .item img {
    min-height: 180px;
  }
}

/* ============================================================
   Pantallas muy pequeñas (< 400px)
   ============================================================ */
@media (max-width: 400px) {
  .cl_precios {
    font-size: 16px !important;
  }
  .btn_add_car_det,
  .btn_add_det {
    font-size: 12px !important;
    padding: 12px 10px !important;
  }
  .title_cuadro_prod {
    font-size: 18px !important;
  }
}


  /* Botón principal "Añadir al Carrito" en carruseles de home */
  .btn_add_car_det,
  .btn_add_det {
    min-height: 48px !important;
    height: auto !important;
    padding: 12px 16px !important;
    font-size: 13px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
  }

  /* Botón "Añadir al Carrito" en página de detalle de producto */
  .btn_add_car,
  #boton_compra .btn,
  #btn_comprar,
  .btn-comprar,
  .anadirCarritoIndex_2 > .btn,
  .anadirCarritoCookiesIndex_2 > .btn {
    min-height: 52px !important;
    height: auto !important;
    padding: 14px 20px !important;
    font-size: 15px !important;
    width: 100% !important;
    border-radius: 8px !important;
  }

  /* Todos los botones .btn en mobile — mínimo táctil */
  .btn {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* ============================================================
     2. BARRA DE CATEGORÍAS SUPERIOR (links de 19px → 44px)
     ============================================================ */
  .categorias_mobile a,
  .combomobil_product a,
  .nav-logobar a {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  /* Quick links horizontales (Comprar por Whatsapp, Christmas Place…) */
  .menu_rapido a,
  [class*="top-links"] a,
  .navbar-fixed-top .nav > li > a {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }

  /* ============================================================
     3. BÚSQUEDA — más alta y fácil de tocar
     ============================================================ */
  input[type="search"],
  input[type="text"].search-input,
  #search_box,
  .search-field,
  [class*="search"] input[type="text"] {
    min-height: 48px !important;
    font-size: 16px !important; /* evita zoom automático en iOS */
    padding: 10px 14px !important;
    border-radius: 6px !important;
  }

  /* Botón buscar contiguo a input */
  #btn_search,
  .btn-search,
  [class*="search"] button,
  [class*="search"] input[type="submit"] {
    min-height: 48px !important;
    min-width: 48px !important;
  }

  /* ============================================================
     4. INPUTS EN FORMULARIOS — evitar zoom automático en iOS
     ============================================================ */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;  /* iOS hace zoom si < 16px */
    min-height: 44px;
  }

  /* ============================================================
     5. PRECIOS — legibles sin hacer zoom
     ============================================================ */
  .cl_precios {
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
  }

  .rl_precios {
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  /* ============================================================
     6. CARRUSEL DE PRODUCTOS — cards completas
     ============================================================ */
  .owl-carousel .owl-item {
    /* Evita que los items se vean cortados en pantallas pequeñas */
    -webkit-tap-highlight-color: transparent;
  }

  /* Zona de imagen de producto en carrusel — altura consistente.
     Se excluyen las colecciones (.coleccion-item), que tienen su propio
     diseño con object-fit:cover y max-height:320px. */
  .cuadro_prod .item:not(.coleccion-item) img:first-of-type,
  .owl-item .item:not(.coleccion-item) img:first-of-type {
    width: 100% !important;
    object-fit: contain !important;
    max-height: 200px !important;
  }

  /* ============================================================
     7. MENÚ HAMBURGUESA — área de toque más amplia
     ============================================================ */
  #mostrarmenu,
  .nav-left {
    min-width: 56px !important;
    min-height: 56px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ============================================================
     8. FOOTER MÓVIL — acordeones táctiles
     ============================================================ */
  #foot_id_2 [data-toggle="collapse"],
  #foot_id_2 .accordion-toggle,
  #foot_id_2 [class*="fondoAcordion"] {
    min-height: 52px !important;
    display: flex !important;
    align-items: center !important;
    padding: 14px 16px !important;
    font-size: 14px !important;
  }

  /* ============================================================
     9. ESPACIADO GENERAL — evitar clicks accidentales
     ============================================================ */
  .cuadro_prod {
    padding-bottom: 16px;
  }

  /* Separación entre carruseles */
  .cuadro_prod + .cuadro_prod {
    margin-top: 12px;
  }

  /* ============================================================
     10. BOTÓN FLOTANTE WHATSAPP / CHAT
     ============================================================ */
  #whatsapp-btn,
  .whatsapp-float,
  [id*="whatsapp"],
  [class*="whatsapp-float"] {
    bottom: 80px !important; /* Por encima del thumb en pantalla completa */
  }

  /* ============================================================
     11. MODAL / POPUP — no salirse de pantalla
     ============================================================ */
  .modal-dialog {
    margin: 10px auto !important;
    max-width: calc(100% - 20px) !important;
  }

  .modal-content {
    border-radius: 10px !important;
  }

  /* ============================================================
     12. BREADCRUMB — no cortar en mobile
     ============================================================ */
  .breadcrumb {
    flex-wrap: wrap;
    font-size: 12px;
    padding: 6px 12px;
  }
}

/* ============================================================
   Mejora adicional para pantallas muy pequeñas (< 400px)
   ============================================================ */
@media (max-width: 400px) {
  .cl_precios {
    font-size: 16px !important;
  }

  .btn_add_car_det,
  .btn_add_det {
    font-size: 12px !important;
    padding: 12px 10px !important;
  }

  /* Título de sección más compacto */
  .title_cuadro_prod {
    font-size: 18px !important;
  }
}
