/**
 * WooCommerce Product Video Gallery Styles - Updated Layout
 * Version: 1.0.1
 */

/* ========================================
   Gallery Grid Layout - 4 Column Design
======================================== */
.wcpvg-gallery-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    max-width: 1400px;
}

.wcpvg-gallery-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
    height: 400px;
    margin-bottom: 20px;
}

/* Video - Column 1, spans both rows */
.wcpvg-video-item {
    grid-column: 1;
    grid-row: 1 / 3;
}

/* Product Image (first image) - Column 2, spans both rows */
.wcpvg-gallery-grid .wcpvg-image-item:nth-child(2) {
    grid-column: 2;
    grid-row: 1 / 3;
}

/* Gallery Image 2 - Column 3, Row 1 */
.wcpvg-gallery-grid .wcpvg-image-item:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
}

/* Gallery Image 3 - Column 3, Row 2 */
.wcpvg-gallery-grid .wcpvg-image-item:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
}

/* Gallery Image 4 (with button) - Column 4, spans both rows */
.wcpvg-gallery-grid .wcpvg-image-item:nth-child(5) {
    grid-column: 4;
    grid-row: 1 / 3;
}

/* Without video - adjust positions */
.wcpvg-gallery-grid:not(:has(.wcpvg-video-item)) .wcpvg-image-item:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / 3;
}

.wcpvg-gallery-grid:not(:has(.wcpvg-video-item)) .wcpvg-image-item:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

.wcpvg-gallery-grid:not(:has(.wcpvg-video-item)) .wcpvg-image-item:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

.wcpvg-gallery-grid:not(:has(.wcpvg-video-item)) .wcpvg-image-item:nth-child(4) {
    grid-column: 3;
    grid-row: 1 / 3;
}

/* Responsive adjustments */
@media (min-width: 1440px) {
    .wcpvg-gallery-grid {
        height: 450px;
        gap: 16px;
    }
}

@media (min-width: 1024px) and (max-width: 1439px) {
    .wcpvg-gallery-grid {
        height: 380px;
        gap: 14px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .wcpvg-gallery-grid {
        grid-template-columns: 1fr 1fr 1fr;
        height: 350px;
        gap: 12px;
    }
    
    /* Adjust for 3 columns on tablet */
    .wcpvg-gallery-grid .wcpvg-image-item:nth-child(5) {
        grid-column: 3;
        grid-row: 1 / 3;
    }
}

@media (min-width: 640px) and (max-width: 767px) {
    .wcpvg-gallery-grid {
        grid-template-columns: 1fr 1fr;
        height: auto;
        gap: 10px;
    }
    
    /* Stack all items on smaller tablets */
    .wcpvg-video-item,
    .wcpvg-gallery-grid .wcpvg-image-item {
        grid-column: auto !important;
        grid-row: auto !important;
    }
}

/* ========================================
   Gallery Items
======================================== */
.wcpvg-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f5f5;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wcpvg-gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.wcpvg-image-item a {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.wcpvg-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.wcpvg-gallery-item:hover img {
    transform: scale(1.05);
}

/* ========================================
   Video Container
======================================== */
.wcpvg-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.wcpvg-video-embed {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.wcpvg-video-embed iframe,
.wcpvg-video-embed video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    object-fit: cover;
}

.wcpvg-video-trigger {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
}

.wcpvg-video-trigger img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   Play Icon Overlay
======================================== */
.wcpvg-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.3s ease;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.wcpvg-video-trigger:hover .wcpvg-play-icon {
    transform: translate(-50%, -50%) scale(1.1);
}

.wcpvg-play-icon svg {
    width: 100%;
    height: 100%;
}

/* ========================================
   Zoom Icon Overlay
======================================== */
.wcpvg-zoom-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2;
}

.wcpvg-image-item:hover .wcpvg-zoom-icon {
    opacity: 1;
}

.wcpvg-zoom-icon svg {
    width: 20px;
    height: 20px;
    color: #333;
}

/* ========================================
   Mobile Slider
======================================== */
.wcpvg-mobile-slider {
    display: none;
}

@media (max-width: 639px) {
    .wcpvg-gallery-grid {
        display: none;
    }
    
    .wcpvg-mobile-slider {
        display: block;
        width: 100%;
        border-radius: 12px;
        overflow: hidden;
    }
}

.wcpvg-mobile-slider .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    aspect-ratio: 1 / 1;
}

.wcpvg-mobile-slider .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Swiper Navigation Buttons */
.wcpvg-mobile-slider .swiper-button-next,
.wcpvg-mobile-slider .swiper-button-prev {
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.wcpvg-mobile-slider .swiper-button-next:after,
.wcpvg-mobile-slider .swiper-button-prev:after {
    font-size: 18px;
}

.wcpvg-mobile-slider .swiper-button-next:hover,
.wcpvg-mobile-slider .swiper-button-prev:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Swiper Pagination */
.wcpvg-mobile-slider .swiper-pagination {
    bottom: 16px;
}

.wcpvg-mobile-slider .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    background: #fff;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.wcpvg-mobile-slider .swiper-pagination-bullet-active {
    opacity: 1;
    width: 24px;
    border-radius: 4px;
}

/* ========================================
   GLightbox Customization
======================================== */
.glightbox-container .gslide-description {
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 20px;
    border-radius: 8px;
}

.glightbox-container .gslide-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #fff;
}

/* ========================================
   Thumbnail Strip (Bottom Navigation)
======================================== */
.glightbox-thumbnails {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    padding: 15px 60px;
    z-index: 9999;
}

.glightbox-thumbnails-inner {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.glightbox-thumbnails-inner::-webkit-scrollbar {
    height: 6px;
}

.glightbox-thumbnails-inner::-webkit-scrollbar-track {
    background: transparent;
}

.glightbox-thumbnails-inner::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.glightbox-thumbnails-inner::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.glightbox-thumbnails-track {
    display: flex;
    gap: 10px;
    padding: 5px 0;
}

.glightbox-thumbnail {
    flex: 0 0 auto;
    width: 100px;
    height: 70px;
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    background: #000;
}

.glightbox-thumbnail:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.glightbox-thumbnail.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.glightbox-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gthumb-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #000;
    pointer-events: none;
}

/* Thumbnail Navigation Buttons */
.gthumb-prev,
.gthumb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.gthumb-prev {
    left: 10px;
}

.gthumb-next {
    right: 10px;
}

.gthumb-prev:hover,
.gthumb-next:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.gthumb-prev svg,
.gthumb-next svg {
    width: 20px;
    height: 20px;
}

/* Hide thumbnails on small screens */
@media (max-width: 767px) {
    .glightbox-thumbnails {
        padding: 10px 50px;
    }
    
    .glightbox-thumbnail {
        width: 80px;
        height: 55px;
    }
}

@media (max-width: 480px) {
    .glightbox-thumbnails {
        display: none;
    }
}

/* ========================================
   Loading States
======================================== */
.wcpvg-gallery-item.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   Accessibility
======================================== */
.wcpvg-gallery-item:focus-visible,
.wcpvg-video-trigger:focus-visible,
.wcpvg-lightbox-trigger:focus-visible {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* ========================================
   Print Styles
======================================== */
@media print {
    .wcpvg-mobile-slider,
    .wcpvg-zoom-icon,
    .wcpvg-play-icon {
        display: none;
    }
    
    .wcpvg-gallery-grid {
        display: grid !important;
        gap: 10px;
    }
    
    .wcpvg-gallery-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ========================================
   RTL Support
======================================== */
[dir="rtl"] .wcpvg-zoom-icon {
    right: auto;
    left: 12px;
}

/* ========================================
   Show All Photos Button & Overlay
======================================== */
.wcpvg-show-all-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
}

.wcpvg-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1;
}

.wcpvg-show-all-btn {
    position: relative;
    background: #fff;
    color: #333;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 2;
    pointer-events: auto;
    white-space: nowrap;
}

.wcpvg-show-all-btn:hover {
    background: #f8f9fa;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.wcpvg-show-all-btn:active {
    transform: scale(0.98);
}

/* Hidden items */
.wcpvg-gallery-item.wcpvg-hidden {
    display: none;
}

/* ========================================
   Dark Mode Support
======================================== */
@media (prefers-color-scheme: dark) {
    .wcpvg-gallery-item {
        background: #2a2a2a;
    }
    
    .wcpvg-zoom-icon {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .wcpvg-zoom-icon svg {
        color: #fff;
    }
}

/* ========================================
   Show All Photos Button Style (if needed)
======================================== */
.wcpvg-show-all-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 10;
}

.wcpvg-show-all-btn:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}
