/* ========== MEJORAS RESPONSIVE GENERALES ========== */

/* Tablets grandes y laptops pequeñas (992px - 1199px) */
@media screen and (max-width: 1199px) {
    header {
        width: 95%;
        padding: 0 15px;
    }
    
    .carousel {
        height: 600px;
    }
    
    .carousel .list {
        width: 95%;
    }
    
    .carousel .list .item:nth-child(2) .introduce {
        width: 350px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    
    .products-grid.compact {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

/* Tablets (768px - 991px) */
@media screen and (max-width: 991px) {
    /* Header responsive */
    header {
        height: 60px;
        flex-wrap: wrap;
        padding: 0 15px;
    }
    
    header nav {
        gap: 18px;
    }
    
    header nav a span {
        display: none; /* Ocultar texto en tablets */
    }
    
    header nav a svg {
        width: 20px;
        height: 20px;
    }
    
    .btn-login {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    /* Carousel ajustado */
    .carousel {
        height: 550px;
        margin-top: 20px;
    }
    
    .carousel .list .item {
        width: 90%;
    }
    
    .carousel .list .item:nth-child(2) .introduce {
        width: 320px;
    }
    
    .carousel .list .item:nth-child(2) .introduce .topic {
        font-size: 2.4em;
    }
    
    .carousel .list .item img {
        width: 55%;
    }
    
    /* Detail view optimizado */
    .carousel.showDetail .list .item:nth-child(2) .detail {
        width: 55%;
        padding-right: 20px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .detail .specifications {
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 10px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .detail .title {
        font-size: 2.2em;
    }
    
    /* Arrows más pequeños */
    #prev, #next {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    /* Secciones optimizadas */
    .categories-section.compact,
    .products-section.compact {
        margin: 40px auto 30px;
    }
    
    .section-title {
        font-size: 1.8em;
        margin-bottom: 25px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 16px;
    }
    
    .category-card.compact {
        padding: 20px 12px;
    }
    
    .products-grid.compact {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 18px;
    }
    
    /* CTA Section */
    .cta-section {
        margin: 50px auto;
    }
    
    .cta-content {
        padding: 40px 30px;
    }
    
    .cta-content h2 {
        font-size: 1.8em;
    }
    
    /* Cart sidebar */
    .cart-sidebar {
        width: 350px;
        right: -350px;
    }
    
    /* Footer */
    .footer-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
}

/* Móviles grandes (576px - 767px) */
@media screen and (max-width: 767px) {
    /* Header móvil */
    header {
        height: auto;
        min-height: 55px;
        padding: 10px 15px;
    }
    
    header .logo {
        font-size: 18px;
    }
    
    header .logo svg {
        width: 22px;
        height: 22px;
    }
    
    header nav {
        gap: 12px;
        flex-wrap: wrap;
    }
    
    header nav a {
        font-size: 0;
        padding: 8px;
    }
    
    header nav a svg {
        width: 22px;
        height: 22px;
        margin: 0;
    }
    
    .btn-login {
        padding: 8px 12px;
        font-size: 0;
    }
    
    .btn-login svg {
        margin: 0;
    }
    
    .cart-icon svg {
        width: 24px;
        height: 24px;
    }
    
    /* Carousel móvil */
    .carousel {
        height: 480px;
        margin-top: 10px;
    }
    
    .carousel .list {
        height: 85%;
    }
    
    .carousel .list .item {
        width: 100%;
        font-size: 10px;
    }
    
    .carousel .list .item:nth-child(2) .introduce {
        width: 52%;
        padding-right: 10px;
    }
    
    .carousel .list .item:nth-child(2) .introduce .title {
        font-size: 10px;
        margin-bottom: 6px;
    }
    
    .carousel .list .item:nth-child(2) .introduce .topic {
        font-size: 1.6em;
        margin-bottom: 10px;
    }
    
    .carousel .list .item:nth-child(2) .introduce .des {
        font-size: 11px;
        line-height: 1.4;
        margin-bottom: 14px;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .carousel .list .item:nth-child(2) .introduce .seeMore {
        padding: 8px 18px;
        font-size: 11px;
    }
    
    .carousel .list .item img {
        width: 48%;
        border-radius: 15px;
    }
    
    /* Detail view móvil */
    .carousel.showDetail .list .item:nth-child(2) .detail {
        width: 55%;
        font-size: 11px;
        backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.95);
        padding: 15px;
        border-radius: 15px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .detail .title {
        font-size: 1.8em;
        margin-bottom: 10px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .detail .des {
        font-size: 11px;
        max-height: 80px;
        overflow-y: auto;
        margin-bottom: 15px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .detail .specifications {
        gap: 8px;
        margin-top: 15px;
        padding-top: 15px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .detail .specifications div {
        width: 70px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .detail .specifications div p:nth-child(1) {
        font-size: 9px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .detail .specifications div p:nth-child(2) {
        font-size: 12px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .checkout {
        margin-top: 15px;
        flex-direction: column;
        gap: 8px;
    }
    
    .carousel.showDetail .list .item:nth-child(2) .checkout button {
        width: 100%;
        padding: 10px;
        font-size: 11px;
    }
    
    /* Arrows móvil */
    .arrows {
        bottom: 5px;
    }
    
    #prev, #next {
        width: 38px;
        height: 38px;
        font-size: 14px;
    }
    
    #back {
        font-size: 11px;
        padding: 6px 14px;
    }
    
    /* Secciones móvil */
    .categories-section.compact,
    .products-section.compact {
        margin: 35px auto 25px;
        padding: 0 15px;
    }
    
    .section-title {
        font-size: 1.5em;
        margin-bottom: 20px;
        gap: 8px;
    }
    
    .section-title svg {
        width: 20px;
        height: 20px;
    }
    
    .section-title::after {
        width: 40px;
        height: 2px;
        bottom: -10px;
    }
    
    /* Categorías móvil */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .category-card.compact {
        padding: 18px 10px;
    }
    
    .category-icon-svg {
        width: 40px;
        height: 40px;
        margin: 0 auto 10px;
    }
    
    .category-icon-svg svg {
        width: 100%;
        height: 100%;
    }
    
    .category-card.compact h3 {
        font-size: 14px;
    }
    
    /* Productos móvil */
    .products-grid.compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .product-card.compact {
        border-radius: 12px;
    }
    
    .product-image {
        height: 160px;
    }
    
    .product-info {
        padding: 12px;
    }
    
    .product-info h3 {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    .product-info .category {
        font-size: 11px;
        margin-bottom: 10px;
    }
    
    .price-row {
        margin-bottom: 10px;
    }
    
    .product-info .price {
        font-size: 18px;
    }
    
    .btn-add-small {
        width: 36px;
        height: 36px;
    }
    
    .btn-add-small svg {
        width: 16px;
        height: 16px;
    }
    
    .btn-view-full {
        padding: 8px;
        font-size: 12px;
        border-radius: 8px;
    }
    
    .btn-view-full svg {
        width: 14px;
        height: 14px;
    }
    
    /* CTA móvil */
    .cta-section {
        margin: 40px auto;
        padding: 0 15px;
    }
    
    .cta-content {
        padding: 30px 20px;
        border-radius: 15px;
    }
    
    .cta-content svg {
        width: 50px;
        height: 50px;
        margin-bottom: 15px;
    }
    
    .cta-content h2 {
        font-size: 1.4em;
        margin-bottom: 12px;
    }
    
    .cta-content p {
        font-size: 0.95em;
        margin-bottom: 20px;
    }
    
    .btn-cta {
        padding: 12px 30px;
        font-size: 13px;
        border-radius: 20px;
    }
    
    .btn-cta svg {
        width: 16px;
        height: 16px;
    }
    
    /* Cart sidebar móvil */
    .cart-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .cart-header {
        padding: 18px;
    }
    
    .cart-header h2 {
        font-size: 18px;
    }
    
    .cart-items {
        padding: 15px;
    }
    
    .cart-footer {
        padding: 18px;
    }
    
    .cart-total {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .btn-checkout,
    .btn-continue {
        padding: 12px;
        font-size: 13px;
    }
    
    /* Footer móvil */
    .footer.compact {
        padding: 35px 15px 12px;
        margin-top: 40px;
    }
    
    .footer-container {
        grid-template-columns: 1fr;
        gap: 25px;
        margin-bottom: 25px;
    }
    
    .footer-section h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .footer-section h3 svg {
        width: 20px;
        height: 20px;
    }
    
    .footer-section p,
    .footer-section a {
        font-size: 13px;
        margin-bottom: 8px;
    }
    
    .footer-contact p svg {
        width: 13px;
        height: 13px;
    }
    
    .footer-bottom {
        padding-top: 20px;
        font-size: 12px;
    }
}

/* Móviles pequeños (480px - 575px) */
@media screen and (max-width: 575px) {
    .carousel {
        height: 450px;
    }
    
    .carousel .list .item:nth-child(2) .introduce .topic {
        font-size: 1.4em;
    }
    
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .category-card.compact {
        padding: 15px 8px;
    }
    
    .category-card.compact h3 {
        font-size: 13px;
    }
    
    .products-grid.compact {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .product-image {
        height: 200px;
    }
    
    .product-card.compact {
        max-width: 400px;
        margin: 0 auto;
    }
}

/* Móviles muy pequeños (< 400px) */
@media screen and (max-width: 399px) {
    header .logo {
        font-size: 16px;
    }
    
    header .logo svg {
        width: 20px;
        height: 20px;
    }
    
    header nav {
        gap: 8px;
    }
    
    header nav a,
    .btn-login {
        padding: 6px;
    }
    
    header nav a svg,
    .btn-login svg,
    .cart-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .carousel {
        height: 400px;
    }
    
    .carousel .list .item:nth-child(2) .introduce {
        width: 50%;
    }
    
    .carousel .list .item:nth-child(2) .introduce .topic {
        font-size: 1.3em;
    }
    
    .carousel .list .item:nth-child(2) .introduce .des {
        font-size: 10px;
        -webkit-line-clamp: 2;
    }
    
    .section-title {
        font-size: 1.3em;
    }
    
    .categories-grid {
        gap: 8px;
    }
    
    .category-icon-svg {
        width: 35px;
        height: 35px;
    }
    
    .category-card.compact h3 {
        font-size: 12px;
    }
    
    .product-info .price {
        font-size: 16px;
    }
    
    .cta-content h2 {
        font-size: 1.2em;
    }
    
    .cta-content p {
        font-size: 0.9em;
    }
}

/* ========== OPTIMIZACIONES LANDSCAPE MÓVIL ========== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .carousel {
        height: 380px;
    }
    
    .carousel .list {
        height: 90%;
    }
    
    .carousel .list .item:nth-child(2) .introduce .des {
        -webkit-line-clamp: 2;
        max-height: 50px;
    }
    
    .arrows {
        bottom: 2px;
    }
    
    #prev, #next {
        width: 35px;
        height: 35px;
        font-size: 13px;
    }
}

/* ========== MEJORAS DE ACCESIBILIDAD ========== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== SOPORTE PARA PANTALLAS TÁCTILES ========== */
@media (hover: none) and (pointer: coarse) {
    header nav a:hover::after {
        width: 0;
    }
    
    .product-card.compact:hover {
        transform: none;
    }
    
    .product-card.compact:active {
        transform: scale(0.98);
    }
    
    .btn-add-small:hover {
        transform: none;
    }
    
    .btn-add-small:active {
        transform: scale(0.9);
    }
}

/* ========== OPTIMIZACIÓN PARA IMPRESIÓN ========== */
@media print {
    header,
    .arrows,
    .cart-sidebar,
    .overlay,
    .btn-cta,
    footer {
        display: none !important;
    }
    
    .carousel {
        height: auto;
    }
    
    .carousel .list .item {
        position: relative;
        page-break-inside: avoid;
    }
}