/* ======================================================
   Virtual Try-On widget — duale.shop
   ====================================================== */

/* ── Кнопка-триггер в карточке товара ─────────────────── */
.tryon-trigger {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin: 18px 0;
    padding: 14px 18px;
    background: linear-gradient(135deg, #fff 0%, #f7f1ff 100%);
    border: 1.5px solid #d8cdef;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
    font-family: inherit;
    color: #1f1235;
    transition: all .2s;
    box-shadow: 0 2px 8px rgba(116, 65, 200, 0.06);
}

.tryon-trigger:hover {
    border-color: #8b5cf6;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.18);
    transform: translateY(-1px);
    color: #1f1235;
}

.tryon-trigger__icon {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
}

.tryon-trigger__text {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tryon-trigger__title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.tryon-trigger__sub {
    font-size: 12px;
    color: #5d5276;
    margin-top: 2px;
    line-height: 1.3;
}

.tryon-trigger__arrow {
    flex: 0 0 auto;
    font-size: 26px;
    color: #8b5cf6;
    line-height: 1;
    font-weight: 300;
}

.tryon-trigger--guest .tryon-trigger__icon {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    box-shadow: 0 3px 10px rgba(100, 116, 139, 0.3);
}

/* ── Кнопки внутри модалки ─────────────────────────────── */
.tryon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 22px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform .15s, box-shadow .2s, opacity .2s;
    font-family: inherit;
}

.tryon-btn-primary {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.tryon-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.45);
    color: #fff;
}

.tryon-btn-primary:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.tryon-btn-secondary {
    background: #fff;
    color: #6366f1;
    border: 2px solid #c7bcf5;
}

.tryon-btn-secondary:hover {
    background: #f3efff;
    color: #5b21b6;
}

.tryon-btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 17px;
    margin-top: 8px;
}

/* ======================================================
   Модалка
   ====================================================== */

/* КРИТИЧНО: hidden-атрибут должен побеждать display:flex */
.tryon-modal[hidden] { display: none !important; }

.tryon-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tryon-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 8, 35, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.tryon-modal__dialog {
    position: relative;
    background: #fff;
    border-radius: 18px;
    max-width: 640px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    animation: tryonModalIn .25s ease-out;
}

@keyframes tryonModalIn {
    from { opacity: 0; transform: translateY(20px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tryon-modal__close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f3f0fa;
    font-size: 28px;
    line-height: 1;
    color: #5d5276;
    cursor: pointer;
    transition: background .2s, transform .15s;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.tryon-modal__close:hover {
    background: #e7e0f7;
    transform: rotate(90deg);
}

.tryon-modal__close:active {
    background: #d8cdef;
}

.tryon-step h2 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
    color: #1f1235;
    padding-right: 48px; /* место для крестика */
}

.tryon-sub {
    margin: 0 0 22px;
    font-size: 14px;
    color: #5d5276;
    line-height: 1.5;
}

/* Сетка с фото */
.tryon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 22px;
}

.tryon-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tryon-card__label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #8a7da8;
    margin-bottom: 8px;
    letter-spacing: .5px;
}

.tryon-card__photo {
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    overflow: hidden;
    background: #f7f5fc;
    border: 2px solid #ebe5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    position: relative;
}

.tryon-card__photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tryon-card__photo--upload {
    cursor: pointer;
    border-style: dashed;
    transition: all .2s;
}

.tryon-card__photo--upload:hover,
.tryon-card__photo--upload:active {
    border-color: #8b5cf6;
    background: #f3efff;
}

.tryon-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #8a7da8;
    text-align: center;
    padding: 12px;
}

.tryon-upload-placeholder span {
    font-size: 14px;
    font-weight: 600;
    color: #6366f1;
}

.tryon-upload-placeholder small {
    font-size: 11px;
    color: #a89dc4;
}

.tryon-hint {
    text-align: center;
    margin: 14px 0 0;
    font-size: 12px;
    color: #8a7da8;
}

/* Прогресс */
.tryon-progress {
    width: 100%;
    height: 10px;
    background: #ece6f9;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 18px;
}

.tryon-progress__bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8b5cf6, #6366f1, #ec4899);
    background-size: 200% 100%;
    border-radius: 6px;
    transition: width .4s ease;
    animation: tryonShimmer 2s linear infinite;
}

@keyframes tryonShimmer {
    0%   { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

.tryon-progress__percent {
    text-align: center;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #6366f1;
}

.tryon-steps-list {
    list-style: none;
    margin: 22px 0 0;
    padding: 0;
}

.tryon-steps-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    color: #8a7da8;
    transition: color .3s;
}

.tryon-steps-list li.active {
    color: #1f1235;
    font-weight: 600;
}

.tryon-steps-list li.done {
    color: #16a34a;
}

.tryon-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ece6f9;
    border: 2px solid #d8cdef;
    flex-shrink: 0;
    transition: all .3s;
}

.tryon-steps-list li.active .tryon-dot {
    background: #6366f1;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
    animation: tryonPulse 1.4s ease-in-out infinite;
}

.tryon-steps-list li.done .tryon-dot {
    background: #16a34a;
    border-color: #16a34a;
}

@keyframes tryonPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2); }
    50%      { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.05); }
}

/* Результат */
.tryon-result {
    background: #f7f5fc;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 18px;
}

.tryon-result img {
    width: 100%;
    height: auto;
    display: block;
}

.tryon-result-actions {
    display: flex;
    gap: 12px;
}

.tryon-result-actions .tryon-btn {
    flex: 1;
}

.tryon-error {
    color: #dc2626;
    padding: 14px 16px;
    background: #fef2f2;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* ======================================================
   Мобильная адаптация
   ====================================================== */
@media (max-width: 768px) {
    .tryon-trigger {
        padding: 12px 14px;
        gap: 12px;
    }
    .tryon-trigger__icon {
        flex: 0 0 36px;
        width: 36px;
        height: 36px;
    }
    .tryon-trigger__title { font-size: 14px; }
    .tryon-trigger__sub { font-size: 11px; }

    .tryon-modal {
        padding: 0;
        align-items: stretch;
    }

    .tryon-modal__dialog {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        padding: 56px 16px 20px;
        animation: tryonModalInMobile .25s ease-out;
    }

    @keyframes tryonModalInMobile {
        from { opacity: 0; transform: translateY(20px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .tryon-modal__close {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
        font-size: 30px;
        background: #ece6f9;
        z-index: 10;
    }

    .tryon-step h2 {
        font-size: 19px;
        padding-right: 52px;
    }

    .tryon-sub {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .tryon-grid {
        gap: 10px;
        margin-bottom: 18px;
    }

    .tryon-card__label {
        font-size: 11px;
    }

    .tryon-upload-placeholder span { font-size: 13px; }
    .tryon-upload-placeholder small { font-size: 10px; }

    .tryon-btn-large {
        padding: 14px 20px;
        font-size: 16px;
    }

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

    .tryon-steps-list li {
        font-size: 13px;
    }
}

@media (max-width: 380px) {
    .tryon-modal__dialog { padding: 52px 12px 16px; }
    .tryon-grid { gap: 8px; }
    .tryon-upload-placeholder { padding: 8px; }
    .tryon-upload-placeholder svg { width: 32px; height: 32px; }
}
