/* ============================================
   MODAL — Unified Modal System
   ============================================ */

/* ── Overlay (backdrop blur) ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    /* Центрирование по обеим осям */
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ── Modal Container ── */
.modal {
    position: relative;
    border-radius: 15px;
    width: 850px;
    min-height: 588px;
    max-height: calc(100vh - 40px);
    box-shadow: 0 2px 18px 0 rgba(0, 0, 0, 0.2);
    background: linear-gradient(180deg, #322a22 0%, #16120e 66.67%);
    border: none;
    padding: 88px 50px 50px 50px; /* 88px top padding on desktop */
    box-sizing: border-box;
    transform: translateY(30px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.4s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal {
    transform: translateY(0);
    opacity: 1;
}

/* ── Close Button ── */
.modal__close {
    position: absolute;
    top: 25px;
    right: 25px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.2s;
}

.modal__close:hover {
    opacity: 0.7;
}

/* ── Title ── */
.modal__title {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 24px;
    line-height: 56%;
    text-transform: uppercase;
    color: #fff;
    margin: 0 0 40px;
}

/* ── Divider ── */
.modal__divider {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0;
}

/* ── Product Info Block ── */
.modal__product {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 0;
}

.modal__product-info {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 24px;
    line-height: 120%;
    color: #fff;
}

.modal__product-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 30px;
}

/* ── Quantity Counter ── */
.modal__quantity {
    display: flex;
    align-items: center;
}

.modal__quantity-btn {
    width: 31px;
    height: 34px;
    border: 0.86px solid #666;
    border-radius: 0 4px 4px 0;
    background: transparent;
    color: #e8d6ac;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-sizing: border-box;
}

.modal__quantity-btn:first-child {
    transform: rotate(-180deg);
}

.modal__quantity-value {
    width: 40px;
    height: 34px;
    border-top: 0.86px solid #666;
    border-bottom: 0.86px solid #666;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-sizing: border-box;
}

/* ── Price ── */
.modal__price {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 40px;
    line-height: 40%;
    letter-spacing: 0.1em;
    text-align: right;
    color: #fff;
    white-space: nowrap;
}

/* ── Form Fields ── */
.modal__fields {
    display: flex;
    gap: 15px;
    margin-bottom: 18px;
    margin-top: 40px;
}


.modal__input {
    flex: 1;
    background: #16120e;
    font-family: var(--font-primary);
    font-size: 14px;
    color: #fff;
    border-radius: 30px;
    padding: 0 20px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    outline: none;
    box-sizing: border-box;
}

.modal__input:focus {
    border-color: #e8d6ac;
}

/* Fix paste / autofill background */
.modal__input:-webkit-autofill,
.modal__input:-webkit-autofill:hover,
.modal__input:-webkit-autofill:focus,
.modal__input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #16120e inset !important;
    -webkit-text-fill-color: #fff !important;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: #fff;
}

/* ── Consent Checkbox ── */
.modal__consent {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    cursor: pointer;
}

.modal__consent input {
    display: none;
}

.modal__consent-check {
    width: 20px;
    height: 20px;
    min-width: 20px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal__consent-check::after {
    content: '';
    width: 0;
    height: 0;
    background: #16120e;
    border-radius: 50%;
    transition: 0.2s;
}

.modal__consent input:checked+.modal__consent-check {
    background: #e8d6ac;
}

.modal__consent input:checked+.modal__consent-check::after {
    width: 8px;
    height: 8px;
}

.modal__consent-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.modal__consent-text a {
    color: inherit;
    text-decoration: underline;
}

/* ── Submit Button ── */
.modal__submit {
    align-self: center;
    height: 41px;
    border-radius: 58px;
    border: 1.45px solid #f6b66b;
    background: #a98058;
    color: #fff;
    font-family: var(--font-primary);
    font-size: 14px;
    cursor: pointer;
    transition: 0.3s;
    padding: 15px 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    box-sizing: border-box;
}

.modal__submit:hover {
    background: #b88d64;
}

/* ── Submit Button — Disabled ── */
.modal__submit:disabled,
.modal__submit.disabled {
    border: 1.15px solid #7a7a7a;
    border-radius: 46px;
    background: #525252;
    cursor: not-allowed;
    opacity: 1;
    color: #fff;
}

.modal__submit:disabled:hover,
.modal__submit.disabled:hover {
    background: #525252;
}

/* ── Success Modal ── */
.modal--success {
    text-align: center;
    align-items: center;
    justify-content: center;
    width: 474px;
    height: 301px;
    min-height: 301px;
    border-radius: 15px;
    box-shadow: 0 2px 18px 0 rgba(0, 0, 0, 0.2);
    background: linear-gradient(180deg, #322a22 0%, #16120e 66.67%);
    padding: 40px;
}

.modal__success-icon {
    margin-bottom: 6px;
}

.modal__success-title {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 24px;
    line-height: 130%;
    text-transform: uppercase;
    text-align: center;
    color: #fff;
    margin: 0 0 12px;
}

.modal__success-text {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 14px;
    line-height: 120%;
    text-align: center;
    color: #fff;
}

/* ── Centered Modal Content (legacy fallback) ── */
.modal--centered {
    text-align: center;
    align-items: center;
    min-height: 355px;
}

.modal--centered .modal__fields {
    justify-content: center;
    width: 100%;
}

.modal--centered .modal__consent {
    justify-content: center;
}

/* ── 3D Model Modal Specifics ── */
.modal--3d {
    min-height: 355px;
}

.modal--3d .modal__fields {
    margin-top: 0;
}

/* ── Prevent scroll ── */
body.modal-open {
    overflow: hidden;
}

/* ============================================
   MODAL — MOBILE (≤991px)
   ============================================ */
@media (max-width: 991px) {
    .modal-overlay {
        padding: 20px;
        align-items: center;
    }

    .modal {
        width: 100%;
        max-width: 100%;
        min-height: auto;
        height: auto;
        max-height: calc(100vh - 40px);
        padding: 45px 44px;
        transform: translateY(20px);
        box-shadow: 0 2px 18px 0 rgba(0, 0, 0, 0.2);
        background: linear-gradient(180deg, #322a22 0%, #16120e 66.67%);
    }

    .modal--success {
        min-height: 256px;
        height: 256px;
        width: 100%;
        padding: 30px 24px;
        box-shadow: 0 2px 18px 0 rgba(0, 0, 0, 0.2);
        background: linear-gradient(180deg, #322a22 0%, #16120e 66.67%);
    }

    .modal--centered {
        align-items: center;
        text-align: center;
    }

    .modal--centered .modal__fields {
        justify-content: center;
    }

    .modal--centered .modal__consent {
        justify-content: center;
    }

    .modal__close {
        top: 18px;
        right: 18px;
    }

    .modal__title {
        font-weight: 700;
        font-size: 14px;
        line-height: 95%;
        text-transform: uppercase;
        text-align: center;
        color: #fff;
        margin: 0 0 20px;
        width: 100%;
    }

    .modal__divider {
        background: rgba(255, 255, 255, 0.12);
        height: 1px;
        margin: 0;
    }

    /* ── Product Info (order modal) ── */
    .modal__product {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 0;
    }

    .modal__product-info {
        text-align: left;
        padding: 20px 0;
        font-weight: 400;
        font-size: 14px;
        line-height: 160%;
        color: #fff;
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    }

    .modal__product-right {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 20px 0;
    }

    .modal__quantity-btn {
        width: 31px;
        height: 34px;
    }

    .modal__quantity-value {
        width: 40px;
        height: 34px;
        font-size: 16px;
    }

    .modal__price {
        font-family: var(--font-primary);
        font-weight: 700;
        font-size: 14px;
        line-height: 140%;
        text-align: right;
        color: #f5f5f5;
        white-space: nowrap;
    }

    .modal__price::before {
        content: 'Сумма:';
        display: block;
        font-weight: 700;
        font-size: 14px;
        line-height: 140%;
        color: #f5f5f5;
        margin-bottom: 2px;
    }

    /* ── Product Info (request modal) ── */
    .modal__product-info {
        text-align: left;
        padding: 20px 0;
        font-weight: 400;
        font-size: 14px;
        line-height: 160%;
        color: #fff;
    }

    /* ── Form Fields ── */
    .modal__fields {
        flex-direction: column;
        gap: 7px;
        width: 100%;
        margin-top: 10px;
        margin-bottom: 18px;
    }

    .modal__input {
        width: 100% !important;
        max-width: none;
        height: 44px !important;
        min-height: 44px !important;
        border-radius: 30px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        padding: 0 20px !important;
        box-sizing: border-box !important;
        background: #16120e !important;
        backdrop-filter: blur(4.85px);
        -webkit-backdrop-filter: blur(4.85px);
        box-shadow: inset 1px 2px 4px 0 rgba(0, 0, 0, 0.5) !important;
        font-weight: 400;
        font-size: 13px;
        color: #fff;
        -webkit-appearance: none;
        appearance: none;
    }

    .modal__input::placeholder {
        color: rgba(255, 255, 255, 0.45);
    }

    .modal__consent {
        margin-bottom: 25px;
        gap: 10px;
    }

    .modal__consent-check {
        width: 22px;
        height: 22px;
        min-width: 22px;
    }

    .modal__consent-text {
        font-size: 11px;
        line-height: 140%;
        color: rgba(255, 255, 255, 0.5);
    }

    .modal__submit {
        width: 171px;
        height: 41px;
        padding: 15px 21px;
        font-weight: 400;
        font-size: 14px;
        line-height: 120%;
        color: #fff;
        margin-top: 0;
        align-self: center;
    }
}