/**
 * Галерея фото товара — v2 (стиль apteka.ru)
 * /new/assets/css/gallery.css
 *
 * Desktop: миниатюры вертикально слева + большое фото справа
 * Mobile:  full-width слайдер + dots пагинация
 * Lightbox: fullscreen + thumbnail strip снизу
 */

/* === Внешний layout: [thumbs-left | main-right] === */
.product-gallery {
    background: #fff;
    border: 1px solid #eee;
    border-radius: var(--r3);
    overflow: hidden;
    display: flex;
    flex-direction: row;
    gap: 0;
}

/* === Колонка миниатюр (слева, desktop) === */
.gallery-thumbs-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 10px;
    border-right: 1px solid #eee;
    overflow-y: auto;
    max-height: 520px;
    min-width: 96px;
    width: 96px;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #ddd #f5f5f5;
    flex-shrink: 0;
}
.gallery-thumbs-col::-webkit-scrollbar {
    width: 4px;
}
.gallery-thumbs-col::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

.gallery-thumb {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    border: 2px solid transparent;
    border-radius: var(--r2);
    overflow: hidden;
    cursor: pointer;
    padding: 4px;
    background: #f9f9f9;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.gallery-thumb.active {
    border-color: var(--c4);
}
.gallery-thumb:hover {
    border-color: var(--c1l);
}

/* === Правая часть: слайдер === */
.gallery-main-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* === Основное фото === */
.gallery-main {
    position: relative;
    min-height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
}

.gallery-slides {
    display: flex;
    width: 100%;
    transition: transform 0.3s ease;
}

.gallery-slide {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    min-height: 480px;
    box-sizing: border-box;
}

.gallery-slide-img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    object-fit: contain;
}

/* === Иконка зума === */
.gallery-zoom-btn {
    position: absolute;
    bottom: 14px;
    right: 14px;
    background: rgba(255,255,255,0.88);
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--n6);
    line-height: 1;
    padding: 0;
}
.gallery-zoom-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

/* === Стрелки навигации (только между миниатюрами, скрыты на desktop) === */
.gallery-arrow {
    display: none;
}

/* === Dots пагинация (мобильная) === */
.gallery-dots {
    display: none;
    justify-content: center;
    gap: 6px;
    padding: 10px 0 14px;
}
.gallery-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ccc;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 0.2s;
}
.gallery-dot.active {
    background: var(--c4);
}

/* === Lightbox === */
.gallery-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.gallery-lightbox.active {
    display: flex;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.lightbox-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90%;
    max-width: 860px;
    max-height: 90vh;
    background: #fff;
    border-radius: var(--r4);
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    overflow: hidden;
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #f5f5f5;
    border: 1px solid var(--n2);
    color: var(--n6);
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 3;
    line-height: 1;
    padding: 0;
    transition: all 0.2s;
}
.lightbox-close:hover {
    background: #eee;
    color: var(--n9);
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #f5f5f5;
    border: 1px solid var(--n2);
    color: var(--n6);
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 3;
    line-height: 1;
    padding: 0;
    transition: all 0.2s;
}
.lightbox-arrow:hover {
    background: #eee;
    color: var(--n9);
}
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

.lightbox-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding: 40px 60px 10px;
    box-sizing: border-box;
    background: #fff;
}

.lightbox-img {
    max-width: 100%;
    max-height: calc(90vh - 160px);
    object-fit: contain;
}

/* === Надпись (название препарата) в lightbox === */
.lightbox-caption {
    width: 100%;
    padding: 0 60px 4px;
    box-sizing: border-box;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    color: var(--n6);
    line-height: 1.3;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

/* === Предупреждение под фото === */
.lightbox-disclaimer {
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: #aaa;
    font-style: italic;
    padding: 0 20px 2px;
    box-sizing: border-box;
}

/* === Thumbnail strip в lightbox (снизу, как apteka.ru) === */
.lightbox-thumbs {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 8px;
    padding: 10px 16px 16px;
    justify-content: center;
    overflow-x: auto;
    max-width: 100%;
    box-sizing: border-box;
    scrollbar-width: none;
    background: #fff;
}
.lightbox-thumbs::-webkit-scrollbar {
    display: none;
}

.lightbox-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border: 2px solid var(--n2);
    border-radius: var(--r1);
    overflow: hidden;
    cursor: pointer;
    padding: 3px;
    background: #f9f9f9;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.lightbox-thumb.active {
    border-color: var(--c4);
}
.lightbox-thumb:hover {
    border-color: var(--c1l);
}

/* === Мобильная адаптация === */
@media (max-width: 768px) {
    .product-gallery {
        flex-direction: column;
    }

    /* Скрываем вертикальные миниатюры на mobile */
    .gallery-thumbs-col {
        display: none;
    }

    .gallery-main {
        min-height: 280px;
        cursor: default;
    }
    .gallery-slide {
        padding: 16px;
        min-height: 280px;
    }
    .gallery-slide-img {
        max-height: 280px;
    }

    .gallery-zoom-btn {
        display: none;
    }

    /* Показываем dots на mobile */
    .gallery-dots {
        display: flex;
    }

    /* Lightbox на mobile */
    .lightbox-content {
        width: 95%;
        max-height: 92vh;
        border-radius: var(--r3);
    }
    .lightbox-arrow {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    .lightbox-prev { left: 6px; }
    .lightbox-next { right: 6px; }
    .lightbox-close {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        font-size: 24px;
    }
    .lightbox-img-wrap {
        padding: 36px 20px 6px;
    }
    .lightbox-img {
        max-height: calc(90vh - 140px);
    }
    .lightbox-thumb {
        flex: 0 0 52px;
        width: 52px;
        height: 52px;
    }
}
