/* Основной контейнер галереи */
.product-gallery {
    max-width: 100%;
    margin: 0 auto;
    font-family: sans-serif;
    outline: none; /* фокус управляется через tabindex, но стиль можно задать */
}

.product-gallery:focus-visible {
    outline: 2px solid #007cba;
}

/* Блок с главным изображением */
.gallery-main-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.gallery-main {
    flex: 1;
    text-align: center;
    overflow: hidden;
}

.main-img {
    max-width: 100%;
    height: auto;
    transition: opacity 0.2s ease;
    opacity: 1;
}

.main-img.fade-out {
    opacity: 0;
}

.main-img.fade-in {
    opacity: 1;
}

.main-img.fade-effect {
    opacity: 0;
}

/* Кнопки навигации */
.gallery-nav {
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: background 0.2s;
    z-index: 1;
    border-radius: 4px;
}

.gallery-nav:hover,
.gallery-nav:focus {
    background: rgba(0,0,0,0.8);
    outline: none;
}

/* Миниатюры */
.gallery-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.thumb-item {
    width: 80px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    border: 2px solid transparent;
    border-radius: 4px;
}

.thumb-item img {
    width: 100%;
    height: auto;
    display: block;
}

.thumb-item.active,
.thumb-item:hover {
    opacity: 1;
    border-color: #007cba;
    transform: scale(1.02);
}

.main-img.loading {
    position: relative;
    opacity: 0.6;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23333"><circle cx="12" cy="12" r="10" stroke-width="2"/><path d="M12 2v4M12 22v-4M22 12h-4M2 12h4" stroke-width="2"/></svg>') center no-repeat;
    background-size: 2rem;
}

.main-img.fade-out { opacity: 0; transition: opacity 0.2s ease; }
.main-img.fade-in { opacity: 1; transition: opacity 0.2s ease; }

/* Адаптивность */
@media (max-width: 768px) {
    .thumb-item {
        width: 60px;
    }
    .gallery-nav {
        font-size: 1.5rem;
        padding: 0.25rem 0.75rem;
    }
}