/*
 * responsive.css — Tecnoboot Web
 * Fixes para móviles pequeños: iPhone SE (375px), iPhone X/12/13/14 (390px)
 * y dispositivos Android compactos (360px–414px).
 *
 * ¡NUNCA usar padding/margin fijos grandes en móvil!
 * Regla base: todo el contenido debe caber en 360px de ancho como mínimo.
 */

/* ════════════════════════════════════════
   1. RESET GLOBAL MÓVIL
   ════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

@media (max-width: 575.98px) {
    /* Evitar overflow horizontal en cualquier pantalla */
    html, body { overflow-x: hidden; max-width: 100vw; }

    /* Contenedores y paddings globales */
    main, header, footer { padding-left: 12px !important; padding-right: 12px !important; }
    .max-width-1200 { padding-left: 12px; padding-right: 12px; }
    .container, .container-fluid { padding-left: 10px !important; padding-right: 10px !important; }
    .px-4 { padding-left: 10px !important; padding-right: 10px !important; }

    /* Texto base más legible en pantallas pequeñas */
    body { font-size: 14px; }

    /* Home hero: más compacto, centrado y con imagen contenida */
    .hero-grid-wrapper {
        gap: 8px !important;
        padding: 0 !important;
        margin-top: 2px;
        grid-template-columns: 1fr !important;
        justify-items: center !important;
    }
    .hero-carousel-col,
    #heroCarousel {
        border-radius: 12px !important;
        overflow: hidden !important;
        width: min(100%, 420px) !important;
    }
    #heroCarousel .carousel-item img.img-hero-cover {
        width: 100% !important;
        object-fit: cover !important;
        object-position: center center !important;
    }
    .hero-banners-col {
        height: auto !important;
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px !important;
        width: min(100%, 420px) !important;
    }
    .hero-banner-slot {
        min-height: 62px !important;
        border-radius: 10px !important;
    }
    .hero-banner-placeholder {
        font-size: .68rem !important;
    }
    .hero-banner-placeholder i {
        font-size: 1rem !important;
    }
}

/* ════════════════════════════════════════
   2. HEADER / NAVBAR
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Top banner más compacto */
    .top-banner-container { height: 34px; font-size: 0.82rem; padding: 8px 0; }

    /* Logo del header */
    .logo-img { max-width: 130px !important; }
    header.bg-white { padding-top: 10px !important; padding-bottom: 10px !important; }

    /* Buscador ocupa fila completa */
    header .row { row-gap: 8px; }
    .search-input-wrap .form-control { font-size: 0.85rem; height: 40px; }
    .search-btn { height: 40px; padding: 0 14px; }
    .search-clear-btn { height: 40px; }

    /* Iconos móvil del header más espaciados */
    header .action-icon-btn { font-size: 1.4rem; padding: 4px !important; }

    /* Navbar naranja secundaria: links más pequeños */
    .navbar-orange { padding-left: 8px !important; padding-right: 8px !important; }
    .nav-link-custom { font-size: 0.78rem !important; padding: 10px 7px !important; }
}

@media (max-width: 390px) {
    .logo-img { max-width: 110px !important; }
    .nav-link-custom { font-size: 0.73rem !important; padding: 10px 5px !important; }
}

/* ════════════════════════════════════════
   3. HERO / CARRUSEL / BANNERS
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .hero-grid-wrapper { gap: 6px; padding: 0; }
    .hero-banners-col { height: 64px; gap: 4px; }
    .hero-banner-slot { border-radius: 6px; }

    /* Carrusel sin desbordamiento */
    #heroCarousel, .hero-carousel-col {
        border-radius: 8px;
        overflow: hidden;
    }
    #heroCarousel .carousel-item img.img-hero-cover { min-height: 0; }

    /* Indicadores del carrusel más pequeños */
    .carousel-indicators [data-bs-target] { width: 7px; height: 7px; }
}

@media (max-width: 390px) {
    .hero-banners-col { height: 56px; }
}

/* ════════════════════════════════════════
   4. SECCIÓN HOME: CATEGORÍAS Y PRODUCTOS
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Títulos de sección */
    section h2 { font-size: 1.1rem !important; }

    /* Slider de categorías */
    .cat-card { width: 100px; padding: 12px 8px 10px; }
    .cat-card-img, .cat-card-icon { width: 60px; height: 60px; }
    .cat-card-name { font-size: 11px; }
    .cat-card-count { font-size: 10px; }
    .cat-slider-btn { width: 34px; height: 34px; font-size: 13px; }

    /* Grid de productos: 2 columnas */
    #product-list.row { --bs-gutter-x: 10px; --bs-gutter-y: 10px; }
    #product-list .col-6 { padding-left: 5px; padding-right: 5px; }

    /* Tarjeta de producto ajustada */
    .product-card .card-body { padding: 8px 8px 10px !important; }
    .product-card .card-title { font-size: 0.78rem !important; line-height: 1.3; margin-bottom: 4px; }
    .product-card .card-img-top { height: 140px !important; }
    .btn-cart-add-dynamic { height: 34px; font-size: 12px; padding: 6px 10px; }
    .product-card .fw-bold { font-size: 0.88rem !important; }

    /* Botones de acción en tarjeta ocultos en hover — siempre visibles en móvil */
    .product-actions-vertical { opacity: 1 !important; pointer-events: auto !important; }
    .product-actions-vertical .action-btn { width: 28px; height: 28px; font-size: 0.9rem; }
}

@media (max-width: 390px) {
    .cat-card { width: 88px; padding: 10px 6px 8px; }
    .cat-card-img, .cat-card-icon { width: 52px; height: 52px; }
    .product-card .card-img-top { height: 120px !important; }
}

/* ════════════════════════════════════════
   5. CARRITO LATERAL (OFFCANVAS)
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .cart-offcanvas { width: 100vw; right: -100vw; }
    .cart-header { padding: 14px 14px; }
    .cart-header h5 { font-size: 0.92rem; }
    .cart-body { padding: 12px 14px; }
    .cart-footer { padding: 12px 14px; }
    .cart-item-img { width: 52px; height: 52px; }
    .cart-item-name { font-size: 12px; }
    .cart-item-price { font-size: 13px; }
    .cart-subtotal .value { font-size: 15px; }
    .btn-checkout { font-size: 14px; padding: 11px; }
}

/* ════════════════════════════════════════
   6. PÁGINA CARRITO / CHECKOUT
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Vista carrito estándar */
    .cart-page-panel, .cart-page-summary { padding: 14px 12px; border-radius: 14px; }
    .cart-page-item { grid-template-columns: 64px minmax(0,1fr); gap: 10px; padding: 12px; border-radius: 12px; }
    .cart-page-item img { width: 64px; height: 64px; }
    .cart-page-item-info h6 { font-size: 0.85rem; }
    .cart-page-item-controls { grid-column: 1/-1; flex-direction: row; justify-content: space-between; align-items: center; }

    /* Checkout form */
    .checkout-section-card { border-radius: 12px; padding: 14px 12px !important; }
    .checkout-title { font-size: 0.9rem; }
    #cartCheckoutContainer .col-lg-7,
    #cartCheckoutContainer .col-lg-5 { padding-left: 0; padding-right: 0; }

    /* Métodos de pago */
    .payment-option-item { padding: 10px 12px; border-radius: 8px; }
    .payment-option-logo { max-height: 18px; max-width: 52px; }

    /* Botón finalizar */
    button[type="submit"].btn-orange { font-size: 0.95rem; padding: 13px !important; }

    /* Resumen del pedido en checkout */
    .checkout-table th, .checkout-table tbody tr td,
    .checkout-table tfoot tr td { font-size: 0.8rem; }
    .checkout-product-img { width: 36px; height: 36px; }
    .checkout-product-qty-tag { font-size: 0.65rem; }
}

@media (max-width: 390px) {
    .cart-page-item { padding: 10px; }
    .checkout-section-card { padding: 12px 10px !important; }
    #modalProductoDetalle .modal-dialog {
        padding: 5px !important;
    }
    #modalProductoDetalle .modal-content {
        width: min(100%, 300px);
        max-height: calc(100dvh - 10px);
    }
    .detalle-main-img-wrap { height: 148px !important; }
    .detalle-thumb { width: 40px; height: 40px; }
    .detalle-nombre { font-size: 0.92rem !important; }
    .detalle-precio-final { font-size: 0.98rem !important; }
    .detalle-descripcion { font-size: 0.74rem !important; }
    .detalle-btn-agregar { height: 36px; font-size: 0.8rem; }
    .detalle-btn-favorito { width: 36px; height: 36px; }
    .detalle-rel-card { min-width: 128px; max-width: 128px; }
    .detalle-rel-img-wrap { height: 94px; }
}

/* ════════════════════════════════════════
   7. MODAL DETALLE PRODUCTO
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    #modalProductoDetalle .modal-dialog {
        margin: 0 !important;
        max-width: 100vw !important;
        height: 100dvh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px !important;
    }
    #modalProductoDetalle .modal-content {
        border-radius: 18px !important;
        max-height: calc(100dvh - 16px);
        overflow-y: auto;
        width: min(100%, 420px);
    }
    /* Galería */
    .detalle-layout { grid-template-columns: 1fr !important; }
    .detalle-gallery { padding: 12px 12px 8px !important; }
    .detalle-main-img-wrap { height: 170px !important; border-radius: 10px; padding: 10px !important; }
    .detalle-thumb { width: 46px; height: 46px; }
    /* Info */
    .detalle-info { padding: 12px !important; gap: 8px !important; }
    .detalle-nombre { font-size: 0.98rem !important; }
    .detalle-precio-final { font-size: 1.08rem !important; }
    .detalle-descripcion { font-size: 0.78rem !important; line-height: 1.45 !important; }
    .detalle-btn-agregar { height: 38px; font-size: 0.85rem; }
    .detalle-btn-favorito { width: 38px; height: 38px; }
    .detalle-info-extra { grid-template-columns: 1fr !important; gap: 6px; }
    .detalle-info-item { padding: 7px 10px; font-size: 0.75rem; }
    /* Productos relacionados */
    .detalle-relacionados { padding: 10px 10px 14px !important; }
    .detalle-rel-card { min-width: 140px; max-width: 140px; }
    .detalle-rel-img-wrap { height: 100px; }
}

/* ════════════════════════════════════════
   8. MODAL AUTH (LOGIN / REGISTRO)
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .auth-modal-overlay {
        align-items: center !important;
        justify-content: center !important;
        padding: 10px;
    }
    .auth-modal {
        width: min(100%, 360px) !important;
        max-width: min(100vw - 20px, 360px) !important;
        max-height: calc(100dvh - 20px);
        overflow: auto;
        border-radius: 18px !important;
        animation: authModalInMobile .25s cubic-bezier(.4,0,.2,1);
    }
    @keyframes authModalInMobile {
        from { transform: translateY(40px); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }
    .auth-panel { padding: 14px 12px 16px !important; }
    .auth-input-row { grid-template-columns: 1fr !important; }
    .auth-modal-header {
        padding: 16px 14px 12px !important;
        text-align: center !important;
    }
    .auth-brand-wrap { gap: 4px !important; }
    .auth-modal-header h4 { font-size: 0.98rem !important; }
    .auth-modal-header p { font-size: 0.72rem !important; }
    .auth-brand-logo { width: min(92px, 36vw) !important; max-width: 92px !important; }
    .auth-input-group { margin-bottom: 10px !important; }
    .auth-input-group label { font-size: 0.74rem !important; }
    .auth-input-group input { padding: 9px 11px !important; font-size: 0.9rem !important; }
    .auth-tab-btn { padding: 10px 8px !important; font-size: 0.8rem !important; }
    .auth-submit-btn { padding: 10px 12px !important; font-size: 0.9rem !important; }
    .auth-footer-link { font-size: 0.72rem !important; }
}

@media (max-width: 390px) {
    .hero-grid-wrapper {
        gap: 5px !important;
        justify-items: center !important;
    }
    #heroCarousel .carousel-item img.img-hero-cover {
        height: clamp(126px, 42vw, 180px) !important;
    }
    .hero-carousel-col,
    .hero-banners-col {
        width: min(100%, 340px) !important;
    }
    .hero-banners-col {
        gap: 5px !important;
        grid-template-columns: repeat(3, 1fr);
    }
    .hero-banner-slot { min-height: 56px !important; }
    .auth-modal {
        width: min(100%, 320px) !important;
        max-width: calc(100vw - 14px) !important;
        border-radius: 16px !important;
    }
    .auth-modal-header h4 { font-size: 0.94rem !important; }
    .auth-panel { padding: 12px 10px 14px !important; }
}

@media (max-width: 470px) {
    .hero-grid-wrapper {
        gap: 4px !important;
        padding: 0 !important;
    }
    .hero-carousel-col,
    #heroCarousel,
    .hero-banners-col {
        width: min(100%, 330px) !important;
        max-width: 330px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    #heroCarousel .carousel-item img.img-hero-cover {
        object-fit: cover !important;
    }
    .hero-banners-col {
        gap: 4px !important;
        height: auto !important;
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .hero-banner-slot {
        min-height: 52px !important;
    }
    section h2 {
        font-size: 0.98rem !important;
    }
    .auth-modal-overlay {
        padding: 8px !important;
    }
    .auth-modal {
        width: min(92vw, 330px) !important;
        max-width: min(92vw, 330px) !important;
        border-radius: 16px !important;
    }
    .auth-modal-header {
        padding: 14px 12px 10px !important;
    }
    .auth-brand-logo {
        width: min(84px, 34vw) !important;
        max-width: 84px !important;
    }
    .auth-modal-header h4 {
        font-size: 0.92rem !important;
    }
    .auth-modal-header p {
        font-size: 0.68rem !important;
    }
    .auth-panel {
        padding: 12px 10px 14px !important;
    }
    .auth-input-group label {
        font-size: 0.7rem !important;
    }
    .auth-input-group input {
        padding: 8px 10px !important;
        font-size: 0.86rem !important;
    }
    .auth-tab-btn {
        padding: 9px 6px !important;
        font-size: 0.76rem !important;
    }
    .auth-submit-btn {
        padding: 9px 10px !important;
        font-size: 0.86rem !important;
    }
    .auth-footer-link {
        font-size: 0.68rem !important;
    }
}

/* ════════════════════════════════════════
   9. CATÁLOGO (filtros, grid, sidebar)
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Sidebar de filtros en móvil: modal flotante */
    .catalog-sidebar { border-radius: 0 !important; }

    /* Toolbar del catálogo */
    .catalog-toolbar { flex-wrap: wrap; gap: 8px !important; }
    .catalog-toolbar .form-select { font-size: 0.82rem; }

    /* Grid de productos catálogo: 2 columnas ajustadas */
    #catalogProductGrid.row { --bs-gutter-x: 8px; --bs-gutter-y: 10px; }
    #catalogProductGrid .col-6 { padding-left: 4px; padding-right: 4px; }
    .product-card .card-img-top { height: 130px !important; object-fit: contain; }

    /* Botón de filtros */
    .btn-filtros-mobile { font-size: 0.82rem; padding: 8px 14px; }

    /* Breadcrumb catálogo */
    .catalog-breadcrumb { font-size: 0.78rem; padding: 8px 0 4px; }

    /* Paginación */
    .pagination .page-link { padding: 6px 10px; font-size: 0.82rem; }
}

@media (max-width: 390px) {
    #catalogProductGrid .col-6 { padding-left: 3px; padding-right: 3px; }
    .product-card .card-img-top { height: 110px !important; }
    .product-card .card-title { font-size: 0.72rem !important; }
    .product-card .fw-bold { font-size: 0.82rem !important; }
}

/* ════════════════════════════════════════
   10. MI CUENTA
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Tabs de mi cuenta */
    .cuenta-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 6px !important; }
    .cuenta-tab-btn { white-space: nowrap; font-size: 0.8rem; padding: 8px 12px; flex-shrink: 0; }

    /* Cards de mi cuenta */
    .cuenta-card { border-radius: 12px; padding: 14px !important; }
    .cuenta-section-title { font-size: 0.95rem; }

    /* Avatar */
    .cuenta-avatar-wrap { width: 72px; height: 72px; }
    .cuenta-avatar-upload { width: 26px; height: 26px; font-size: 0.7rem; }

    /* Historial de pedidos: cards */
    .historial-pedido-card { padding: 12px !important; border-radius: 10px; }
    .historial-pedido-id { font-size: 0.92rem; }

    /* Formularios de perfil */
    .cuenta-form .form-control { font-size: 0.85rem; }
}

/* ════════════════════════════════════════
   11. PÁGINAS: NOSOTROS, MARCAS, CONTACTO,
       VISITANOS, FAVORITOS, RESEÑAS,
       LIBRO RECLAMACIONES, POLÍTICAS
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Hero nosotros / visitanos */
    .nosotros-hero { height: 200px; }
    .nosotros-hero-content h1 { font-size: 1.5rem !important; }
    .nosotros-hero-content p { font-size: 0.88rem; }
    .visitanos-hero { height: 180px; }
    .visitanos-hero-title { font-size: 1.3rem !important; letter-spacing: 1px; }
    .visitanos-hero-content { padding: 16px 14px !important; }

    /* Cards */
    .nos-card { padding: 20px 16px; border-radius: 12px; }
    .nos-card-icon { width: 52px; height: 52px; font-size: 1.3rem; }
    .nos-card h4 { font-size: 1rem; }
    .nos-card p { font-size: 0.85rem; }
    .nos-about-img-wrap { min-height: 200px; }
    .nos-stat-num { font-size: 1.25rem; }

    /* Grid marcas: 2 col en móvil */
    .nos-marcas-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .marcas-full-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .marca-full-card { padding: 18px 12px 12px; border-radius: 12px; }
    .marca-full-img-wrap { width: 90px; height: 60px; }

    /* Visitanos */
    .visitanos-info-card { padding: 18px !important; border-radius: 12px; }
    .visitanos-card-title { font-size: 1rem; }
    .visitanos-map-wrap { min-height: 220px; }

    /* Contacto */
    .ctc-form-card { padding: 18px !important; border-radius: 14px; }
    .ctc-info-card { padding: 18px !important; border-radius: 14px; }
    .contacto-mapa-wrap iframe { min-height: 220px; }

    /* Políticas y términos: tipografía */
    .politica-content h2, .terminos-content h2 { font-size: 1.05rem; }
    .politica-content p, .terminos-content p { font-size: 0.88rem; }

    /* Reseñas */
    .resena-card { border-radius: 12px; padding: 14px !important; }
    .resena-stars { font-size: 0.9rem; }

    /* Libro de reclamaciones */
    .libro-form-card { border-radius: 12px; padding: 16px !important; }
    .libro-form-card .form-control { font-size: 0.85rem; }
}

@media (max-width: 390px) {
    .nosotros-hero { height: 170px; }
    .nosotros-hero-content h1 { font-size: 1.3rem !important; }
    .visitanos-hero { height: 150px; }
    .visitanos-hero-title { font-size: 1.1rem !important; }
    .nos-marcas-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .marcas-full-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* ════════════════════════════════════════
   12. FOOTER
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .footer-dark { font-size: 0.8rem; }
    .footer-dark h5 { font-size: 0.82rem !important; margin-bottom: 6px !important; }
    .footer-links li a { font-size: 0.78rem; }
    .contact-list li { font-size: 0.78rem; }
    .libro-box { max-width: 100% !important; }
    .footer-dark .row > .col-xl-3, .footer-dark .row > .col-md-6 { margin-bottom: 10px !important; }

    /* Suscripción */
    .subscription-input-group { max-width: 100% !important; }
    .subscription-input-group .form-control { font-size: 0.82rem; }
    .subscription-input-group .btn { font-size: 0.82rem; padding: 6px 12px; }

    /* Redes sociales */
    .social-icons a { font-size: 1.1rem; }

    /* Botón flotante WhatsApp */
    .whatsapp-floating { width: 48px; height: 48px; font-size: 1.5rem; bottom: 18px; right: 14px; }
}

@media (max-width: 390px) {
    .footer-dark { padding-left: 8px !important; padding-right: 8px !important; }
}

/* ════════════════════════════════════════
   13. BUSCADOR DEL HEADER — panel resultados
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* El panel se extiende al 100% del viewport */
    #headerSearchResults {
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        width: 100vw !important;
        max-height: 65dvh !important;
        border-radius: 0 0 14px 14px !important;
        box-shadow: 0 8px 24px rgba(0,0,0,0.18) !important;
        z-index: 1100 !important;
        overflow-y: auto;
    }
    .search-result-item { padding: 8px 12px; gap: 9px; }
    .sr-img-wrap { width: 44px; height: 44px; }
    .sr-nombre { font-size: 0.8rem; }
    .sr-price-new { font-size: 0.85rem; }
    .sr-btn-cart { width: 30px; height: 30px; font-size: 0.9rem; }
}

/* ════════════════════════════════════════
   14. MENÚ LATERAL CATEGORÍAS
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Panel de categorías: ancho adaptado */
    .category-menu-panel.expanded {
        width: min(270px, calc(100vw - 20px)) !important;
    }
    .category-menu-item { padding: 11px 12px; }
    .category-menu-name { font-size: 0.88rem; }
    .category-menu-count { font-size: 0.72rem; }
    .category-menu-icon { width: 34px; height: 34px; font-size: 1.1rem; }
}

/* ════════════════════════════════════════
   15. BOTONES GLOBALES Y BADGES
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Badges de conteo en iconos */
    .badge-count { width: 14px; height: 14px; font-size: 0.58rem; }

    /* Botones de acción */
    .btn { font-size: 0.85rem; }
    .btn-sm { font-size: 0.78rem; padding: 5px 10px; }

    /* Paginación y controles */
    .cat-slider-btn { width: 30px; height: 30px; }
}

/* ════════════════════════════════════════
   16. AGENCIAS DE ENVÍO EN CHECKOUT
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Cards de agencias en checkout */
    .agencia-card { padding: 10px 12px !important; border-radius: 10px !important; }
    .agencia-card .fw-bold { font-size: 0.88rem; }
    .agencia-card .text-muted { font-size: 0.78rem !important; }
    .agencia-card .small { font-size: 0.75rem !important; }
}

/* ════════════════════════════════════════
   17. FIXES ESPECÍFICOS iPHONE (notch, safe-area)
   ════════════════════════════════════════ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    /* Cart offcanvas respeta el notch inferior del iPhone */
    .cart-offcanvas { padding-bottom: env(safe-area-inset-bottom); }
    /* Modales que tocan el borde inferior */
    .auth-modal { padding-bottom: env(safe-area-inset-bottom); }
    #modalProductoDetalle .modal-content { padding-bottom: env(safe-area-inset-bottom); }
    /* Footer flotante de WhatsApp */
    .whatsapp-floating { bottom: calc(18px + env(safe-area-inset-bottom)); }
}

@supports (padding-left: env(safe-area-inset-left)) {
    /* Margen lateral para iPhone en landscape */
    @media (orientation: landscape) and (max-height: 500px) {
        main, header, footer, .navbar-orange {
            padding-left: max(12px, env(safe-area-inset-left)) !important;
            padding-right: max(12px, env(safe-area-inset-right)) !important;
        }
    }
}

/* ════════════════════════════════════════
   18. AJUSTES ESPECÍFICOS 360px (Android compactos)
   ════════════════════════════════════════ */
@media (max-width: 360px) {
    main, header, footer { padding-left: 8px !important; padding-right: 8px !important; }
    .container, .container-fluid { padding-left: 6px !important; padding-right: 6px !important; }
    .cat-card { width: 80px; padding: 8px 4px; }
    .cat-card-img, .cat-card-icon { width: 48px; height: 48px; }
    .cat-card-name { font-size: 10px; }
    .logo-img { max-width: 100px !important; }
    .nav-link-custom { font-size: 0.7rem !important; padding: 9px 4px !important; }
    .product-card .card-img-top { height: 100px !important; }
    .product-card .card-title { font-size: 0.7rem !important; }
    .product-card .fw-bold { font-size: 0.78rem !important; }
    #catalogProductGrid .col-6, #product-list .col-6 { padding-left: 3px; padding-right: 3px; }
    .checkout-section-card { padding: 10px 8px !important; }
    .cart-page-item { padding: 8px; gap: 8px; }
    .cart-page-item img { width: 56px; height: 56px; }
}

/* ════════════════════════════════════════
   19. FIXES ADICIONALES PARA TABLETS
       (768px — iPad mini portrait)
   ════════════════════════════════════════ */
@media (min-width: 576px) and (max-width: 767.98px) {
    main, header, footer { padding-left: 16px !important; padding-right: 16px !important; }
    .hero-banners-col { height: 80px; }
    .cart-page-grid { grid-template-columns: 1fr; }
    .cart-page-summary { position: static; }
    .marcas-full-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
    .nos-marcas-grid { grid-template-columns: repeat(3, 1fr); }
    section h2 { font-size: 1.2rem !important; }
}

/* ════════════════════════════════════════
   20. NAVBAR SECUNDARIA (VISIBLE EN MÓVIL)
      Scrollable horizontal, botón menu fijo
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .navbar-secondary {
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        flex-wrap: nowrap !important;
    }
    .navbar-secondary::-webkit-scrollbar { display: none; }
    .navbar-secondary > div {
        flex-wrap: nowrap !important;
        gap: 8px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 4px !important;
    }
    .navbar-secondary > div::-webkit-scrollbar { display: none; }
    .navbar-mobile-links {
        flex-wrap: nowrap !important;
        white-space: nowrap;
        flex: 1 1 auto;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0 !important;
        padding-bottom: 2px !important;
    }
    .navbar-mobile-links::-webkit-scrollbar { display: none; }
    .navbar-mobile-links .nav-item {
        flex: 0 0 auto;
        min-width: unset;
    }
    .navbar-secondary .menu-toggle-btn {
        flex-shrink: 0;
    }

    /* Animación logo: rotación + rebote */
    .logo-bounce-rotate {
        animation: logoBounceRotate 0.7s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
    }
    @keyframes logoBounceRotate {
        0%   { transform: rotate(0deg)   scale(1);    opacity: 0.5; }
        30%  { transform: rotate(-25deg) scale(1.15);  opacity: 1;   }
        55%  { transform: rotate(12deg)  scale(0.92); }
        75%  { transform: rotate(-6deg)  scale(1.04); }
        90%  { transform: rotate(2deg)   scale(0.98); }
        100% { transform: rotate(0deg)   scale(1);    opacity: 1;   }
    }
}

/* ════════════════════════════════════════
   21. PÁGINAS POLÍTICAS / TÉRMINOS
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Cards de contenido */
    .bg-white.rounded.shadow-sm.p-4 { padding: 16px !important; }
    .bg-white.rounded.shadow-sm.p-5 { padding: 18px !important; }
    .card-body.p-4 { padding: 14px !important; }
    .card-body.p-5 { padding: 16px !important; }

    /* Títulos de políticas */
    h1.fw-bold { font-size: 1.4rem !important; }
    .content-text p { font-size: 0.88rem; line-height: 1.65; }
    .content-text h2 { font-size: 1.05rem !important; }
    .content-text h3 { font-size: 0.95rem !important; }
    .content-text ul, .content-text ol { padding-left: 18px; }
    .content-text li { font-size: 0.88rem; }

    /* Libro de reclamaciones */
    .card.shadow-sm .card-body { padding: 14px !important; }
    #reclamacionesForm .form-control { font-size: 16px !important; }
    #reclamacionesForm .form-label { font-size: 0.82rem; }
}

/* ════════════════════════════════════════
   22. RESEÑAS
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .resenas-list { padding: 0; }
    /* Cards de reseña generadas por JS */
    .resena-item, [class*="resena-card"] {
        padding: 14px !important;
        border-radius: 12px !important;
        margin-bottom: 12px;
    }
    .star-rating { font-size: 1.1rem; gap: 2px !important; }
    #modalResena .modal-dialog { margin: 0 8px; }
    #modalResena .modal-body { padding: 14px !important; }
    #modalResena .modal-body .form-control { font-size: 16px !important; }
}

/* ════════════════════════════════════════
   23. FAVORITOS — GRID
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    #favGrid.row { --bs-gutter-x: 8px; --bs-gutter-y: 8px; }
    /* Las tarjetas de favoritos usan el mismo .product-card — ya cubierto arriba */
    #favGrid .col-6 { padding-left: 4px; padding-right: 4px; }
    /* Estado vacío / no login */
    #favNoLogin, #favEmpty {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }
    #favNoLogin i, #favEmpty i { font-size: 2.8rem !important; }
}

/* ════════════════════════════════════════
   24. SECCIÓN HERO HOME — padding vertical
   ════════════════════════════════════════ */
@media (max-width: 575.98px) {
    /* Reducir my-4 en la sección hero */
    section.my-4 { margin-top: 10px !important; margin-bottom: 10px !important; }

    /* Sección de categorías */
    .py-5 { padding-top: 24px !important; padding-bottom: 24px !important; }

    /* Títulos de sección home */
    .d-flex.justify-content-between h2 { font-size: 1.05rem !important; }
    .d-flex.justify-content-between a  { font-size: 0.82rem !important; }
}

@media (max-width: 390px) {
    .py-5 { padding-top: 18px !important; padding-bottom: 18px !important; }
    section.my-4 { margin-top: 8px !important; margin-bottom: 8px !important; }
}

@media (max-width: 390px) {
    .hero-grid-wrapper {
        gap: 3px !important;
    }
    .hero-carousel-col,
    #heroCarousel,
    .hero-banners-col {
        width: min(100%, 300px) !important;
        max-width: 300px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    #heroCarousel .carousel-item img.img-hero-cover {
        height: clamp(108px, 35vw, 145px) !important;
    }
    .hero-banners-col {
        gap: 3px !important;
    }
    .hero-banner-slot {
        min-height: 48px !important;
    }
    section h2 {
        font-size: 0.9rem !important;
    }
    .auth-modal-overlay {
        padding: 6px !important;
    }
    .auth-modal {
        width: min(90vw, 300px) !important;
        max-width: min(90vw, 300px) !important;
    }
    .auth-modal-header {
        padding: 12px 10px 8px !important;
    }
    .auth-brand-logo {
        width: min(76px, 32vw) !important;
        max-width: 76px !important;
    }
    .auth-modal-header h4 {
        font-size: 0.88rem !important;
    }
    .auth-modal-header p {
        font-size: 0.64rem !important;
    }
    .auth-panel {
        padding: 10px 9px 12px !important;
    }
    .auth-input-group {
        margin-bottom: 8px !important;
    }
    .auth-input-group label {
        font-size: 0.68rem !important;
    }
    .auth-input-group input {
        padding: 7px 9px !important;
        font-size: 0.84rem !important;
    }
    .auth-tab-btn {
        padding: 8px 5px !important;
        font-size: 0.72rem !important;
    }
    .auth-submit-btn {
        padding: 8px 10px !important;
        font-size: 0.84rem !important;
    }
    .auth-footer-link {
        font-size: 0.64rem !important;
    }
}

@media (max-width: 575.98px) {
    .hero-grid-wrapper {
        grid-template-columns: 1fr !important;
        justify-items: center !important;
    }
    .hero-carousel-col,
    #heroCarousel,
    .hero-banners-col {
        width: min(100%, 360px) !important;
        max-width: 360px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    .hero-banners-col {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        gap: 5px !important;
    }
    .hero-banner-slot {
        width: 100% !important;
        flex: none !important;
        min-height: 64px !important;
        height: clamp(64px, 18vw, 84px) !important;
    }
}

@media (max-width: 470px) {
    .hero-carousel-col,
    #heroCarousel,
    .hero-banners-col {
        width: min(100%, 330px) !important;
        max-width: 330px !important;
    }
    .hero-banner-slot {
        min-height: 58px !important;
        height: clamp(58px, 16vw, 74px) !important;
    }
}

@media (max-width: 390px) {
    .hero-carousel-col,
    #heroCarousel,
    .hero-banners-col {
        width: min(100%, 300px) !important;
        max-width: 300px !important;
    }
    .hero-banner-slot {
        min-height: 52px !important;
        height: clamp(52px, 15vw, 66px) !important;
    }
}

/* ════════════════════════════════════════
   25. SPLASH MODAL (icono-logo.png)
   ════════════════════════════════════════ */
.splash-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #ffffffe0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.09s ease-out;
}
.splash-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.splash-content {
    transform: scale(0.7);
    opacity: 0;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease-out;
}
.splash-overlay.active .splash-content {
    transform: scale(1);
    opacity: 1;
}
.splash-logo-img {
    width: min(70vw, 250px);
    height: auto;
    display: block;
    object-fit: contain;
}
