/* Кнопка "View in 3D" — квадратная, последней "миниатюрой" в ряду превью
   (#thumbsRow), визуально повторяет .thumb-item из product_detail.css.
   Специально НЕ использует класс .thumb-item — тот класс подхвачен JS-кодом
   галереи (клик по нему ожидает data-index для навигации по фото), а этой
   кнопке навигация не нужна, у неё своё действие — открыть попап 3D. */
.thumb-item-3d {
    width: 70px;
    height: 70px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border: 1px solid #000;
    background: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0;
}

.thumb-item-3d:hover {
    background: #f5f5f5;
}

.thumb-item-3d .icon {
    font-size: 20px;
    line-height: 1;
}

.thumb-item-3d .label {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* ===== Overlay-кнопка "View in 3D" поверх фото — только мобильная версия =====
   На десктопе спрятана: там кнопка живёт в ряду миниатюр (.thumb-item-3d выше).
   На мобильном ряд миниатюр целиком скрыт (правило в product_detail.css),
   поэтому там нужна отдельная кнопка прямо на фото — как у Gucci. */
.btn-view-3d-overlay {
    display: none;
    position: absolute;
    bottom: 15px;
    left: 15px;
    z-index: 15;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-view-3d-overlay .icon {
    font-size: 16px;
}

/* ===== Счётчик "текущее фото / всего" — только мобильная версия.
   На десктопе не нужен: там уже есть ряд миниатюр, который и так показывает
   и общее количество фото, и текущее положение (активная миниатюра). Плюс
   на десктопе он визуально конфликтует с product-info-box — оба прижаты
   к правому нижнему углу одной и той же ленты. */
.gallery-counter {
    display: none;
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 15;
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
}

@media (max-width: 768px) {
    .btn-view-3d-overlay {
        display: inline-flex;
    }

    .gallery-counter {
        display: block;
    }
}

/* ===== Модальное окно попапа ===== */

.product-3d-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.product-3d-modal.open {
    display: flex;
}

.product-3d-modal-content {
    position: relative;
    width: 100%;
    max-width: 700px;
    height: 80vh;
    max-height: 700px;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
}

.product-3d-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-3d-modal-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Внутри модалки вьюер растягивается на весь попап, без своих рамок и отступов */
.product-3d-modal .product-3d-viewer {
    width: 100%;
    height: 100%;
    margin-top: 0;
    border: none;
    border-radius: 0;
}

/* ===== Сам вьюер (используется и вне модалки, если понадобится) ===== */

.product-3d-viewer {
    width: 350px;
    height: auto;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-top: 15px;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    cursor: grab;
    user-select: none;
}

.product-3d-viewer:active {
    cursor: grabbing;
}

.product-3d-viewer img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.1s ease;
    /* Отключаем нативное перетаскивание картинки браузером (то самое
       "полупрозрачное таскание" файла) — оно конфликтует с нашим
       собственным вращением по mousedown/mousemove */
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.viewer-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    padding: 5px 15px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.viewer-controls button {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
}

.viewer-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.viewer-progress {
    width: 60px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.viewer-progress-bar {
    height: 100%;
    background: white;
    border-radius: 2px;
    transition: width 0.1s ease;
}

.viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
    text-align: center;
    width: 80%;
}