/**
 * Product Gallery Styles - Swiper & Lightbox
 * Optimized for performance and LCP
 */

/* Gallery Container */
.hightech-product-gallery-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.hightech-gallery-container {
    display: flex;
    flex-direction: row; /* Mobile: thumbnails on right */
    gap: 10px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

@media (max-width: 1300px) and (min-width: 850px) {
    .hightech-gallery-container {
        margin-bottom: 20px;
    }
}


@media (min-width: 850px) {
    .hightech-gallery-container {
        flex-direction: row;
        gap: 20px;
    }
}

/* Thumbnail Navigation */
.hightech-gallery-thumbs {
    order: 2; /* Mobile: on right side */
    flex-shrink: 0;
    width: 60px; /* Mobile: smaller width */
    max-height: 340px; /* Mobile: limit height */
    overflow: hidden; /* Clip without scrollbar */
}

@media (min-width: 850px) {
    .hightech-gallery-thumbs {
        order: 1;
        width: 80px; /* Desktop: smaller width */
        max-height: 500px; /* Limit height on desktop */
        overflow: hidden; /* Clip without scrollbar */
        display: flex;
        flex-direction: column;
    }
}

.hightech-thumbs-swiper {
    width: 100%;
    height: auto;
    max-height: 340px; /* Mobile: limit height */
    overflow: hidden; /* Clip without scrollbar */
}

@media (min-width: 850px) {
    .hightech-thumbs-swiper {
        height: 100%;
        max-height: 500px; /* Limit height on desktop */
        overflow: hidden; /* Clip without scrollbar */
    }
    
    .hightech-thumbs-swiper .swiper-wrapper {
        max-height: none;
    }
}

.hightech-thumbs-swiper .swiper-wrapper {
    display: flex;
    flex-direction: column; /* Mobile: vertical (right side) */
    gap: 0px;
}

@media (min-width: 850px) {
    .hightech-thumbs-swiper .swiper-wrapper {
        flex-direction: column;
        gap: 0px;
        height: auto; /* Allow wrapper to grow with content */
    }
}

.hightech-thumb-slide {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
    width: 60px; /* Mobile: smaller size */
    height: 60px; /* Mobile: smaller size */
    min-height: 60px;
    max-height: 60px;
}

@media (min-width: 850px) {
    .hightech-thumb-slide {
        width: 80px; /* Desktop: smaller size */
        height: 80px; /* Desktop: smaller size */
        min-height: 80px;
        max-height: 80px;
    }
}

.hightech-thumb-slide:hover {
    opacity: 1;
}

.hightech-thumb-slide.active {
    opacity: 1;
    border-color: #333;
}

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

@media (min-width: 850px) {
    .hightech-thumb-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* Main Gallery Slider */
.hightech-gallery-main {
    order: 1; /* Mobile: on left, Desktop: on right */
    flex: 1;
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0; /* Important for flexbox to respect max-width */
    overflow: hidden;
}

@media (min-width: 850px) {
    .hightech-gallery-main {
        order: 2;
    }
}

.hightech-main-swiper {
    width: 100%;
    max-width: 100%;
    position: relative;
    overflow: hidden;
}

.hightech-main-swiper .swiper-wrapper {
    align-items: stretch;
    width: 100%;
    max-width: 100%;
}

.hightech-main-swiper .swiper-slide {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.hightech-main-slide {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 340px; /* Mobile: 400px reduced by 15% */
    overflow: hidden;
}

@media (min-width: 850px) {
    .hightech-main-slide {
        min-height: 500px;
    }
}

.hightech-main-slide a {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-height: inherit;
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
    /* Ensure content doesn't overflow */
    contain: layout style paint;
}

@media (min-width: 850px) {
    .hightech-main-slide a {
        padding: 30px;
    }
}

.hightech-main-img {
    width: auto;
    height: auto;
    max-width: 100% !important;
    max-height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    /* Ensure image never exceeds container */
    box-sizing: border-box;
    /* Prevent any overflow */
    overflow: hidden;
}

/* Lightbox Icon */
.hightech-lightbox-icon {
    position: absolute;
    bottom: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
    pointer-events: none;
}

.hightech-main-slide:hover .hightech-lightbox-icon {
    opacity: 1;
}

.hightech-lightbox-icon svg {
    width: 20px;
    height: 20px;
    color: #333;
}

/* Navigation Arrows */
.hightech-gallery-next,
.hightech-gallery-prev {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    color: #333;
    margin-top: 0;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hightech-gallery-next {
    right: 15px;
}

.hightech-gallery-prev {
    left: 15px;
}

.hightech-main-swiper:hover .hightech-gallery-next,
.hightech-main-swiper:hover .hightech-gallery-prev {
    opacity: 1;
}

.hightech-gallery-next::after,
.hightech-gallery-prev::after {
    font-size: 18px;
    font-weight: bold;
}

.hightech-gallery-next.swiper-button-disabled,
.hightech-gallery-prev.swiper-button-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mobile Optimizations */
@media (max-width: 849px) {
    .hightech-gallery-thumbs {
        width: 60px; /* Smaller width on mobile */
        max-height: 340px; /* Limit height */
        overflow: hidden; /* Clip without scrollbar */
    }
    
    .hightech-thumbs-swiper {
        height: 100%;
        max-height: 340px; /* Limit height */
        overflow: hidden; /* Clip without scrollbar */
    }

    .hightech-thumbs-swiper .swiper-wrapper {
        flex-direction: column; /* Vertical on mobile (right side) */
    }

    .hightech-lightbox-icon {
        opacity: 1; /* Always visible on mobile */
        bottom: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }

    .hightech-lightbox-icon svg {
        width: 18px;
        height: 18px;
    }

    .hightech-gallery-next,
    .hightech-gallery-prev {
        opacity: 0.7; /* More visible on mobile */
        width: 36px;
        height: 36px;
    }

    .hightech-gallery-next::after,
    .hightech-gallery-prev::after {
        font-size: 16px;
    }
}

/* Ensure Swiper slides have proper height */
.hightech-main-swiper .swiper-slide {
    height: auto;
}

/* Ensure images don't cause layout shift */
.hightech-main-img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

.hightech-main-img[loading="lazy"].loaded {
    opacity: 1;
}

/* Lightbox Overrides */
.glightbox-clean .gslide-media {
    background: transparent;
}

/* Hide lightbox text/description */
.glightbox-clean .gslide-description,
.glightbox-clean .gslide-title,
.glightbox .gslide-description,
.glightbox .gslide-title {
    display: none !important;
}

/* Ensure lightbox overlay/backdrop is clickable to close */
.goverlay {
    cursor: pointer !important;
}

/* Hide Flatsome's zoom button (we use custom lightbox icons instead) */
.hightech-product-gallery-wrapper .image-tools .zoom-button {
    display: none !important;
}
