/**
 * ProductVideo Upload - Listing CSS
 * Styles for videos in product listings and placeholders
 */

/* Video placeholder for [product_video_listing] shortcode */
.product-video-listing-placeholder {
    width: 100%;
    max-width: 100%;
}

.product-video-listing-placeholder:not(.has-video) {
    display: none;
}

.product-video-listing-placeholder .productvideo-wrapper {
    width: 100%;
    max-width: 100%;
}

.product-video-listing-placeholder .productvideo-player {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
}

/* Ensure video fits in various containers */
.product-video-listing-placeholder video {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* For Creative Element - ensure proper sizing */
.elementor-widget-container .product-video-listing-placeholder,
.ce-widget-container .product-video-listing-placeholder {
    width: 100%;
}

/* Video indicator badge (for hover preview style) */
.product-video-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    pointer-events: none;
}

.product-video-indicator .video-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: all 0.3s ease;
    pointer-events: auto;
    cursor: pointer;
    z-index: 15;
}

.product-video-indicator .video-icon i {
    font-size: 20px;
}

.product-video-indicator:hover .video-icon,
.product-miniature:hover .product-video-indicator .video-icon {
    opacity: 0;
}

/* Hover video */
.product-hover-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
    pointer-events: none;
}

.product-miniature:hover .product-hover-video,
.product-video-indicator.playing .product-hover-video {
    opacity: 1;
}

/* Make sure product thumbnail container is relative */
.product-miniature .thumbnail-container,
.product-miniature .product-thumbnail {
    position: relative;
}

/* Hide original image on hover when video plays */
.product-miniature:hover .product-thumbnail img {
    opacity: 0.3;
}

.product-miniature:hover .product-video-indicator.playing ~ .product-thumbnail img,
.product-miniature .product-video-indicator.playing + img {
    opacity: 0;
}

/* Alternative: Full replacement style */
.product-video-indicator.video-active .product-hover-video {
    opacity: 1;
}

/* Loading state */
.product-video-indicator.loading .video-icon i:before {
    content: "hourglass_empty";
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Ensure proper stacking in different themes */
.products .product-miniature {
    position: relative;
}

.product-miniature .product-flags {
    z-index: 20;
}

/* Clean video in listing - no extra spacing */
.product-video-listing-placeholder .productvideo-clean {
    margin: 0;
    padding: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .product-video-listing-placeholder .productvideo-player {
        max-height: 200px;
    }
}

/* ============================================
   CREATIVE ELEMENT - Video/Photo Hover Effect
   ============================================ */

/* Photo layer - visible by default */
.pv-photo-layer {
    opacity: 1;
    transition: opacity 0.4s ease;
}

/* Video layer - hidden by default */
.pv-video-layer {
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* On hover: hide photo, show video - ONLY if video content exists */
.pv-hover-container:has(.pv-video-content):hover .pv-photo-layer {
    opacity: 0;
}

.pv-hover-container:has(.pv-video-content):hover .pv-video-layer {
    opacity: 1;
}

/* Video icon indicator - hidden by default, visible only when video exists */
.pv-video-icon {
    display: none;
    transition: opacity 0.3s ease;
}

.pv-hover-container:has(.pv-video-content) .pv-video-icon {
    display: block;
}

.pv-hover-container:has(.pv-video-content):hover .pv-video-icon {
    opacity: 0;
}

/* ============================================
   VIDEO CAROUSEL
   ============================================ */

.pv-carousel {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.pv-carousel-track {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
}

.pv-carousel-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease;
}

.pv-carousel-slide.active {
    opacity: 1;
    position: relative;
    z-index: 5; /* Above inactive slides, below navigation */
}

.pv-carousel-slide video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: auto; /* Allow clicking on video controls */
}

/* Navigation dots - positioned higher to not overlap video controls */
.pv-carousel-dots {
    position: absolute;
    bottom: 45px; /* Above video controls */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
    pointer-events: auto;
}

.pv-carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0;
    transition: background 0.3s ease;
}

.pv-carousel-dot.active,
.pv-carousel-dot:hover {
    background: rgba(255, 255, 255, 1);
}

/* Navigation arrows */
.pv-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pv-carousel:hover .pv-carousel-arrow {
    opacity: 1;
}

.pv-carousel-prev {
    left: 10px;
}

.pv-carousel-next {
    right: 10px;
}

.pv-carousel-arrow:hover {
    background: rgba(0, 0, 0, 0.8);
}
