/* Hartman Gallery Styles */

.hg-gallery-wrapper {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 100%;
    position: relative;
    align-items: flex-start;
}

/* Custom thumbnails container */
.hg-thumbnails {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: auto;
    margin-right: 15px;
    gap: 10px;
    overflow-y: auto; /* Enable scrolling but hide scrollbar */
    overflow-x: hidden;
    max-height: 500px; /* Default max-height, will be overridden by JS */
    padding: 2px; /* Small padding to prevent scrollbar from cutting off thumbnails */
    box-sizing: content-box;
    scroll-behavior: smooth; /* Smooth scrolling when programmatically scrolled */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.hg-thumbnails::-webkit-scrollbar {
    display: none;
}

/* Main WooCommerce gallery container */
.hg-main-gallery {
    flex: 1;
    position: relative;
    width: 100%;
    min-width: 0; /* Prevents flex item from overflowing */
}

/* Hide the default WooCommerce thumbnails since we're using our own */
.hg-main-gallery .flex-control-thumbs {
    display: none !important;
}

/* Make sure the main gallery image takes full width */
.hg-main-gallery .woocommerce-product-gallery__wrapper {
    width: 100%;
}

.hg-main-gallery .woocommerce-product-gallery__image {
    width: 100%;
}

.hg-main-gallery .woocommerce-product-gallery__image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Thumbnail images */
.hg-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.7;
    border-radius: 4px;
    flex-shrink: 0; /* Prevent thumbnails from being compressed */
    display: block;
}

/* Ensure animated GIFs in thumbnails are not lazy loaded */
.hg-thumbnail.is-animated-gif {
    image-rendering: auto;
    will-change: auto;
}

/* Disable zoom cursor for animated GIFs */
.woocommerce-product-gallery__image.is-animated-gif img {
    cursor: default !important;
}

.hg-thumbnail:hover {
    opacity: 1;
    transform: scale(1.05);
}

.hg-thumbnail.active {
    border-color: #333;
    opacity: 1;
}

/* Responsive design - Only apply mobile styles on very small screens */
@media (max-width: 600px) {
    .hg-gallery-wrapper {
        flex-direction: column;
    }
    
    .hg-thumbnails {
        flex-direction: row;
        width: 100%;
        margin: 0 0 15px 0;
        max-height: none;
        overflow-x: auto; /* Enable horizontal scrolling */
        overflow-y: hidden;
        justify-content: flex-start;
        flex-wrap: nowrap;
        padding: 2px;
        scroll-behavior: smooth;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE and Edge */
    }
    
    /* Hide horizontal scrollbar for mobile */
    .hg-thumbnails::-webkit-scrollbar {
        display: none;
    }
    
    .hg-thumbnail {
        width: 60px;
        height: 60px;
        margin-right: 10px;
    }
    
    .hg-thumbnail:last-child {
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .hg-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .hg-thumbnails {
        gap: 8px;
        margin-bottom: 10px;
    }
}

/* Loading state */
.hg-main-gallery.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 999;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.woocommerce-product-gallery__trigger {
    z-index: 10 !important; /* Fix magnifying glass appearing infront of header */
}

.pswp__caption {
    display: none !important; /* Hide image title in lightbox */
}