/**
 * Product Hover Video Styles
 * Version: 1.2.0
 */

/* Container dla obrazka/wideo produktu */
.woocommerce ul.products li.product .phv-video-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    display: block;
}

/* Obrazek produktu - definiuje wysokość kontenera */
.woocommerce ul.products li.product .phv-video-container img.phv-has-video {
    display: block;
    width: 100%;
    height: auto;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1;
}

/* Wideo ukryte domyślnie - dokładnie takie same wymiary jak obrazek produktu */
.woocommerce ul.products li.product .phv-video-container video.phv-hover-video,
.custom_single_product_view_block .wrap_product_card .product_card_image video.phv-hover-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 2;
    display: block;
    background-color: #000;
}

/* Przy hover - ukryj obrazek, pokaż wideo - TYLKO gdy hover na .product_card_image */
.product_card_image:hover img.phv-has-video {
    opacity: 0 !important;
}

.product_card_image:hover video.phv-hover-video {
    opacity: 1 !important;
}

/* Badge z ikonką wideo w rogu produktu */
.phv-video-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 30px;
    height: 30px;
    background: rgba(249, 1, 89, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: opacity 0.3s ease, transform 0.2s ease;
    opacity: 1;
}

.phv-video-badge:hover {
    transform: scale(1.1);
    background: #f90159;
}

.phv-video-badge svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* Ukryj badge podczas hover na .product_card_image (żeby nie zasłaniał wideo) - tylko desktop */
.product_card_image:hover .phv-video-badge {
    opacity: 0;
    pointer-events: none;
}

/* Na mobile badge zostaje widoczny (zmienia się przez JS po tapnięciu) */
.phv-video-badge.phv-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Loading indicator (opcjonalnie) */
.woocommerce ul.products li.product .phv-video-container.phv-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: phv-spin 0.8s linear infinite;
    z-index: 2;
}

@keyframes phv-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mobile: wideo pokazuje się po tapnięciu badge (klasa .phv-playing dodawana przez JS) */
video.phv-hover-video.phv-playing {
    opacity: 1 !important;
    z-index: 5 !important;
    display: block !important;
    pointer-events: auto !important;
}

/* Mobile: ukryj obrazek gdy wideo gra - dodaj klasę też do obrazka przez JS */
img.phv-has-video.phv-video-active {
    opacity: 0 !important;
}

/* Fallback dla przeglądarek bez :has() */
.phv-video-container.phv-container-playing img.phv-has-video {
    opacity: 0 !important;
}

/* Responsive - na bardzo małych ekranach można zmniejszyć badge */
@media (max-width: 480px) {
    .phv-video-badge {
        width: 28px;
        height: 28px;
        top: 10px;
        left: 10px;
    }
    
    .phv-video-badge svg {
        width: 14px;
        height: 14px;
    }
}

