/**
 * WooCommerce Product Video Gallery Styles
 * Version: 1.0.0
 */

/* Video Container */
.wpvg-video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: 4px;
}

.wpvg-video-container iframe,
.wpvg-video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Video Slide */
.wpvg-video-slide {
    position: relative;
    display: block;
}

.wpvg-video-slide a {
    display: block;
    position: relative;
    cursor: pointer;
}

/* Play Button Overlay */
.wpvg-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
    transition: all 0.3s ease;
    opacity: 0.9;
}

.wpvg-video-trigger:hover .wpvg-play-button {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.wpvg-play-button svg {
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

/* Video Thumbnail */
.wpvg-video-slide .wpvg-video-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 5;
    transition: background 0.3s ease;
}

.wpvg-video-trigger:hover .wpvg-video-container::before {
    background: rgba(0, 0, 0, 0.5);
}

/* Hide iframe initially */
.wpvg-video-container iframe,
.wpvg-video-container video {
    pointer-events: none;
}

/* Active state when video is playing */
.wpvg-video-playing .wpvg-play-button {
    display: none;
}

.wpvg-video-playing .wpvg-video-container::before {
    display: none;
}

.wpvg-video-playing .wpvg-video-container iframe,
.wpvg-video-playing .wpvg-video-container video {
    pointer-events: auto;
}

/* Gallery thumbnail styling */
.woocommerce-product-gallery__wrapper .wpvg-video-slide {
    margin-bottom: 1em;
}

/* Flex gallery support */
.flex-control-thumbs .wpvg-video-slide img {
    position: relative;
}

.flex-control-thumbs .wpvg-video-slide::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    pointer-events: none;
}

.flex-control-thumbs .wpvg-video-slide::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-35%, -50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent #ffffff;
    z-index: 1;
    pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .wpvg-play-button svg {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .wpvg-play-button svg {
        width: 50px;
        height: 50px;
    }
}

/* Lightbox/Photoswipe compatibility */
.pswp__video-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pswp__video-container iframe,
.pswp__video-container video {
    max-width: 100%;
    max-height: 100%;
}

/* Loading state */
.wpvg-video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wpvg-spin 1s linear infinite;
    z-index: 20;
}

@keyframes wpvg-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Theme compatibility fixes */
.woocommerce div.product div.images .wpvg-video-slide {
    margin: 0;
}

.woocommerce div.product div.images .flex-control-nav.flex-control-thumbs li {
    position: relative;
}

/* Ensure video maintains aspect ratio in gallery */
.woocommerce-product-gallery__image .wpvg-video-container {
    border-radius: 0;
}

/* Fix for some themes that add extra padding */
.wpvg-video-slide > a {
    padding: 0 !important;
    margin: 0 !important;
}