/* FSLightbox Integration for IYH Theme */

/* Enhanced Product Gallery Styling */
.woocommerce-product-gallery {
    position: relative;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.woocommerce-product-gallery .woocommerce-product-gallery__image img {
    width: 100%;
    height: auto;
    transition: transform 0.3s ease;
    border-radius: 8px;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:hover img {
    transform: scale(1.05);
}

/* Zoom indicator overlay */
.woocommerce-product-gallery .woocommerce-product-gallery__image::after {
    content: '🔍';
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 50%;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:hover::after {
    opacity: 1;
}

/* Lightbox trigger icon - only show on main image */
.woocommerce-product-gallery .woocommerce-product-gallery__image:first-child .lightbox-trigger {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 50%;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:first-child:hover .lightbox-trigger {
    opacity: 1;
    transform: scale(1.1);
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:first-child .lightbox-trigger:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.2);
}

/* Hide the old ::after zoom indicator on main image since we have the trigger */
.woocommerce-product-gallery .woocommerce-product-gallery__image:first-child::after {
    display: none;
}

/* Thumbnail styling */
.woocommerce-product-gallery .woocommerce-product-gallery__image:not(:first-child) {
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.3s ease, transform 0.3s ease;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:not(:first-child):hover {
    border-color: #3498db;
    transform: scale(1.05);
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:not(:first-child).active {
    border-color: #e74c3c;
    transform: scale(1.02);
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:not(:first-child).active::after {
    display: none;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:hover::after {
    opacity: 1;
}

/* Show hover effect only on thumbnails, not main image */
.woocommerce-product-gallery .woocommerce-product-gallery__image:not(:first-child):hover::after {
    opacity: 1;
}

/* Main product image styling */
.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:first-child {
    margin-bottom: 15px;
}

/* Thumbnail grid styling */
.woocommerce-product-gallery__wrapper {
    display: grid;
    gap: 10px;
}

.woocommerce-product-gallery.woocommerce-product-gallery--columns-4 .woocommerce-product-gallery__wrapper {
    grid-template-columns: repeat(4, 1fr);
}

.woocommerce-product-gallery.woocommerce-product-gallery--columns-3 .woocommerce-product-gallery__wrapper {
    grid-template-columns: repeat(3, 1fr);
}

.woocommerce-product-gallery.woocommerce-product-gallery--columns-2 .woocommerce-product-gallery__wrapper {
    grid-template-columns: repeat(2, 1fr);
}

/* Main image spans full width when thumbnails are present */
.woocommerce-product-gallery.woocommerce-product-gallery--with-images .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:first-child {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 15px;
}

/* FSLightbox Custom Styling */
.fslightbox-container {
    background: rgba(0, 0, 0, 0.95) !important;
}

.fslightbox-nav {
    width:100% !important;
}

.fslightbox-toolbar {
    background: transparent !important;
}

.fslightbox-toolbar-button {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 50% !important;
    width: 50px !important;
    height: 50px !important;
    backdrop-filter: blur(10px) !important;
    transition: all 0.3s ease !important;
}

.fslightbox-toolbar-button:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
    transform: scale(1.1) !important;
}

.fslightbox-slide-number-container {
    background: rgba(0, 0, 0, 0.5) !important;
    border-radius: 20px !important;
    padding: 8px 16px !important;
    backdrop-filter: blur(10px) !important;
    color: white !important;
    font-size: 14px !important;
}

/* Enhanced loading animation */
.fslightbox-loader {
    border: 3px solid rgba(255, 255, 255, 0.3) !important;
    border-top: 3px solid #3498db !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    animation: fslightbox-spin 1s linear infinite !important;
}

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

/* Mobile responsiveness */
@media (max-width: 768px) {
    .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .woocommerce-product-gallery.woocommerce-product-gallery--with-images .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:first-child {
        grid-column: 1 / -1;
        grid-row: 1;
    }
    
    .woocommerce-product-gallery .woocommerce-product-gallery__image::after {
        top: 10px;
        right: 10px;
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px;
    }
    
    .fslightbox-slide-number-container {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }
}

/* Smooth gallery initialization */
.woocommerce-product-gallery {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.woocommerce-product-gallery.fslightbox-initialized {
    opacity: 1;
}

/* Image aspect ratio consistency */
.woocommerce-product-gallery .woocommerce-product-gallery__image img {
    aspect-ratio: 4/3;
    object-fit: cover;
    width: 100%;
}

.woocommerce-product-gallery .woocommerce-product-gallery__image:first-child img {
    aspect-ratio: 16/9;
}

/* Loading state for images */
.woocommerce-product-gallery .woocommerce-product-gallery__image.loading {
    position: relative;
    pointer-events: none; /* Prevent multiple clicks during loading */
}

.woocommerce-product-gallery .woocommerce-product-gallery__image.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: fslightbox-spin 1s linear infinite;
    z-index: 3;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Ensure loading state is removed when lightbox is active */
.fslightbox-container ~ * .woocommerce-product-gallery__image.loading,
body.fslightbox-open .woocommerce-product-gallery__image.loading {
    pointer-events: auto;
}

body.fslightbox-open .woocommerce-product-gallery__image.loading::before {
    display: none;
}

/* Accessibility improvements */
.woocommerce-product-gallery .woocommerce-product-gallery__image a:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
    border-radius: 8px;
}

/* Print styles */
@media print {
    .woocommerce-product-gallery .woocommerce-product-gallery__image::after {
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .woocommerce-product-gallery .woocommerce-product-gallery__image::after {
        background: black;
        color: white;
        border: 2px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .woocommerce-product-gallery .woocommerce-product-gallery__image,
    .woocommerce-product-gallery .woocommerce-product-gallery__image img,
    .woocommerce-product-gallery .woocommerce-product-gallery__image::after {
        transition: none;
    }
    
    .woocommerce-product-gallery .woocommerce-product-gallery__image:hover {
        transform: none;
    }
    
    .woocommerce-product-gallery .woocommerce-product-gallery__image:hover img {
        transform: none;
    }
}

.woocommerce div.product div.images {
    float: none;
    width: 100% ;
}

.woocommerce div.product div.images .woocommerce-product-gallery__image:nth-child(n+2) {
    width: 100%;
}