/**
 * RNS Product Gallery Styles
 * Mobile-first responsive design with fixed height on desktop
 * 
 * @package RNS\Assets\CSS
 * @since 1.0.0
 */

/* ============================================================================
   CONTAINER STYLES
   ============================================================================ */

.rns-product-gallery-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    font-family: inherit;
}

/* ============================================================================
   MAIN SWIPER STYLES - Mobile First (Responsive Height)
   ============================================================================ */

.main-product-swiper {
    width: 100%;
    height: auto; /* Responsive height for mobile */
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
    position: relative;
}

/* Desktop and Tablet - Fixed Height */
@media (min-width: 768px) {
    .main-product-swiper {
        height: 500px; /* Fixed height for larger screens */
    }
}

/* Large screens get even more height */
@media (min-width: 1200px) {
    .main-product-swiper {
        height: 600px;
    }
}

/* ============================================================================
   MAIN SWIPER SLIDE STYLES
   ============================================================================ */

.main-product-swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    height: 100%;
    padding: 8px;
}

/* Main Gallery Images */
.main-product-swiper .rns-main-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Prevent distortion, maintain aspect ratio */
    object-position: center;
    max-width: 100%;
    max-height: 100%;
    transition: opacity 0.3s ease;
}

/* Mobile specific adjustments for main image */
@media (max-width: 767px) {
    .main-product-swiper .rns-main-gallery-image {
        height: auto;
        max-height: 70vh; /* Prevent images from being too tall on mobile */
    }
    
    .main-product-swiper .swiper-slide {
        padding: 4px;
    }
}

/* Image hover effect */
.main-product-swiper .rns-main-gallery-image:hover {
    opacity: 0.95;
}

/* ============================================================================
   THUMBNAIL SWIPER STYLES
   ============================================================================ */

.thumbs-product-swiper {
    width: 100%;
    height: auto;
    padding: 8px 0;
    margin-top: 8px;
}

.thumbs-product-swiper .swiper-slide {
    height: 80px;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background: #f8f9fa;
}

/* Responsive thumbnail heights */
@media (max-width: 480px) {
    .thumbs-product-swiper .swiper-slide {
        height: 60px;
    }
}

@media (min-width: 1200px) {
    .thumbs-product-swiper .swiper-slide {
        height: 100px;
    }
}

/* Thumbnail hover states */
.thumbs-product-swiper .swiper-slide:hover {
    opacity: 0.8;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Active thumbnail styles */
.thumbs-product-swiper .swiper-slide-thumb-active {
    opacity: 1 !important;
    border-color: var(--e-global-color-primary);
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.3);
    transform: translateY(-1px);
}

.thumbs-product-swiper .swiper-slide-thumb-active:hover {
    transform: translateY(-2px);
}

/* ============================================================================
   THUMBNAIL IMAGES
   ============================================================================ */

.thumbs-product-swiper .rns-thumb-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: all 0.3s ease;
}

/* ============================================================================
   NAVIGATION ARROWS
   ============================================================================ */

.rns-gallery-nav-next,
.rns-gallery-nav-prev {
    width: 44px !important;
    height: 44px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    color: #333 !important;
    transition: all 0.3s ease !important;
    backdrop-filter: blur(4px);
    margin-top: -22px !important;
}

.rns-gallery-nav-next:hover,
.rns-gallery-nav-prev:hover {
    background: rgba(255, 255, 255, 1) !important;
    transform: scale(1.1) !important;
    color: var(--e-global-color-primary) !important;
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3) !important;
}

.rns-gallery-nav-next::after,
.rns-gallery-nav-prev::after {
    font-size: 16px !important;
    font-weight: bold !important;
    color: inherit !important;
}

.rns-gallery-nav-next.swiper-button-disabled,
.rns-gallery-nav-prev.swiper-button-disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

/* Responsive arrow sizing */
@media (max-width: 480px) {
    .rns-gallery-nav-next,
    .rns-gallery-nav-prev {
        width: 36px !important;
        height: 36px !important;
        margin-top: -18px !important;
    }
    
    .rns-gallery-nav-next::after,
    .rns-gallery-nav-prev::after {
        font-size: 14px !important;
    }
}

/* ============================================================================
   ERROR AND NO IMAGES STATES
   ============================================================================ */

.rns-gallery-error,
.rns-gallery-no-images {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #ddd;
    font-size: 16px;
    line-height: 1.5;
}

.rns-gallery-error::before,
.rns-gallery-no-images::before {
    content: "📷";
    display: block;
    font-size: 32px;
    margin-bottom: 12px;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.rns-product-gallery-container.loading .main-product-swiper {
    background: linear-gradient(90deg, #f0f0f0 25%, transparent 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: rns-loading 1.5s ease infinite;
}

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

/* Skeleton loading for thumbnails */
.rns-product-gallery-container.loading .thumbs-product-swiper .swiper-slide {
    background: linear-gradient(90deg, #f0f0f0 25%, transparent 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: rns-loading 1.5s ease infinite;
}

/* ============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================ */

/* Screen reader only text */
.rns-gallery-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus states for keyboard navigation */
.main-product-swiper .swiper-slide:focus,
.thumbs-product-swiper .swiper-slide:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* ============================================================================
   HIGH CONTRAST MODE SUPPORT
   ============================================================================ */

@media (prefers-contrast: high) {
    .main-product-swiper {
        border: 2px solid #000;
        box-shadow: none;
    }
    
    .thumbs-product-swiper .swiper-slide {
        border: 2px solid #000;
    }
    
    .thumbs-product-swiper .swiper-slide-thumb-active {
        border-color: #000;
        background: #fff;
    }
    
    .rns-gallery-nav-next,
    .rns-gallery-nav-prev {
        background: #fff !important;
        border: 2px solid #000 !important;
        color: #000 !important;
    }
}

/* ============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .main-product-swiper .rns-main-gallery-image,
    .thumbs-product-swiper .swiper-slide,
    .rns-gallery-nav-next,
    .rns-gallery-nav-prev {
        transition: none !important;
        animation: none !important;
    }
    
    .rns-product-gallery-container.loading .main-product-swiper,
    .rns-product-gallery-container.loading .thumbs-product-swiper .swiper-slide {
        animation: none !important;
        background: #f0f0f0 !important;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .thumbs-product-swiper,
    .rns-gallery-nav-next,
    .rns-gallery-nav-prev {
        display: none !important;
    }
    
    .main-product-swiper {
        height: auto !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
    
    .main-product-swiper .swiper-slide:not(.swiper-slide-active) {
        display: none !important;
    }
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .main-product-swiper {
        background: #2a2a2a;
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
    }
    
    .main-product-swiper .swiper-slide {
        background: #1a1a1a;
    }
    
    .thumbs-product-swiper .swiper-slide {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .thumbs-product-swiper .swiper-slide-thumb-active {
        border-color: #0ea5e9;
        box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
    }
    
    .rns-gallery-nav-next,
    .rns-gallery-nav-prev {
        background: rgba(42, 42, 42, 0.9) !important;
        color: #fff !important;
    }
    
    .rns-gallery-nav-next:hover,
    .rns-gallery-nav-prev:hover {
        background: rgba(42, 42, 42, 1) !important;
        color: #0ea5e9 !important;
    }
    
    .rns-gallery-error,
    .rns-gallery-no-images {
        background: #2a2a2a;
        color: #ccc;
        border-color: #444;
    }
}

/* ============================================================================
   CUSTOM HEIGHT VARIANTS (via data attributes)
   ============================================================================ */

.rns-product-gallery-container[data-height="400px"] .main-product-swiper {
    height: 400px;
}

.rns-product-gallery-container[data-height="600px"] .main-product-swiper {
    height: 600px;
}

.rns-product-gallery-container[data-height="auto"] .main-product-swiper {
    height: auto;
}

@media (max-width: 767px) {
    .rns-product-gallery-container[data-height] .main-product-swiper {
        height: auto !important; /* Force responsive on mobile regardless of data-height */
    }
}