/* ==========================================================================
   Enhanced Product Gallery Styles - BecksCarCare
   ========================================================================== */

/* Enhanced Gallery Container */
.product-gallery-container {
    height: 600px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    position: relative;
}

/* Main Product Image Section with Enhanced Interactivity */
.main-product-image-section {
    height: 70%; /* Increased to give more space for main image */
    position: relative;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    background: #f8f9fa;
    cursor: zoom-in;
}

.main-product-image {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.main-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    user-select: none;
}

.main-product-image:hover img {
    transform: scale(1.08);
}

/* Image Loading State */
.main-product-image.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.main-product-image.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #ddd;
    border-top: 3px solid var(--beckscarcare-primary-color, #E81C2E);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Enhanced Thumbnail Gallery */
.product-gallery-section {
    height: 30%; /* Reduced to give more space to main image */
    padding: 12px;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
    overflow-y: hidden;
}

.product-gallery-grid {
    display: flex;
    gap: 10px;
    height: 100%;
    align-items: center;
    min-width: fit-content;
}

/* Enhanced Gallery Items */
.gallery-item {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    overflow: hidden;
    border-radius: 8px;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    background: #fff;
}

.gallery-item:hover {
    border-color: var(--beckscarcare-secondary-color, #f7931e);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(232, 28, 46, 0.25);
}

.gallery-item.active {
    border-color: var(--beckscarcare-primary-color, #E81C2E);
    box-shadow: 0 4px 12px rgba(232, 28, 46, 0.3);
    transform: translateY(-2px);
}

.gallery-item.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: var(--beckscarcare-primary-color, #E81C2E);
    border-radius: 50%;
    opacity: 0.9;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.9; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.6; }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.9; }
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.1);
}

/* Zoom and Expand Buttons */
.image-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.main-product-image-section:hover .image-controls {
    opacity: 1;
}

.image-control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.image-control-btn:hover {
    background: var(--beckscarcare-primary-color, #E81C2E);
    color: white;
    transform: scale(1.1);
}

.image-control-btn i {
    font-size: 16px;
}

/* Image Lightbox Modal */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-lightbox.show {
    display: flex;
    opacity: 1;
}

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

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

/* Lightbox Controls */
.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}

.lightbox-close:hover {
    background: var(--beckscarcare-primary-color, #E81C2E);
    border-color: var(--beckscarcare-primary-color, #E81C2E);
    transform: scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 20px;
}

.lightbox-nav:hover {
    background: var(--beckscarcare-primary-color, #E81C2E);
    border-color: var(--beckscarcare-primary-color, #E81C2E);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: -70px;
}

.lightbox-next {
    right: -70px;
}

/* Image Counter */
.lightbox-counter {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Zoom Functionality */
.lightbox-image.zoomed {
    transform: scale(2);
    cursor: zoom-out;
}

.lightbox-image:not(.zoomed) {
    cursor: zoom-in;
}

/* Sale/Featured Badges Enhanced */
.sale-badge,
.featured-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 5;
    animation: fadeInScale 0.5s ease-out;
}

.sale-badge {
    background: linear-gradient(135deg, #ff4757, #ff3742);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
}

.featured-badge {
    background: linear-gradient(135deg, #ffa502, #ff9500);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 165, 2, 0.4);
    top: 60px; /* Position below sale badge if both exist */
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .product-gallery-container {
        height: 400px;
    }
    
    .main-product-image-section {
        height: 75%;
    }
    
    .product-gallery-section {
        height: 25%;
        padding: 8px;
    }
    
    .gallery-item {
        width: 60px;
        height: 60px;
    }
    
    .image-controls {
        top: 10px;
        right: 10px;
        gap: 6px;
    }
    
    .image-control-btn {
        width: 35px;
        height: 35px;
    }
    
    .image-control-btn i {
        font-size: 14px;
    }
    
    .lightbox-nav {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .lightbox-prev {
        left: -60px;
    }
    
    .lightbox-next {
        right: -60px;
    }
}

@media (max-width: 480px) {
    .product-gallery-container {
        height: 350px;
        border-radius: 8px;
    }
    
    .gallery-item {
        width: 50px;
        height: 50px;
    }
    
    .image-controls {
        opacity: 1; /* Always visible on mobile */
    }
    
    .lightbox-content {
        max-width: 95%;
        max-height: 85%;
    }
    
    .lightbox-close {
        top: -40px;
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .lightbox-prev {
        left: -50px;
    }
    
    .lightbox-next {
        right: -50px;
    }
    
    .lightbox-counter {
        bottom: -40px;
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Touch Interactions for Mobile */
@media (hover: none) and (pointer: coarse) {
    .gallery-item:active {
        transform: scale(0.95);
    }
    
    .image-control-btn:active {
        transform: scale(0.9);
    }
    
    .main-product-image:active img {
        transform: scale(1.05);
    }
}

/* High Contrast and Accessibility */
@media (prefers-contrast: high) {
    .gallery-item {
        border-width: 4px;
    }
    
    .gallery-item.active {
        border-width: 5px;
    }
    
    .image-control-btn {
        border: 2px solid #000;
    }
    
    .lightbox-nav,
    .lightbox-close {
        border-width: 3px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .main-product-image img,
    .gallery-image,
    .gallery-item,
    .image-control-btn,
    .lightbox-image {
        transition: none;
    }
    
    .gallery-item.active::after {
        animation: none;
    }
    
    .sale-badge,
    .featured-badge {
        animation: none;
    }
    
    .main-product-image:hover img,
    .gallery-item:hover .gallery-image {
        transform: none;
    }
}

/* Focus Styles for Keyboard Navigation */
.gallery-item:focus,
.image-control-btn:focus,
.lightbox-close:focus,
.lightbox-nav:focus {
    outline: 3px solid var(--beckscarcare-primary-color, #E81C2E);
    outline-offset: 2px;
}

/* Loading Animation for Image Transitions */
.main-product-image.transitioning {
    opacity: 0.7;
}

.main-product-image.transitioning::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 2px solid #ddd;
    border-top: 2px solid var(--beckscarcare-primary-color, #E81C2E);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10;
}