/* Estilos para Productos Vistos Plugin */

#productos-vistos-container {
    width: 100%;
    margin: 20px 0;
}

.productos-vistos-title {

    font-size: 35px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #212c55;
    text-align: center;
}

/* Grid para Desktop */
.productos-vistos-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}



/* Tarjeta de producto */
.producto-visto-item {
    max-width: 300px;
    background: #fff;
    border: 1px solid #2f2f2f;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.producto-visto-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(112, 175, 225, 0.25);
    border-color: #e8461c;
}

.producto-visto-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
}

.producto-visto-item h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 10px 0;
    color: #212c55;
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.producto-visto-item .price {
    font-size: 18px;
    font-weight: 700;
    color: #e8461c;
    margin: 10px 0;
}

/* Botón Comprar */
.pv-add-to-cart-btn {
    background-color: #e8461c !important;
    margin-bottom: 10px;
    color: white !important;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    box-shadow: 0 2px 4px rgba(232, 70, 28, 0.3);
}

.pv-add-to-cart-btn:hover {
    background-color: #d13516 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(232, 70, 28, 0.4);
}

.pv-add-to-cart-btn:active {
    transform: translateY(0);
}

.pv-add-to-cart-btn:disabled {
    background-color: #ccc !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Botón Ver opciones (enlace estilizado) */
.pv-view-options-btn {
    display: inline-block;
    text-align: center;
    background-color: #70afe1;
    color: #fff !important;
    padding: 10px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    width: 100%;
    transition: all 0.3s ease;
}
.pv-view-options-btn:hover {
    background-color: #5a97c8;
}

/* Navegación del Carousel (oculta por defecto) */
.carousel-navigation {
    display: none;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.carousel-prev,
.carousel-next {
    background-color: #212c55;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-prev:hover,
.carousel-next:hover {
    background-color: #70afe1;
    transform: scale(1.1);
}

/* Estados de carga */
.pv-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.pv-loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #70afe1;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive - Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
    .productos-vistos-grid {
        display: grid; /* necesario para que grid-template-columns tenga efecto */
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
    
    .producto-visto-item img {
        height: 180px;
    }
}

/* Responsive - Mobile y Tablet pequeño */
@media (max-width: 768px) {
    .productos-vistos-title {
        font-size: 30px;
        text-align: center;
        margin-bottom: 15px;
    }
    
    
    /* Convertir a carousel en móvil - mantener tamaño desktop */
    .productos-vistos-grid {
        /* Slider horizontal con snap (solo móvil) */
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;                 /* no pasar a segunda fila: slider 1 línea */
        gap: 20px;
        padding: 10px;
        margin-bottom: 10px;

        /* Desplazamiento horizontal y snap legible */
        overflow-x: scroll;                 /* usar scroll explícito */
        overflow-y: hidden;                 /* evitar scroll vertical accidental */
        overscroll-behavior-x: contain;     /* contener el rebote horizontal */
        scroll-snap-type: x proximity;      /* snap menos estricto que mandatory */
        scroll-padding: 0 10px;             /* alinear el snap con el padding lateral */
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;                 /* mejorar gesto horizontal */

        /* Evitar parpadeos */
        will-change: scroll-position;
        backface-visibility: hidden;
        perspective: 1000px;
    }
    
    .productos-vistos-grid::-webkit-scrollbar {
        height: 4px;
    }
    
    .productos-vistos-grid::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 2px;
    }
    
    .productos-vistos-grid::-webkit-scrollbar-thumb {
        background: #70afe1;
        border-radius: 2px;
    }
    
    .productos-vistos-grid::-webkit-scrollbar-thumb:hover {
        background: #e8461c;
    }
    
    .producto-visto-item {
        /* Tamaño tipo slider (pedido) */
        flex: 0 0 auto;                     /* ancho según width en lugar de fijo */
        width: 70%;                         /* pedido: 70% */
        min-width: 190px;                   /* pedido: mínimo 190px */
        max-width: 300px;                   /* pedido: máximo 300px */
        height: auto;                      /* pedido: altura 250px */
        margin: 20px auto;                  /* pedido: centrar visualmente */
        padding: 0 15px;                    /* pedido: padding lateral */
        background-color: var(--just-white, #fff); /* pedido con fallback */
        border-radius: 15px;                /* pedido: bordes redondeados */
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.16); /* pedido: sombra */

        /* Snap al centro para efecto carrusel */
        scroll-snap-align: center;          /* pedido: centrar el snap */

        /* Evitar parpadeos en las tarjetas */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
    
    .producto-visto-item img {
        height: 200px; /* Mantener altura del desktop */
    }
    
    .producto-visto-item h4 {
        font-size: 16px; /* Mantener tamaño del desktop */
        height: 2.8em; /* Mantener altura del desktop */
    }
    
    .pv-add-to-cart-btn {
        padding: 12px 24px; /* Mantener padding del desktop */
        font-size: 14px; /* Mantener tamaño del desktop */
    }
    
    /* Mostrar navegación del carousel en móvil */
    .carousel-navigation {
        display: flex;
    }
}

@media (max-width: 480px) {
    .producto-visto-item {
        flex: 0 0 240px; /* Ligeramente más pequeño para móviles muy pequeños */
    }
    
    .producto-visto-item img {
        height: 180px; /* Reducir un poco la altura en pantallas muy pequeñas */
    }
    
    .carousel-prev,
    .carousel-next {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

/* Animaciones para el carousel touch */
.productos-vistos-grid.scrolling {
    scroll-behavior: auto;
}

/* Optimizaciones para evitar parpadeos en móvil */
@media (max-width: 768px) {
    .producto-visto-item,
    .producto-visto-item * {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-perspective: 1000px;
        perspective: 1000px;
    }
    
    .producto-visto-item img {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    /* Suavizar transiciones en móvil */
    .producto-visto-item:hover {
        transform: translateZ(0) translateY(-3px); /* Reducir movimiento en móvil */
    }
}

/* Estilos para productos sin stock */
.producto-visto-item.out-of-stock {
    opacity: 0.7;
    border-color: #ccc;
}

.producto-visto-item.out-of-stock .pv-add-to-cart-btn {
    background-color: #999 !important;
    cursor: not-allowed;
}

/* Overlay de loading para botones */
.pv-add-to-cart-btn.loading {
    position: relative;
    color: transparent !important;
}

.pv-add-to-cart-btn.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

/* Mensaje de éxito temporal */
.pv-success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #70afe1;
    color: white;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(112, 175, 225, 0.3);
    z-index: 9999;
    font-weight: 600;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid #212c55;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.pv-success-message.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Estilos adicionales con paleta de colores */
.producto-visto-item h4 a {
    color: #212c55;
    text-decoration: none;
    transition: color 0.3s ease;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1.2rem;
}

.producto-visto-item h4 a:hover {
    color: #e8461c;
}

/* Loader personalizado */
.pv-loading {
    color: #212c55;
}

/* Estados focus para accesibilidad */
.pv-add-to-cart-btn:focus,
.carousel-prev:focus,
.carousel-next:focus {
    outline: 2px solid #70afe1;
    outline-offset: 2px;
}

/* Gradiente sutil en las tarjetas */
.producto-visto-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 8px 8px 0 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.producto-visto-item {
    position: relative;
}

.producto-visto-item:hover::before {
    opacity: 1;
}