/* Lightweight Product Gallery CSS */
/* Optimized for 512MB RAM servers */

.product-gallery-container {
    display: flex;
    flex-direction: column;
    gap: 0px;
    max-width: 100%;
}

.gallery-main {
    width: 100%;
    max-width: 600px;
    margin-bottom: 0px;
    position: relative;
    padding-bottom: 0px; /* Space for pagination */
}

.gallery-thumbs {
    width: 100%;
    height: 120px;
    flex-shrink: 0;
}

.gallery-main .swiper-slide {
    position: relative;
    background: #f8f8f8;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.gallery-main .swiper-slide .zoom {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gallery-main .swiper-slide img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
}

.gallery-thumbs .swiper-slide {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.gallery-thumbs .swiper-slide-thumb-active {
    opacity: 1;
    /* border: 2px solid #333; */
}

.gallery-thumbs .swiper-slide img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

/* Navigation buttons */
.swiper-button-next,
.swiper-button-prev {
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.swiper-button-next::after,
.swiper-button-prev::after {
    font-size: 16px;
    font-weight: bold;
}

/* Pagination */
.swiper-pagination {
    bottom: 15px !important;
    left: 0 !important;
    right: 0 !important;
    text-align: center !important;
    position: absolute !important;
    z-index: 10;
}

.swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.7);
    opacity: 1;
    margin: 0 4px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.swiper-pagination-bullet:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.2);
}

.swiper-pagination-bullet-active {
    background: #333 !important;
    transform: scale(1.3);
}

/* Zoom/Expand button */
.wpgis-popup {
    position: absolute;
    top: 15px;
    right: 15px;
    color: white;
    background: transparent;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s ease;
    z-index: 10;
}

.wpgis-popup:hover {
    transform: scale(1.1);
}

/* Lighthouse Lightbox */
.lightweight-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image-container {
    position: relative;
    overflow: hidden;
    max-width: 90vw;
    max-height: 90vh;
    cursor: grab;
}

.lightbox-image-container:active {
    cursor: grabbing;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center;
    transition: transform 0.2s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox-close {
    position: absolute;
    top: -15px;
    right: -15px;
    background: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.lightbox-controls {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 25px;
}

.lightbox-controls button {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.lightbox-controls button:hover {
    background: white;
    transform: scale(1.1);
}

.zoom-reset {
    font-size: 12px !important;
    width: 50px !important;
    border-radius: 20px !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .product-gallery-container {
        flex-direction: column;
    }
    
    .gallery-main {
        order: 1;
        max-width: 100%;
    }
    
    .gallery-thumbs {
        order: 2;
        width: 100%;
        height: 100px;
        margin-top: 15px;
    }
    
    .gallery-thumbs .swiper-slide img {
        height: 60px;
    }
    
    /* Hide navigation on mobile */
    .swiper-button-next,
    .swiper-button-prev {
        display: none;
    }
}

/* RTL Support */
[dir="rtl"] .gallery-thumbs {
    direction: rtl;
}

/* Lazy loading placeholder */
.swiper-lazy-preloader {
    width: 42px;
    height: 42px;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -21px;
    margin-top: -21px;
    z-index: 10;
    transform-origin: 50%;
    animation: swiper-preloader-spin 1s infinite linear;
    box-sizing: border-box;
    border: 4px solid #ddd;
    border-radius: 50%;
    border-top: 4px solid #333;
}

@keyframes swiper-preloader-spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Performance optimizations */
.gallery-main,
.gallery-thumbs {
    will-change: transform;
    transform: translateZ(0);
}

.swiper-slide {
    backface-visibility: hidden;
}