/* OPTIMIZED PRODUCT GALLERY CSS */
/* Critical styles for immediate rendering */

/* Gallery Container */
.bb-product-gallery-wrapper {
    position: relative;
    width: 100%;
    min-height: 400px;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
}

.bb-product-gallery {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Main Image Container */
.bb-product-gallery-images {
    position: relative;
    width: 100%;
    height: 400px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.bb-product-gallery-images a {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.bb-product-gallery-images img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.bb-product-gallery-images img.loaded {
    opacity: 1;
}

/* Thumbnail Container */
.bb-product-gallery-thumbnails {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding: 0 4px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}

.bb-product-gallery-thumbnails::-webkit-scrollbar {
    height: 4px;
}

.bb-product-gallery-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.bb-product-gallery-thumbnails::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

.bb-product-gallery-thumbnails>div {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.bb-product-gallery-thumbnails>div.active {
    /* border-color: #007bff; */
}

.bb-product-gallery-thumbnails img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: opacity 0.2s ease;
    opacity: 0;
}

.bb-product-gallery-thumbnails img.loaded {
    opacity: 1;
}

/* Loading States */
.gallery-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Image Placeholder */
.image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

    100% {
        background-position: 200% 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .bb-product-gallery-images {
        height: 300px;
    }

    .bb-product-gallery-thumbnails>div {
        width: 50px;
        height: 50px;
    }
}

/* LightGallery Overrides - Minimal Styles */
.lg-backdrop {
    background-color: rgba(0, 0, 0, 0.9) !important;
}

.lg-toolbar {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

.lg-outer {
    z-index: 9999 !important;
}

/* Performance Optimizations */
.bb-product-gallery-images img {
    will-change: opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Critical Above-the-fold Styles */
.product-gallery-critical {
    position: relative;
    width: 100%;
    min-height: 400px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.product-gallery-critical .main-image {
    width: 100%;
    height: 400px;
    object-fit: cover;
    object-position: center;
    background: #fff;
}

/* Intersection Observer Support */
.gallery-observer {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-observer.visible {
    opacity: 1;
}