/**
 * Стили для модального окна Virtual Try-On
 * Цветовая гамма OpticTrend: ч/б/серый
 */

.tryon-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tryon-modal--active {
    display: flex;
    opacity: 1;
}

.tryon-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1;
}

.tryon-modal__content {
    position: relative;
    background: #FFFFFF;
    border: 1px solid #E6E6E6;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    transform: scale(0.96);
    transition: transform 0.3s;
    z-index: 2;
}

.tryon-modal--active .tryon-modal__content {
    transform: scale(1);
}

.tryon-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 1px solid #E6E6E6;
    background: #F4F4F4;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    color: #1D1D1B;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s, color 0.2s;
}

.tryon-modal__close:hover {
    background: #E6E6E6;
    color: #1D1D1B;
}

.tryon-modal__body {
    padding: 24px 30px;
}

/* Типографика */
.tryon-step__title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    color: #1D1D1B;
}

.tryon-step__subtitle {
    font-size: 15px;
    color: #666;
    text-align: center;
    margin-bottom: 24px;
}

/* Кнопки: десктоп — в ряд, мобила — вертикально */
.tryon-upload {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tryon-btn {
    padding: 14px 24px;
    min-height: 48px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.tryon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* CTA — чёрная */
.tryon-btn--primary {
    background: #1D1D1B;
    color: #FFFFFF;
    border-color: #1D1D1B;
}

.tryon-btn--primary:hover:not(:disabled) {
    background: #2B2B2B;
    border-color: #2B2B2B;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(29, 29, 27, 0.25);
}

/* Вторичные — серые */
.tryon-btn--secondary {
    background: #F4F4F4;
    color: #1D1D1B;
    border-color: #D9D9D9;
}

.tryon-btn--secondary:hover:not(:disabled) {
    background: #E6E6E6;
    border-color: #D9D9D9;
}

.tryon-btn--camera,
.tryon-btn--upload {
    min-width: 200px;
}

.tryon-preview {
    margin-bottom: 20px;
    text-align: center;
}

.tryon-preview img {
    max-width: 100%;
    max-height: 280px;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid #E6E6E6;
}

.tryon-hint {
    font-size: 14px;
    color: #666;
    text-align: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #F4F4F4;
    border: 1px solid #E6E6E6;
    border-radius: 8px;
}

.tryon-btn--generate {
    width: 100%;
    padding: 16px;
    font-size: 17px;
    font-weight: 600;
    margin-top: 16px;
    min-height: 52px;
}

/* Шаг 2 — генерация */
.tryon-loader {
    text-align: center;
    padding: 32px 20px;
}

.tryon-loader__spinner {
    width: 52px;
    height: 52px;
    border: 3px solid #E6E6E6;
    border-top-color: #1D1D1B;
    border-radius: 50%;
    animation: tryon-spin 0.9s linear infinite;
    margin: 0 auto 20px;
}

.tryon-loader__wait {
    font-size: 13px;
    color: #888;
    margin-top: 12px;
}

@keyframes tryon-spin {
    to { transform: rotate(360deg); }
}

/* Шаг 3 — результат */
.tryon-result-image {
    text-align: center;
    margin-bottom: 24px;
}

.tryon-result-image img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #E6E6E6;
}

.tryon-result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.tryon-result-actions .tryon-btn {
    flex: 1;
    min-width: 140px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Шаг — ошибка */
.tryon-step--error {
    text-align: center;
}

.tryon-error__icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.tryon-error__text {
    font-size: 15px;
    color: #1D1D1B;
    margin-bottom: 8px;
    line-height: 1.5;
}

.tryon-error__hint {
    font-size: 14px;
    color: #666;
    margin-bottom: 24px;
}

.tryon-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1D1D1B;
    color: #FFFFFF;
    padding: 14px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.tryon-toast--show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Камера */
.tryon-camera-preview {
    margin: 20px 0;
    text-align: center;
}

.tryon-camera-preview video {
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
    margin: 0 auto 16px;
    display: block;
    background: #1D1D1B;
    border: 1px solid #E6E6E6;
}

.tryon-camera-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

.tryon-camera-actions .tryon-btn {
    min-width: 140px;
}

/* 4-й thumbnail в галерее — «Примерить онлайн» (только очки) */
.product__slider-outer .carousel-indicators .tryon-gallery-indicator {
    display: block !important;
    border: none !important;
    background: transparent !important;
}

.product__slider-outer .carousel-indicators .tryon-gallery-thumb {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 98px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    line-height: 98px;
    text-align: center;
    font-size: 0;
}

.product__slider-outer .carousel-indicators .tryon-gallery-thumb:hover {
    background: transparent;
}

.product__slider-outer .carousel-indicators .tryon-gallery-thumb img,
.product__slider-outer .carousel-indicators .tryon-gallery-thumb svg {
    max-width: 112.5%;
    max-height: 112.5px;
    width: auto;
    height: auto;
    vertical-align: middle;
    display: block;
    margin: 0 auto;
}

/* Мобильная версия (≤768px) — крупно */
@media (max-width: 767px) {
    .tryon-modal {
        padding: 12px;
        align-items: center;
    }

    .tryon-modal__content {
        width: 95vw;
        max-width: 480px;
        min-height: 65vh;
        height: auto;
        border-radius: 12px;
        max-height: 88vh;
    }

    .tryon-modal__body {
        padding: 18px 20px;
    }

    .tryon-step__title {
        font-size: 19px;
        font-weight: 700;
    }

    .tryon-step__subtitle {
        font-size: 15px;
        margin-bottom: 20px;
    }

    /* Кнопки вертикально, на всю ширину */
    .tryon-upload {
        flex-direction: column;
        margin-bottom: 20px;
    }

    .tryon-btn--camera,
    .tryon-btn--upload {
        width: 100%;
        min-width: unset;
        min-height: 52px;
        font-size: 16px;
    }

    .tryon-btn--generate {
        min-height: 54px;
        font-size: 16px;
    }

    .tryon-hint {
        font-size: 14px;
        padding: 12px;
    }

    .tryon-loader__spinner {
        width: 56px;
        height: 56px;
    }

    .tryon-result-actions {
        flex-direction: column;
    }

    .tryon-result-actions .tryon-btn {
        width: 100%;
        min-width: unset;
        min-height: 52px;
        touch-action: manipulation;
    }

    .tryon-camera-actions {
        flex-direction: column;
    }

    .tryon-camera-actions .tryon-btn {
        width: 100%;
    }
}

/* Кнопка в карточке товара */
.tryon-product-btn {
    margin-top: 12px;
    width: 100%;
}

.tryon-product-btn .tryon-btn {
    width: 100% !important;
    background: #1D1D1B !important;
    color: #FFFFFF !important;
    padding: 14px 20px !important;
    min-height: 48px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
}

.tryon-product-btn .tryon-btn:hover {
    background: #2B2B2B !important;
    transform: translateY(-1px);
}

.tryon-product-btn .tryon-btn:active {
    transform: translateY(0) !important;
}

/* После скрытия блока примерки — не даём блоку наличия/доставки наезжать на «ЦЕНА ДЕЙСТВУЕТ ЕЩЁ» (обход кэша Bitrix) */
body.tryon-ui-hidden .ot-availability,
body.tryon-ui-hidden #catalog_store_amount_div {
    clear: both !important;
    display: block !important;
    width: 100% !important;
    margin-top: 0.5em !important;
}
body.tryon-ui-hidden .ot-price-recalc {
    display: block !important;
    margin-bottom: 0.25em !important;
}
