/* WooCommerce Product Video Gallery - Frontend Styles */

/* Video Badge on Thumbnail */
.wcpvg-video-slide {
    position: relative;
}

.wcpvg-video-trigger {
    position: relative;
    display: block;
    cursor: pointer;
}

/* Play Button Overlay - Center */
.wcpvg-video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 5;
    pointer-events: none;
}

.wcpvg-video-play-overlay svg {
    width: 40px;
    height: 40px;
    fill: #fff;
    margin-left: 4px;
}

.wcpvg-video-trigger:hover .wcpvg-video-play-overlay {
    background: rgba(255, 0, 0, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
}

.wcpvg-video-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
    z-index: 10;
    transition: all 0.3s ease;
}

.wcpvg-video-badge svg {
    width: 16px;
    height: 16px;
}

.wcpvg-video-trigger:hover .wcpvg-video-badge {
    background: rgba(0, 0, 0, 0.9);
}

/* Video Badge on Thumbnail Navigation */
.flex-control-thumbs li {
    position: relative;
}

.wcpvg-video-badge-thumb {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 4px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
}

.wcpvg-video-badge-thumb svg {
    width: 12px;
    height: 12px;
}

.flex-control-thumbs li:hover .wcpvg-video-badge-thumb {
    background: rgba(0, 0, 0, 0.9);
}

.wcpvg-video-thumbnail {
    width: 100%;
    height: auto;
    display: block;
}

/* Video Modal */
.wcpvg-video-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999999 !important; /* Higher than photoswipe */
    display: flex;
    align-items: center;
    justify-content: center;
    animation: wcpvgFadeIn 0.3s ease;
}

/* Prevent photoswipe/lightbox for video */
.wcpvg-video-slide .woocommerce-product-gallery__trigger {
    pointer-events: none !important;
    cursor: default !important;
}

.wcpvg-video-trigger {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Disable zoom for video thumbnails */
.wcpvg-video-slide img {
    cursor: pointer !important;
}

.wcpvg-video-slide .woocommerce-product-gallery__image {
    position: relative;
}

/* Prevent WC lightbox init on video */
.wcpvg-video-slide a[href="#"] {
    pointer-events: auto !important;
}

@keyframes wcpvgFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.wcpvg-video-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.wcpvg-video-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    z-index: 10;
    animation: wcpvgSlideUp 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes wcpvgSlideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.wcpvg-video-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    padding: 5px 10px;
    transition: all 0.2s ease;
    z-index: 11;
}

.wcpvg-video-modal-close:hover {
    color: #ccc;
    transform: scale(1.1);
}

/* Dynamic aspect ratio container */
.wcpvg-video-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* For landscape videos */
.wcpvg-video-container.wcpvg-landscape {
    aspect-ratio: 16 / 9;
}

/* For portrait videos */
.wcpvg-video-container.wcpvg-portrait {
    aspect-ratio: 9 / 16;
    max-width: 50vh;
}

/* For square videos */
.wcpvg-video-container.wcpvg-square {
    aspect-ratio: 1 / 1;
    max-width: 90vh;
}

.wcpvg-video-container iframe,
.wcpvg-video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Body class when modal is open */
body.wcpvg-modal-open {
    overflow: hidden;
}

/* WooCommerce Product Gallery Compatibility */
.woocommerce-product-gallery .wcpvg-video-slide .woocommerce-product-gallery__trigger {
    display: none;
}

/* Flexslider compatibility */
.flex-viewport .wcpvg-video-slide {
    width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .wcpvg-video-modal-content {
        width: 95%;
    }
    
    .wcpvg-video-modal-close {
        top: -50px;
        font-size: 32px;
    }
    
    .wcpvg-video-badge {
        bottom: 8px;
        right: 8px;
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .wcpvg-video-badge svg {
        width: 14px;
        height: 14px;
    }
    
    .wcpvg-video-play-overlay {
        width: 60px;
        height: 60px;
    }
    
    .wcpvg-video-play-overlay svg {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .wcpvg-video-modal-content {
        width: 100%;
        padding: 0 10px;
    }
    
    .wcpvg-video-container {
        border-radius: 4px;
    }
    
    .wcpvg-video-play-overlay {
        width: 50px;
        height: 50px;
    }
    
    .wcpvg-video-play-overlay svg {
        width: 25px;
        height: 25px;
    }
}

/* Loading state */
.wcpvg-video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.wcpvg-video-loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wcpvgSpin 1s linear infinite;
}

@keyframes wcpvgSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Theme compatibility fixes */
.wcpvg-video-slide img {
    max-width: 100%;
    height: auto;
}

.wcpvg-video-slide a {
    text-decoration: none;
}

/* Hover effect on video thumbnail */
.wcpvg-video-trigger::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
}

.wcpvg-video-trigger:hover::before {
    background: rgba(0, 0, 0, 0.1);
}
