/**
 * Product Gallery Styles
 * Amazon-style image gallery with thumbnails
 * Thumbnails appear ABOVE the main image on mobile, LEFT side on desktop
 */

.product-gallery {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

/* Main Image Container */
.main-image-container {
    position: relative;
    width: 100%;
    background-color: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    order: 2;
}

#main-product-image {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.2s ease-in-out;
}

.image-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    font-size: 0.9rem;
    color: #666;
}

/* Thumbnail Strip */
.thumbnail-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    order: 1;
    margin-bottom: 1rem;
}

.thumbnail-strip::-webkit-scrollbar {
    height: 6px;
}

.thumbnail-strip::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.thumbnail-strip::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.thumbnail-strip::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Thumbnail Wrapper */
.thumbnail-wrapper {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #f8f9fa;
}

.thumbnail-wrapper:hover {
    border-color: #dee2e6;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.thumbnail-wrapper.active {
    border-color: #007bff;
    box-shadow: 0 0 0 1px #007bff;
}

.thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Loading State */
.thumbnail-strip.loading {
    opacity: 0.6;
    pointer-events: none;
}

.thumbnail-strip.loading::after {
    content: 'Loading images...';
    display: block;
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 0.9rem;
}

/* Error State */
.thumbnail-strip.error::after {
    content: 'Failed to load images';
    display: block;
    text-align: center;
    padding: 1rem;
    color: #dc3545;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (min-width: 768px) {
    .thumbnail-wrapper {
        width: 100px;
        height: 100px;
    }
}

@media (min-width: 992px) {
    .product-gallery {
        flex-direction: row;
    }

    .main-image-container {
        flex: 1;
        order: 2;
    }

    .thumbnail-strip {
        flex-direction: column;
        width: 120px;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 600px;
        order: 1;
        margin-bottom: 0;
        margin-right: 1rem;
    }

    .thumbnail-strip::-webkit-scrollbar {
        width: 6px;
        height: auto;
    }

    .thumbnail-wrapper {
        width: 100%;
        height: 100px;
    }
}

/* Animation for image switching */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.main-image-container img {
    animation: fadeIn 0.3s ease-in-out;
}