/* WooCommerce Product Gallery Styles */
.woocommerce-product-gallery {
    position: relative;
}

/* Video Gallery Plugin Integration */
.woocommerce-product-gallery__image[data-vwg-video="1"] {
    /* Prevent video slides from being treated as clickable images */
    pointer-events: none;
}

.woocommerce-product-gallery__image[data-vwg-video="1"] .woocommerce-product-gallery__vwg_video {
    /* Re-enable pointer events for the video container */
    pointer-events: auto;
    display: block;
    width: 100%;
    height: 100%;
}

.woocommerce-product-gallery__image[data-vwg-video="1"] .video-js {
    /* Ensure video player takes full space */
    width: 100% !important;
    height: 100% !important;
    min-height: 400px;
}

/* Video thumbnail styling */
.flex-control-thumbs .vwg-video-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 4px;
    overflow: hidden;
    width: 60px !important;
    height: 60px !important;
    margin: 0;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.flex-control-thumbs .vwg-video-wrapper.flex-active {
    border: 1px solid #FFDE16;
    padding: 4px;
    opacity: 1;
}

.flex-control-thumbs .vwg-video-wrapper:hover {
    opacity: 0.8;
}

.flex-control-thumbs .vwg-video-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flex-control-thumbs .vwg-video-wrapper i.far.fa-play-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 2;
    pointer-events: none;
    background: rgba(0,0,0,0.3);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure video thumbnails have the same styling as image thumbnails */
.flex-control-thumbs li:has(.vwg-video-wrapper) {
    flex: 0 0 auto;
    width: 60px !important;
    height: 60px !important;
    margin: 0;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.flex-control-nav.flex-control-thumbs li:has(.vwg-video-wrapper.flex-active) {
    opacity: 1;
}

/* Prevent PhotoSwipe from opening for video elements */
.woocommerce-product-gallery__image[data-vwg-video="1"] a {
    /* Remove any PhotoSwipe attributes */
    data-size: none !important;
    data-index: none !important;
}

/* Ensure video controls are accessible */
.woocommerce-product-gallery__image[data-vwg-video="1"] .vjs-control-bar {
    z-index: 10;
}

.woocommerce-product-gallery__image[data-vwg-video="1"] .vjs-big-play-button {
    z-index: 11;
}

/* Additional video player styling */
.woocommerce-product-gallery__image[data-vwg-video="1"] .video-js {
    border-radius: 4px;
    overflow: hidden;
}

.woocommerce-product-gallery__image[data-vwg-video="1"] .vjs-poster {
    background-size: cover;
    background-position: center;
}

/* Thumbnails Container */
.flex-control-thumbs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    gap: 10px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    margin-top: 16px !important;
    margin-bottom: -78px !important;
    padding-bottom:2px !important;
}

.flex-control-thumbs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Thumbnail Items */
.flex-control-thumbs li,
.flex-control-thumbs li img{
    flex: 0 0 auto;
    width: 60px !important;
    height: 60px !important;
    margin: 0;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}
.flex-control-thumbs li img.flex-active{
    border: 1px solid #FFDE16;
    padding:4px;
}

.flex-control-thumbs li:hover {
    opacity: 0.8;
}

.flex-control-nav.flex-control-thumbs li:has(.flex-active){
    opacity: 1;
}

.flex-control-thumbs li.flex-active {
    opacity: 1;
}

/* Thumbnail Images */
.flex-control-thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 2px solid transparent;
    transition: border-color 0.3s ease;
}

.flex-control-thumbs .flex-active img {
    border-color: #000;
}

/* Navigation Arrows */
.flex-direction-nav {
    position: absolute;
    top: 50%;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    transform: translateY(-50%);
    z-index: 10;
}

.flex-direction-nav li {
    position: absolute;
    margin: 0;
    padding: 0;
}

.flex-direction-nav li:first-child {
    left: 10px;
}

.flex-direction-nav li:last-child {
    right: 10px;
}

.flex-direction-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    text-decoration: none;
    color: #000;
    font-size: 0;
    transition: background-color 0.3s ease;
}

.flex-direction-nav a:hover {
    background: rgba(255, 255, 255, 1);
}

.flex-direction-nav a:before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    border-top: 2px solid #000;
    border-right: 2px solid #000;
}

.flex-direction-nav .flex-prev:before {
    transform: rotate(-135deg);
}

.flex-direction-nav .flex-next:before {
    transform: rotate(45deg);
}

.flex-direction-nav .flex-disabled {
    opacity: 0.3;
    cursor: default;
} 


/* Custom Border and image */

.woocommerce-product-gallery > .flex-viewport img{
    padding: 20px;
}

.woocommerce-product-gallery{
    border: 1px solid #AFAFAF;
    border-radius:5px;
    margin-bottom: 160px !important;
    padding-top: 64px !important;
}


@media (width<640px){
    .woocommerce-product-gallery{
        margin-bottom: 120px !important;
    }
}

/* Video gallery item specific styling */
.video-gallery-item {
    /* Additional styling for video gallery items */
}

.video-gallery-item .woocommerce-product-gallery__vwg_video {
    display: block;
    width: 100%;
    height: 100%;
}

/* Ensure video controls are properly positioned */
.video-gallery-item .vjs-control-bar {
    z-index: 10;
}

.video-gallery-item .vjs-big-play-button {
    z-index: 11;
}

/* Prevent any PhotoSwipe interference */
.video-gallery-item a {
    pointer-events: none !important;
}

.video-gallery-item .woocommerce-product-gallery__vwg_video {
    pointer-events: auto !important;
}