/**
 * Correcciones responsive — Página de inicio (index.php)
 * Cargar al final para unificar hero, carruseles y evitar overflow horizontal.
 */

/* Inicio: sin hueco entre menú y slider — el banner sube hasta el borde del nav */
body.navbar-fix.index-page {
    padding-top: 0 !important;
}

body.navbar-fix.index-page .hero-carousel-section {
    margin: 0 !important;
    padding: 0 !important;
    background: #0a0a0a;
}

body.navbar-fix.index-page .hero-carousel-container {
    margin-top: 0 !important;
    border-radius: 0 !important;
}

body.navbar-fix.index-page .hero-carousel,
body.navbar-fix.index-page .slide-banner,
body.navbar-fix.index-page .banner-image {
    border-radius: 0 !important;
}

main#main-content {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
}

/* Tablet */
@media screen and (max-width: 1024px) {
    .featured-products-header {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.5rem 1rem;
    }

    .featured-products-vermas {
        font-size: 0.875rem;
    }
}

/* Móvil */
@media screen and (max-width: 768px) {
    main#main-content {
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    }

    /* Hero: altura fluida, sin desborde */
    .hero-carousel-container,
    .hero-carousel,
    .hero-slide,
    .slide-banner,
    .banner-image {
        height: clamp(220px, 44vw, 380px) !important;
        min-height: 220px;
        max-height: 380px;
        border-radius: 0 !important;
    }

    .banner-image {
        object-fit: cover;
        width: 100%;
    }

    /* Ocultar flechas del hero (scroll táctil / swipe en JS) */
    .hero-carousel-section .carousel-nav-btn {
        display: none !important;
    }

    .carousel-indicators {
        bottom: 12px !important;
    }

    /* Mensajes flotantes bajo el nav móvil */
    .logout-success-message,
    .error-message {
        top: max(84px, calc(env(safe-area-inset-top, 0px) + 76px)) !important;
        left: 0.75rem !important;
        right: 0.75rem !important;
        width: auto !important;
        max-width: none !important;
        transform: none !important;
        padding: 12px 14px !important;
    }

    .logout-success-message .message-content,
    .error-message .message-content {
        font-size: 0.8125rem;
        line-height: 1.4;
        align-items: flex-start;
    }

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

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

    .logout-success-message.hide,
    .error-message.hide {
        animation: slideOutUp 0.4s ease forwards;
    }

    /* Categorías: cards que caben en pantalla */
    .categories-simple-grid {
        padding: 0 12px 16px !important;
        margin: 0 -12px !important;
        gap: 12px !important;
    }

    .simple-category-card {
        width: min(300px, calc(100vw - 2.5rem)) !important;
        height: auto !important;
        min-height: 260px !important;
    }

    .simple-category-image {
        width: 100% !important;
        height: min(200px, 48vw) !important;
        max-height: 220px;
    }

    .simple-category-name,
    .simple-category-title {
        font-size: 1.15rem !important;
        padding: 12px !important;
    }

    /* Productos destacados / catálogo en inicio */
    .featured-products-section {
        padding: 32px 0 40px;
    }

    .featured-products-wrap {
        padding: 0 10px;
    }

    .featured-products-carousel-outer {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        gap: 0;
    }

    .featured-products-carousel-inner {
        width: 100%;
    }

    .featured-products-section .featured-products-grid {
        padding: 8px 4px 20px;
        gap: 14px;
        scroll-padding-inline: 10px;
        min-height: 0;
    }

    .featured-products-section .featured-products-grid .featured-product-card,
    .featured-products-section .featured-products-grid .product-card {
        flex: 0 0 min(272px, calc(100vw - 2.5rem)) !important;
        min-width: min(272px, calc(100vw - 2.5rem)) !important;
        scroll-snap-align: center;
    }

    .featured-products-title {
        font-size: 1.2rem;
        line-height: 1.3;
        word-break: break-word;
    }

    /* Carrusel de productos: solo scroll horizontal en móvil */
    .featured-carousel-prev,
    .featured-carousel-next {
        display: none !important;
    }

    .featured-product-body {
        padding: 12px;
    }

    .featured-product-actions {
        flex-wrap: wrap;
    }

    .featured-add-cart {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
        text-align: center;
    }
}

@media screen and (max-width: 480px) {
    .hero-carousel-container,
    .hero-carousel,
    .hero-slide,
    .slide-banner,
    .banner-image {
        height: clamp(200px, 40vw, 280px) !important;
        min-height: 200px;
        max-height: 280px;
    }

    .section-title {
        font-size: 1.35rem !important;
    }

    .section-subtitle {
        font-size: 0.9rem !important;
        margin-bottom: 1.25rem !important;
    }

    .simple-category-card {
        width: calc(100vw - 2rem) !important;
        min-height: 240px !important;
    }

    .featured-products-section .featured-products-grid .featured-product-card,
    .featured-products-section .featured-products-grid .product-card {
        flex: 0 0 min(252px, calc(100vw - 2rem)) !important;
        min-width: min(252px, calc(100vw - 2rem)) !important;
    }

    .featured-products-section .featured-products-grid:not(.catalog-cards-ofertas) .featured-product-card,
    .featured-products-section .featured-products-grid:not(.catalog-cards-ofertas) .product-card {
        height: auto !important;
        min-height: 380px !important;
    }

    .featured-price-current {
        font-size: 1.1rem;
    }
}

@media screen and (max-width: 360px) {
    .featured-products-title {
        font-size: 1.05rem;
    }

    .brand-logo {
        width: 64px !important;
        height: 24px !important;
    }
}
