/**
 * Product Gallery Styles
 * Enhanced gallery with zoom functionality
 */

/* Product Gallery Container */
.product-gallery {
    position: relative;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Main Image Container */
.main-image-container {
    position: relative;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.main-image-wrapper {
    position: relative;
    height: 500px;
    overflow: hidden;
    cursor: zoom-in;
}

.main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.3s ease;
    border-radius: 8px;
}

/* Zoom Overlay */
.zoom-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.zoom-overlay i {
    margin-right: 8px;
    font-size: 16px;
}

.main-image-container:hover .zoom-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
}

/* Thumbnail Gallery */
.gallery-thumbnails {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) transparent;
}

.gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.gallery-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
}

.thumbnail-item {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.thumbnail-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.thumbnail-item.active {
    border-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.thumbnail-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.thumbnail-item:hover img {
    transform: scale(1.1);
}

/* Zoom Functionality */
.zoom-container {
    position: relative;
    overflow: hidden;
}

.zoom-container img {
    transition: transform 0.3s ease;
}

/* Fullscreen Gallery */
.fullscreen-gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(10px);
}

.fullscreen-gallery-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.fullscreen-close {
    position: absolute;
    top: -60px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.fullscreen-prev,
.fullscreen-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.fullscreen-prev {
    left: -80px;
}

.fullscreen-next {
    right: -80px;
}

.fullscreen-prev:hover,
.fullscreen-next:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

/* Loading States */
.gallery-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary-dark);
    font-size: 18px;
}

.gallery-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-light);
    border-top: 2px solid var(--primary-dark);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Lazy Loading */
.lazy {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy.loaded {
    opacity: 1;
}

/* Touch Indicators */
.touch-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.main-image-container.touch-active .touch-indicator {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-image-wrapper {
        height: 400px;
    }
    
    .thumbnail-item {
        width: 70px;
        height: 70px;
    }
}

@media (max-width: 768px) {
    .product-gallery {
        padding: 15px;
    }
    
    .main-image-wrapper {
        height: 350px;
    }
    
    .gallery-thumbnails {
        gap: 8px;
    }
    
    .thumbnail-item {
        width: 60px;
        height: 60px;
    }
    
    .fullscreen-prev {
        left: -60px;
    }
    
    .fullscreen-next {
        right: -60px;
    }
    
    .fullscreen-prev,
    .fullscreen-next {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .main-image-wrapper {
        height: 300px;
    }
    
    .gallery-thumbnails {
        gap: 6px;
    }
    
    .thumbnail-item {
        width: 50px;
        height: 50px;
    }
    
    .zoom-overlay {
        padding: 8px 16px;
        font-size: 12px;
    }
    
    .fullscreen-prev {
        left: -40px;
    }
    
    .fullscreen-next {
        right: -40px;
    }
    
    .fullscreen-prev,
    .fullscreen-next {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .main-image,
    .thumbnail-item img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility */
.thumbnail-item:focus,
.fullscreen-close:focus,
.fullscreen-prev:focus,
.fullscreen-next:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .product-gallery {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .zoom-overlay,
    .fullscreen-gallery-overlay {
        display: none !important;
    }
}
