/**
 * Modern Product Gallery - Simple Static Implementation
 * 
 * Clean, simple gallery without any slider libraries
 * No width calculation issues - completely static approach
 * 
 * @package WooFood Modern Theme
 */

/* ====================================
   SIMPLE STATIC GALLERY - NO SLIDERS
   ==================================== */

/* Modern Gallery Container */
.modern-slick-gallery {
    width: 100%;
    max-width: 100%;
    margin-top: 20px;
    overflow: hidden;
    box-sizing: border-box;
}

/* Simple Main Gallery */
.simple-main-gallery {
    width: 100%;
    height: 600px;

    position: relative;
    overflow: hidden;
}

/* Gallery image containers - hide by default */
.modern-slick-gallery .simple-main-gallery .gallery-image,
.simple-main-gallery .gallery-image {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: none !important;
    /* Use display none for better browser compatibility */
    align-items: center !important;
    justify-content: center !important;
    z-index: 1 !important;
}

/* Show active image - use display flex */
.modern-slick-gallery .simple-main-gallery .gallery-image.active,
.simple-main-gallery .gallery-image.active {
    display: flex !important;
    z-index: 2 !important;
}

.simple-main-gallery .gallery-image img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

.simple-main-gallery .gallery-image img.zoomed {
    transform: scale(1.2);
    cursor: zoom-out;
}

/* Simple Thumbnails Gallery - Responsive */
.simple-thumbs-gallery {
    padding: 15px;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Responsive Thumbnails - Square aspect ratio maintained */
.simple-thumbs-gallery .gallery-thumb {
    flex-shrink: 0;
    width: 100px;
    /* Desktop default */
    height: 100px;
    min-width: 60px;
    /* Minimum size */
    min-height: 60px;
    max-width: 120px;
    /* Maximum size */
    max-height: 120px;
    cursor: pointer;
    border-radius: 8px;
    border: 3px solid transparent;
    opacity: 0.7;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    background: var(--foodmaster-modern-light, #fff);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.simple-thumbs-gallery .gallery-thumb:hover {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.simple-thumbs-gallery .gallery-thumb.active {
    opacity: 1;
    border-color: var(--foodmaster-modern-primary, #FFD700);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

/* Thumbnail images - responsive and maintain aspect ratio */
.simple-thumbs-gallery .gallery-thumb img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    object-fit: cover !important;
    border-radius: 6px;
    display: block !important;
}

/* Navigation Arrows - Simple Implementation */
.simple-main-gallery:before,
.simple-main-gallery:after {
    content: "";
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: none;
    /* Hidden for simplicity, can be enabled later */
}

.simple-main-gallery:before {
    left: 15px;
}

.simple-main-gallery:after {
    right: 15px;
}

/* Loading State */
.modern-slick-gallery.loading {
    position: relative;
    min-height: 400px;
}

.modern-slick-gallery.loading:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 215, 0, 0.3);
    border-top: 3px solid var(--foodmaster-modern-primary, #FFD700);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

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

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

/* Responsive Design - Tablet */
@media (max-width: 1024px) {
    .simple-main-gallery {
        height: 550px;
    }

    .simple-thumbs-gallery .gallery-thumb {
        width: 90px;
        height: 90px;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 768px) {
    .modern-slick-gallery {
        margin-top: 0;
    }

    .simple-main-gallery {
        height: 500px;
    }

    .simple-thumbs-gallery {
        padding: 12px;
        gap: 10px;
    }

    .simple-thumbs-gallery .gallery-thumb {
        width: 80px;
        height: 80px;
        min-width: 70px;
        min-height: 70px;
    }
}

/* Responsive Design - Small Mobile */
@media (max-width: 480px) {
    .simple-main-gallery {
        height: 400px;
    }

    .simple-thumbs-gallery {
        padding: 10px;
        gap: 8px;
    }

    .simple-thumbs-gallery .gallery-thumb {
        width: 70px;
        height: 70px;
        min-width: 60px;
        min-height: 60px;
    }
}

/* Responsive Design - Very Small Mobile */
@media (max-width: 375px) {
    .simple-main-gallery {
        height: 350px;
    }

    .simple-thumbs-gallery .gallery-thumb {
        width: 60px;
        height: 60px;
        min-width: 50px;
        min-height: 50px;
    }
}

/* Ensure proper spacing in product layout */
@media (min-width: 769px) {
    .modern-single-product .modern-slick-gallery {
        margin-top: 0;
    }
}

/* Sale Badge Positioning */
.modern-slick-gallery .onsale,
.modern-slick-gallery .modern-sale-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: var(--foodmaster-modern-primary, #FFD700);
    color: var(--foodmaster-modern-dark, #000);
    padding: 6px 12px;
    border-radius: 15px;
    font-weight: 600;
    font-size: 12px;
    z-index: 10;
    border: none;
    min-width: auto;
    min-height: auto;
    line-height: 1.2;
}

/* Hide all Slick-related styling - Clean Slate */
.modern-slick-gallery .slick-slider,
.modern-slick-gallery .slick-list,
.modern-slick-gallery .slick-track,
.modern-slick-gallery .slick-slide,
.modern-slick-gallery .slick-prev,
.modern-slick-gallery .slick-next,
.modern-slick-gallery .slick-dots {
    display: none !important;
}

/* Remove any leftover Slick CSS that might interfere */
.modern-main-slider,
.modern-thumbs-slider {
    display: none !important;
}



/* Smooth thumbnail scrolling */
.simple-thumbs-gallery {
    scrollbar-width: thin;
    scrollbar-color: var(--foodmaster-modern-primary, #FFD700) #f9fafb;
}

.simple-thumbs-gallery::-webkit-scrollbar {
    height: 6px;
}

.simple-thumbs-gallery::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 3px;
}

.simple-thumbs-gallery::-webkit-scrollbar-thumb {
    background: var(--foodmaster-modern-primary, #FFD700);
    border-radius: 3px;
}

.simple-thumbs-gallery::-webkit-scrollbar-thumb:hover {
    background: var(--foodmaster-modern-secondary, #FFC107);
}

/* Additional Responsive Fixes for Product Page Layout */
.modern-product-gallery-column {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.modern-product-gallery-column .modern-slick-gallery {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Critical fix: Only constrain max-width, don't force width */
.modern-product-gallery-column img {
    max-width: 100% !important;
    height: auto !important;
    width: auto !important;
    display: block !important;
    box-sizing: border-box !important;
}

/* Ensure proper image sizing within gallery */
.modern-slick-gallery img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Comprehensive gallery column image fix - highest specificity */
.modern-product-gallery-column .modern-slick-gallery img,
.modern-product-gallery-column .simple-main-gallery img,
.modern-product-gallery-column .woocommerce-product-gallery img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

/* Prevent horizontal overflow */
.modern-product-layout {
    overflow: hidden;
    box-sizing: border-box;
}

.modern-product-layout>* {
    box-sizing: border-box;
    min-width: 0;
}

/* CRITICAL: Force responsive images - Highest priority override */
.modern-product-gallery-column img,
div.modern-product-gallery-column img,
.modern-product-gallery-column .modern-slick-gallery img,
.modern-product-gallery-column .simple-main-gallery .gallery-image img,
div.product .modern-product-gallery-column img,
.woocommerce div.product .modern-product-gallery-column img,
.modern-product-layout .modern-product-gallery-column img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* Mobile-specific fixes */
@media (max-width: 767px) {

    .modern-product-gallery-column,
    .modern-product-details-column {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
}

/* ================================================================
   FINAL OVERRIDE: Maximum Specificity Image Responsive Fix
   This MUST be the last rule to override all other styles
   ================================================================ */
.woocommerce div.product div.modern-product-gallery-column img,
.woocommerce div.product .modern-product-layout .modern-product-gallery-column img,
div.product.modern-single-product .modern-product-gallery-column img,
.modern-product-layout .modern-product-gallery-column .modern-slick-gallery .simple-main-gallery .gallery-image img,
.modern-product-gallery-column .woocommerce-product-gallery img,
.modern-product-gallery-column .woocommerce-product-gallery .woocommerce-product-gallery__wrapper img,
.modern-product-gallery-column .woocommerce-product-gallery .woocommerce-product-gallery__image img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}