/* Widgetry Pro - WooCommerce Product Gallery Styles */

/* Base Gallery Styles */
.widgetry-product-gallery {
    width: 100%;
    font-family: inherit;
    position: relative;
}

.widgetry-product-gallery * {
    box-sizing: border-box;
}

/* Main Gallery Container */
.widgetry-product-gallery .main-gallery {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #f8f9fa;
}

.widgetry-product-gallery .gallery-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 500px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.widgetry-product-gallery .gallery-item.active {
    position: relative;
    opacity: 1;
    visibility: visible;
}

.widgetry-product-gallery .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    cursor: zoom-in;
}

/* Zoom Effect */
.widgetry-product-gallery.zoom-enabled .gallery-item:hover img {
    transform: scale(1.1);
}

.widgetry-product-gallery .zoom-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.widgetry-product-gallery .gallery-item:hover .zoom-icon {
    opacity: 1;
}

/* Navigation Arrows */
.widgetry-product-gallery .gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.widgetry-product-gallery .gallery-nav:hover {
    background: #007cba;
    color: white;
    transform: translateY(-50%) scale(1.1);
}

.widgetry-product-gallery .prev-nav {
    left: 15px;
}

.widgetry-product-gallery .next-nav {
    right: 15px;
}

.widgetry-product-gallery .gallery-nav svg {
    width: 20px;
    height: 20px;
}

/* Thumbnails */
.widgetry-product-gallery .thumbnails {
    display: grid;
    gap: 10px;
    margin-top: 15px;
    grid-template-columns: repeat(6, 1fr);
}

.widgetry-product-gallery .thumbnails.position-left {
    position: absolute;
    left: -120px;
    top: 0;
    width: 100px;
    grid-template-columns: 1fr;
    margin-top: 0;
}

.widgetry-product-gallery .thumbnails.position-right {
    position: absolute;
    right: -120px;
    top: 0;
    width: 100px;
    grid-template-columns: 1fr;
    margin-top: 0;
}

.widgetry-product-gallery .thumbnail-item {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.widgetry-product-gallery .thumbnail-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.widgetry-product-gallery .thumbnail-item.active {
    border-color: #007cba;
    transform: scale(1.05);
}

.widgetry-product-gallery .thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Grid Layout */
.widgetry-product-gallery.gallery-grid .main-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.widgetry-product-gallery.gallery-grid .gallery-item {
    position: relative;
    opacity: 1;
    visibility: visible;
    height: 250px;
}

.widgetry-product-gallery.gallery-grid .gallery-nav {
    display: none;
}

/* Masonry Layout */
.widgetry-product-gallery.gallery-masonry .main-gallery {
    column-count: 3;
    column-gap: 15px;
}

.widgetry-product-gallery.gallery-masonry .gallery-item {
    position: relative;
    opacity: 1;
    visibility: visible;
    height: auto;
    break-inside: avoid;
    margin-bottom: 15px;
}

.widgetry-product-gallery.gallery-masonry .gallery-item img {
    height: auto;
}

.widgetry-product-gallery.gallery-masonry .gallery-nav {
    display: none;
}

/* Lightbox Styles */
.widgetry-product-gallery.lightbox-enabled .gallery-item {
    cursor: pointer;
}

.widgetry-product-gallery.lightbox-enabled .gallery-item:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .widgetry-product-gallery .gallery-item {
        height: 300px;
    }
    
    .widgetry-product-gallery .gallery-nav {
        width: 35px;
        height: 35px;
    }
    
    .widgetry-product-gallery .prev-nav {
        left: 10px;
    }
    
    .widgetry-product-gallery .next-nav {
        right: 10px;
    }
    
    .widgetry-product-gallery .thumbnails {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .widgetry-product-gallery .thumbnail-item {
        width: 60px;
        height: 60px;
    }
    
    .widgetry-product-gallery .thumbnails.position-left,
    .widgetry-product-gallery .thumbnails.position-right {
        position: static;
        width: 100%;
        grid-template-columns: repeat(4, 1fr);
        margin-top: 15px;
    }
    
    .widgetry-product-gallery.gallery-grid .main-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .widgetry-product-gallery.gallery-masonry .main-gallery {
        column-count: 2;
    }
}

@media (max-width: 480px) {
    .widgetry-product-gallery .gallery-item {
        height: 250px;
    }
    
    .widgetry-product-gallery .thumbnails {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .widgetry-product-gallery .thumbnail-item {
        width: 50px;
        height: 50px;
    }
    
    .widgetry-product-gallery.gallery-grid .main-gallery {
        grid-template-columns: 1fr;
    }
    
    .widgetry-product-gallery.gallery-masonry .main-gallery {
        column-count: 1;
    }
}

/* Loading State */
.widgetry-product-gallery .gallery-item img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.widgetry-product-gallery .gallery-item img.loaded {
    opacity: 1;
}

/* Smooth Transitions */
.widgetry-product-gallery .gallery-item {
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.widgetry-product-gallery .thumbnail-item {
    transition: all 0.3s ease;
}

/* Focus States for Accessibility */
.widgetry-product-gallery .gallery-nav:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.widgetry-product-gallery .thumbnail-item:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Animation for smooth gallery transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.widgetry-product-gallery .gallery-item.active {
    animation: fadeIn 0.5s ease;
}

/* Custom scrollbar for thumbnails if needed */
.widgetry-product-gallery .thumbnails::-webkit-scrollbar {
    height: 4px;
}

.widgetry-product-gallery .thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.widgetry-product-gallery .thumbnails::-webkit-scrollbar-thumb {
    background: #007cba;
    border-radius: 2px;
}

.widgetry-product-gallery .thumbnails::-webkit-scrollbar-thumb:hover {
    background: #005a87;
}

/* Error State */
.widgetry-product-gallery .gallery-item img[src=""] {
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.widgetry-product-gallery .gallery-item img[src=""]::after {
    content: 'No Image';
    color: #666;
    font-size: 14px;
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .widgetry-product-gallery .gallery-item img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
