/* ========================================
   MODERN PRODUCT GALLERY - RESPONSIVE & MOBILE FRIENDLY
   ======================================== */

:root {
    --gallery-primary: #007bff;
    --gallery-border: #e0e0e0;
    --gallery-bg: #ffffff;
    --gallery-hover: #f8f9fa;
    --gallery-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===== DESKTOP GALLERY (768px and above) ===== */
@media (min-width: 768px) {
    .product-img-section-md {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Remove row gaps */
    .product-img-section-md.row {
        margin: 0 !important;
    }

    .product-img-section-md > .row {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Column spacing for thumbnails and main image */
    .product-img-section-md .col-md-10 {
        padding-left: 10px !important;
        padding-right: 0 !important;
    }

    .product-img-section-md .col-md-2 {
        padding-left: 0 !important;
        padding-right: 10px !important;
    }

    /* Main image container - fill the space */
    .mySwiper-preview.gallery-top-1 {
        height: 550px !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
        background: var(--gallery-bg);
        position: relative;
    }

    /* Main image slides */
    .mySwiper-preview .swiper-slide,
    .mySwiper-preview .product-swiper-slide {
        height: 550px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: var(--gallery-bg);
        padding: 20px;
        position: relative;
        overflow: hidden;
    }

    /* Product images with smooth scaling */
    .mySwiper-preview .swiper-slide img,
    .mySwiper-preview .product-swiper-slide img {
        width: auto !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
        object-position: center !important;
        border-radius: 8px;
        transition: transform 0.3s ease;
        display: block;
    }

    /* Image hover effect */
    .mySwiper-preview .swiper-slide img:hover {
        cursor: pointer;
    }

    /* Thumbnail container */
    .image-Thumbnail-container {
        padding: 0 !important;
        margin: 0 !important;
        height: 550px;
        max-width: 100px;
    }

    /* Thumbnail swiper - vertical scroll */
    .mySwiper-thumb.gallery-thumbs-1 {
        height: 550px !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Thumbnail wrapper */
    .mySwiper-thumb .swiper-wrapper {
        gap: 8px !important;
        padding: 0;
    }

    /* Individual thumbnail slides */
    .mySwiper-thumb .swiper-slide,
    .mySwiper-thumb .product-swiper-slide {
        width: 80px !important;
        height: 80px !important;
        opacity: 0.5 !important;
        border: 2px solid var(--gallery-border);
        border-radius: 8px;
        background: var(--gallery-bg);
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
        padding: 4px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        flex-shrink: 0;
        display: block !important;
        visibility: visible !important;
    }

    /* Thumbnail images */
    .mySwiper-thumb .swiper-slide img,
    .mySwiper-thumb .product-swiper-slide img {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        object-position: center !important;
        border-radius: 4px;
        transition: transform 0.3s ease;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Active thumbnail */
    .mySwiper-thumb .swiper-slide-thumb-active {
        opacity: 1 !important;
        border-color: var(--gallery-primary) !important;
        box-shadow: 0 0 0 2px var(--gallery-primary), 0 4px 8px rgba(0, 123, 255, 0.2);
        transform: scale(1.05);
    }

    /* Thumbnail hover effect */
    .mySwiper-thumb .swiper-slide:hover {
        opacity: 0.85 !important;
        border-color: #999;
        transform: scale(1.03);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    }

    .mySwiper-thumb .swiper-slide:hover img {
        transform: scale(1.1);
    }

    /* Navigation buttons - modern style */
    .mySwiper-preview .swiper-button-next,
    .mySwiper-preview .swiper-button-prev {
        background: rgba(255, 255, 255, 0.95) !important;
        color: #333 !important;
        width: 44px !important;
        height: 44px !important;
        border-radius: 50% !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
        transition: all 0.3s ease;
        opacity: 0;
    }

    .mySwiper-preview:hover .swiper-button-next,
    .mySwiper-preview:hover .swiper-button-prev {
        opacity: 1;
    }

    .mySwiper-preview .swiper-button-next:hover,
    .mySwiper-preview .swiper-button-prev:hover {
        background: var(--gallery-primary) !important;
        color: white !important;
        transform: scale(1.1);
    }

    .mySwiper-preview .swiper-button-next::after,
    .mySwiper-preview .swiper-button-prev::after {
        font-size: 18px !important;
        font-weight: 700 !important;
    }

    /* Fullscreen button */
    .gallery-fullscreen-btn {
        position: absolute;
        top: 15px;
        right: 15px;
        z-index: 10;
        background: rgba(255, 255, 255, 0.95);
        border: none;
        border-radius: 8px;
        padding: 10px 14px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        transition: all 0.3s ease;
    }

    .gallery-fullscreen-btn:hover {
        background: var(--gallery-primary);
        color: white;
        transform: scale(1.05);
    }

    .gallery-fullscreen-btn i {
        font-size: 18px;
    }
}

/* ===== MOBILE GALLERY (767px and below) ===== */
@media (max-width: 767px) {
    /* Reset container padding */
    .container.py-4 {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Remove padding from Product Detail card on mobile */
    .Product-Detail-card {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Ensure section container has no padding */
    section.container {
        padding: 0 !important;
    }

    /* Mobile swiper - full width and height */
    .mySwiper {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 85vh !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0;
        overflow: hidden !important;
        position: relative;
    }

    .mySwiper .swiper-wrapper {
        height: 100% !important;
    }

    /* Mobile slides - full screen */
    .mySwiper .swiper-slide {
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #ffffff;
        border-radius: 0;
        overflow: hidden;
    }

    /* Mobile product images - responsive full view */
    .mySwiper .swiper-slide img {
        width: 100% !important;
        height: 100% !important;
        max-width: 100vw !important;
        max-height: 100% !important;
        object-fit: contain !important;
        object-position: center !important;
        background: #ffffff;
        border-radius: 0;
        display: block;
        margin: 0;
    }

    /* Center slide alignment */
    .mySwiper .center-swiper-slide {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Mobile pagination - modern dots */
    .mySwiper .swiper-pagination {
        position: absolute !important;
        bottom: 20px !important;
        left: 0 !important;
        right: 0 !important;
        text-align: center !important;
        z-index: 10;
    }

    .mySwiper .swiper-pagination-bullet {
        width: 8px !important;
        height: 8px !important;
        background: #d1d5db !important;
        opacity: 1 !important;
        margin: 0 5px !important;
        transition: all 0.3s ease !important;
    }

    .mySwiper .swiper-pagination-bullet-active {
        background: var(--gallery-primary) !important;
        width: 24px !important;
        border-radius: 4px !important;
        transform: scale(1.1);
    }

    /* Touch-friendly zoom indicator */
    .mobile-zoom-hint {
        position: absolute;
        bottom: 20px;
        right: 20px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 8px 12px;
        border-radius: 20px;
        font-size: 12px;
        z-index: 10;
        display: flex;
        align-items: center;
        gap: 6px;
        animation: fadeIn 0.5s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

/* ===== VIDEO ELEMENTS ===== */
.swiper-slide video,
.swiper-slide iframe {
    width: 100% !important;
    height: auto !important;
    max-height: 100% !important;
    object-fit: contain !important;
    border-radius: 8px !important;
}

.swiper-slide iframe {
    aspect-ratio: 16 / 9;
}

/* ===== IMAGE ASPECT RATIO FIX ===== */
.swiper-slide img {
    aspect-ratio: auto !important;
}

/* Fix for lazy-loaded images */
.swiper-slide img.lazy,
.swiper-slide img[data-src] {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}

/* ===== LOADING STATE ===== */
.swiper-slide img:not([src]),
.swiper-slide img[src=""] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== LARGER DESKTOP SCREENS (1200px+) ===== */
@media (min-width: 1200px) {
    .mySwiper-preview.gallery-top-1 {
        height: 650px !important;
    }

    .mySwiper-preview .swiper-slide,
    .mySwiper-preview .product-swiper-slide {
        height: 650px !important;
        padding: 25px;
    }

    .image-Thumbnail-container {
        height: 650px !important;
    }

    .mySwiper-thumb.gallery-thumbs-1 {
        height: 650px !important;
    }
}

/* ===== TABLET LANDSCAPE (768px - 1024px) ===== */
@media (min-width: 768px) and (max-width: 1024px) {
    .mySwiper-preview.gallery-top-1 {
        height: 450px !important;
    }

    .mySwiper-preview .swiper-slide,
    .mySwiper-preview .product-swiper-slide {
        height: 450px !important;
        padding: 15px;
    }

    .image-Thumbnail-container {
        height: 450px !important;
    }

    .mySwiper-thumb.gallery-thumbs-1 {
        height: 450px !important;
    }
}

/* ===== MOBILE LANDSCAPE ===== */
@media (max-width: 767px) and (orientation: landscape) {
    .mySwiper {
        height: 100vh !important;
        max-height: 100vh !important;
    }

    .mySwiper .swiper-slide {
        height: 100% !important;
    }
    
    .mySwiper .swiper-slide img {
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
    }
}

/* ===== SMALL MOBILE (320px - 480px) ===== */
@media (max-width: 480px) {
    .mySwiper {
        height: 100vh !important;
        max-height: 85vh !important;
    }

    .mySwiper .swiper-slide {
        height: 100% !important;
        padding: 0 !important;
    }

    .mySwiper .swiper-slide img {
        width: 100% !important;
        height: 100% !important;
    }
}

/* ===== ACCESSIBILITY ===== */
.swiper-button-next:focus,
.swiper-button-prev:focus,
.gallery-fullscreen-btn:focus {
    outline: 2px solid var(--gallery-primary);
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .swiper-slide img,
    .mySwiper-thumb .swiper-slide,
    .swiper-button-next,
    .swiper-button-prev {
        transition: none !important;
        animation: none !important;
    }
}

/* ===== LIGHTBOX MODAL ===== */
.product-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.product-lightbox.active {
    display: flex !important;
}

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

.lightbox-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10000;
    transition: all 0.3s ease;
}

.lightbox-close:hover {
    background: white;
    transform: rotate(90deg) scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lightbox-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.swiper-slide img {
    will-change: transform;
}

.mySwiper-thumb .swiper-slide {
    will-change: opacity, border-color;
}

/* ===== CRITICAL IMAGE DISPLAY FIXES ===== */
/* Ensure images always display at proper size */
.gallery-top-1 img,
.gallery-thumbs-1 img,
.mySwiper img {
    min-width: 50px !important;
    min-height: 50px !important;
}

/* Fix for images that appear too small */
.product-swiper-slide img,
.swiper-slide.center-swiper-slide img {
    flex-shrink: 0;
}

/* ===== DISABLE XZOOM MAGNIFIER COMPLETELY ===== */
/* Nuclear option - hide all xZoom elements with maximum specificity */
.xzoom-container,
.xzoom-preview,
.xzoom-lens,
.xzoom-loading,
.xzoom-source,
.xzoom-hidden,
div.xzoom-container,
div.xzoom-preview,
div.xzoom-lens,
div.xzoom-loading,
body .xzoom-container,
body .xzoom-preview,
body .xzoom-lens,
body .xzoom-loading,
html body .xzoom-container,
html body .xzoom-preview {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: fixed !important;
    left: -99999px !important;
    top: -99999px !important;
    width: 0 !important;
    height: 0 !important;
    z-index: -9999 !important;
}

/* Disable xZoom on images */
img.xzoom,
img.xzoom2,
img.xzoom3,
img.xzoom4,
img.xzoom5,
.zoom_03 {
    cursor: pointer !important;
}

/* Keep thumbnail images visible */
.xzoom-thumbs img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Re-enable normal swiper images */
.swiper-slide img {
    display: block !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force disable xZoom on all images - highest priority */
img.xzoom:hover,
img.zoom_03:hover,
.xzoom:hover {
    cursor: pointer !important;
}

/* Prevent xZoom preview on any element */
*[class*="xzoom"] {
    position: relative !important;
}

*[class*="xzoom"]::before,
*[class*="xzoom"]::after {
    display: none !important;
}

/* Ensure container doesn't restrict image size */
.swiper-slide,
.product-swiper-slide {
    box-sizing: border-box !important;
}

/* Fix for clipped/cropped images */
.swiper-wrapper {
    align-items: center !important;
}

/* Mobile specific image fixes */
@media (max-width: 767px) {
    .mySwiper .swiper-slide {
        align-items: center !important;
        justify-content: center !important;
    }
    
    .mySwiper .swiper-slide img {
        min-width: auto !important;
        min-height: 100% !important;
    }

    /* Remove any row/col gaps on mobile image section */
    .d-sm-block.d-lg-none {
        padding: 0 !important;
        margin: 0 !important;
    }

    .d-sm-block.d-lg-none.row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}
