/**
 * Frontend styles for WooCommerce Product Video Gallery
 */

/* Video wrapper in gallery */
.wpvg-video-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #000;
}

.wpvg-video-wrapper video,
.wpvg-video-wrapper .wpvg-product-video {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

/* Video slide in gallery */
.wpvg-video-slide {
    position: relative;
    width: 100%;
}

.wpvg-video-slide .wpvg-video-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Product video - ensure no controls */
.wpvg-product-video {
    max-width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

/* Hide controls completely - Chrome/Safari */
.wpvg-product-video::-webkit-media-controls {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.wpvg-product-video::-webkit-media-controls-enclosure {
    display: none !important;
}

.wpvg-product-video::-webkit-media-controls-panel {
    display: none !important;
}

.wpvg-product-video::-webkit-media-controls-play-button {
    display: none !important;
}

.wpvg-product-video::-webkit-media-controls-start-playback-button {
    display: none !important;
}

/* Hide controls - Firefox */
.wpvg-product-video::-moz-range-track {
    display: none !important;
}

/* Standard WooCommerce gallery compatibility */
.woocommerce-product-gallery__image.wpvg-video-slide {
    display: block !important;
}

.woocommerce-product-gallery__wrapper > .wpvg-video-slide:first-child {
    order: -1;
}

/* Ensure video displays correctly in various themes */
.woocommerce div.product div.images .wpvg-video-wrapper {
    margin: 0;
    padding: 0;
}

.woocommerce div.product div.images .wpvg-product-video {
    width: 100%;
    height: auto;
}

/* FlexSlider compatibility */
.woocommerce-product-gallery .flex-viewport .wpvg-video-wrapper,
.woocommerce-product-gallery .woocommerce-product-gallery__wrapper .wpvg-video-wrapper {
    width: 100%;
    height: auto;
}

.flex-viewport .wpvg-video-slide {
    display: block !important;
}

/* Force video slide to be first */
.woocommerce-product-gallery__wrapper .wpvg-video-slide {
    order: -1;
}

/* Flatsome theme compatibility */
.product-gallery-slider .wpvg-video-slide,
.flickity-slider .wpvg-video-slide {
    width: 100%;
}

/* WoodMart theme compatibility */
.woocommerce-product-gallery-photoswipe .wpvg-video-slide,
.wd-carousel-container .wpvg-video-slide {
    width: 100%;
}

/* Astra theme compatibility */
.ast-product-gallery-layout .wpvg-video-slide {
    width: 100%;
}

/* OceanWP theme compatibility */
.owp-product-gallery .wpvg-video-slide {
    width: 100%;
}

/* Storefront theme compatibility */
.storefront-single-product-content .wpvg-video-slide {
    width: 100%;
}

/* Fix for zoom functionality - disable on video */
.wpvg-video-slide .zoomImg,
.wpvg-video-slide .woocommerce-product-gallery__trigger {
    display: none !important;
}

.wpvg-video-slide a {
    pointer-events: none;
    cursor: default;
}

/* Video thumbnail in gallery thumbnails */
.wpvg-video-thumbnail-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.wpvg-video-thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wpvg-video-thumb-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    min-height: 60px;
}

.wpvg-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    pointer-events: none;
}

.wpvg-play-icon svg {
    margin-left: 2px;
}

/* Thumbnail gallery video indicator */
.flex-control-thumbs li.wpvg-video-thumb,
.woocommerce-product-gallery__image--placeholder.wpvg-video-thumb {
    position: relative;
}

.flex-control-thumbs li.wpvg-video-thumb::after,
.woocommerce-product-gallery__image--placeholder.wpvg-video-thumb::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent rgba(255, 255, 255, 0.9);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Loading state */
.wpvg-video-loading {
    position: relative;
}

.wpvg-video-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.wpvg-video-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wpvg-spin 1s linear infinite;
    z-index: 2;
}

@keyframes wpvg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .wpvg-video-wrapper video,
    .wpvg-video-wrapper .wpvg-product-video {
        width: 100%;
        height: auto;
    }

    .wpvg-play-icon {
        width: 40px;
        height: 40px;
    }

    .wpvg-play-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* Hide the hidden container */
#wpvg-video-container {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}
