/* ==========================================================================
   Popup Styles (Bitrix Module popup)
   ========================================================================== */

/* 1. Backdrop Overlay with Darkening and Optimized Blur */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    width: 100vw;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    background-color: rgba(10, 18, 36, 0.65);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    will-change: opacity, visibility;
    transform: translateZ(0);
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
}

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

/* 2. Main Modal Card Container */
.popup-container {
    position: relative;
    width: 100%;
    max-width: 1080px;
    max-height: calc(100dvh - 32px);
    max-height: calc(100vh - 32px);
    background: #ffffff;
    border: 2px solid #2563eb;
    border-radius: 28px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(37, 99, 235, 0.1);
    box-sizing: border-box;
    will-change: transform;
    transform: translateZ(0) scale(0.95) translateY(8px);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: auto;
}

.popup-overlay.popup-is-active .popup-container {
    transform: translateZ(0) scale(1) translateY(0);
}

.popup-inner {
    padding: 36px 44px 38px 44px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 3. Close Button */
.popup-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s ease;
    z-index: 20;
    padding: 0;
}

.popup-close:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

.popup-close svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* 4. Top Header Badges */
.popup-header-badges {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.popup-badge-shield {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #eff6ff;
    color: #2563eb;
    padding: 7px 15px;
    border-radius: 100px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1px solid #dbeafe;
}

.popup-shield-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

/* 5. Main Title & Subtitle */
.popup-content-block {
    margin-bottom: 26px;
}

.popup-main-title {
    margin: 0 0 10px 0 !important;
    padding: 0 !important;
    font-size: 30px !important;
    line-height: 1.25 !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    letter-spacing: -0.025em !important;
}

.popup-main-subtitle {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 15px !important;
    line-height: 1.55 !important;
    color: #475569 !important;
    font-weight: 400 !important;
    max-width: 980px;
}

/* 6. Form Row & Inputs */
.popup-form {
    margin: 0;
    padding: 0;
}

.popup-form-row {
    display: flex;
    flex-direction: row;
    gap: 14px;
    align-items: stretch;
    width: 100%;
}

.popup-input-group {
    flex: 1 1 0;
    min-width: 0;
    position: relative;
}

.popup-name-group {
    flex: 1.1 1 0;
}

.popup-phone-group {
    flex: 1.1 1 0;
}

.popup-btn-group {
    flex: 1.35 1 0;
    min-width: 190px;
}

.popup-input {
    width: 100% !important;
    height: 54px !important;
    min-height: 54px !important;
    padding: 0 20px !important;
    box-sizing: border-box !important;
    background: #f8fafc !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 14px !important;
    font-size: 15px !important;
    color: #0f172a !important;
    font-family: inherit !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
}

.popup-input:hover {
    border-color: #94a3b8 !important;
    background: #ffffff !important;
}

.popup-input:focus {
    border-color: #2563eb !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14) !important;
}

.popup-input.popup-error {
    border-color: #ef4444 !important;
    background: #fff8f8 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.popup-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

/* 7. Submit Action Button */
.popup-btn-submit {
    width: 100% !important;
    height: 54px !important;
    min-height: 54px !important;
    padding: 0 20px !important;
    box-sizing: border-box !important;
    background: #ff5722 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 14px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 0 4px 14px rgba(255, 87, 34, 0.32) !important;
    font-family: inherit !important;
    text-transform: uppercase;
    user-select: none;
    -webkit-user-select: none;
    white-space: nowrap;
}

.popup-btn-submit:hover {
    background: #f4511e !important;
    transform: translateY(-1.5px) !important;
    box-shadow: 0 6px 20px rgba(255, 87, 34, 0.42) !important;
}

.popup-btn-submit:active {
    transform: translateY(0.5px) !important;
    box-shadow: 0 2px 8px rgba(255, 87, 34, 0.3) !important;
}

.popup-btn-submit:disabled,
.popup-btn-submit.is-loading {
    opacity: 0.75;
    cursor: not-allowed !important;
    transform: none !important;
}

.popup-phone-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* 8. Consent Agreement Checkbox */
.popup-consent-block {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
}

.popup-checkbox-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Скрываем стандартный инпут с сохранением доступности */
.popup-overlay input[type="checkbox"].popup-checkbox,
#popup-input-consent.popup-checkbox,
.popup-checkbox {
    position: absolute;
    opacity: 0;
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    z-index: 2;
}

/* Кастомный чекбокс */
.popup-checkbox-custom {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid #cbd5e1;
    background: #f8fafc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.popup-checkbox-wrapper:hover .popup-checkbox-custom {
    border-color: #94a3b8;
    background: #ffffff;
}

.popup-checkbox:checked + .popup-checkbox-custom,
.popup-checkbox-custom.is-checked {
    background: #2563eb;
    border-color: #2563eb;
}

.popup-checkbox:focus-visible + .popup-checkbox-custom {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.popup-checkbox-icon {
    color: #ffffff;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    stroke-width: 3.5px;
    width: 12px;
    height: 12px;
}

.popup-checkbox:checked + .popup-checkbox-custom .popup-checkbox-icon,
.popup-checkbox-custom.is-checked .popup-checkbox-icon {
    opacity: 1;
    transform: scale(1);
}

.popup-consent-text {
    font-size: 12.5px;
    line-height: 1.45;
    color: #64748b;
    margin: 0;
    user-select: none;
}

.popup-consent-text a {
    color: #2563eb !important;
    text-decoration: underline !important;
    text-underline-offset: 2px !important;
    transition: color 0.15s ease !important;
}

.popup-consent-text a:hover {
    color: #1d4ed8 !important;
}

/* 9. Feedback Status Messages */
.popup-form-status {
    margin-top: 14px;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    animation: popupFadeIn 0.25s ease-out;
}

.popup-form-status.popup-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.popup-form-status.popup-error-msg {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 10. Responsive Design */
@media (max-width: 900px) {
    .popup-inner {
        padding: 30px 28px 32px 28px;
    }
    .popup-main-title {
        font-size: 26px !important;
    }
    .popup-form-row {
        flex-wrap: wrap;
        gap: 12px;
    }
    .popup-btn-group {
        flex: 1 1 100%;
        min-width: 100%;
    }
    .popup-btn-submit {
        width: 100% !important;
    }
}

@media (max-width: 640px) {
    .popup-overlay {
        padding: 12px;
        align-items: flex-end;
    }
    .popup-container {
        border-radius: 22px;
        max-height: 94dvh;
        max-height: 94vh;
        border-width: 1.5px;
    }
    .popup-inner {
        padding: 24px 18px 24px 18px;
    }
    .popup-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
    }
    .popup-close svg {
        width: 16px;
        height: 16px;
    }
    .popup-header-badges {
        margin-bottom: 14px;
    }
    .popup-badge-shield {
        font-size: 12px;
        padding: 5px 12px;
    }
    .popup-shield-icon {
        width: 15px;
        height: 15px;
    }
    .popup-content-block {
        margin-bottom: 18px;
    }
    .popup-main-title {
        font-size: 22px !important;
        line-height: 1.25 !important;
        margin-bottom: 8px !important;
    }
    .popup-main-subtitle {
        font-size: 13.5px !important;
        line-height: 1.45 !important;
    }
    .popup-form {
        margin-top: 0;
    }
    .popup-form-row {
        flex-direction: column;
        gap: 10px;
    }
    .popup-btn-group {
        min-width: 100%;
    }
    .popup-input,
    .popup-btn-submit {
        height: 48px !important;
        min-height: 48px !important;
        border-radius: 12px !important;
        font-size: 14.5px !important;
    }
    .popup-input {
        padding: 0 16px !important;
    }
    .popup-btn-submit {
        padding: 0 16px !important;
    }
    .popup-consent-block {
        margin-top: 14px;
        gap: 8px;
    }
    .popup-checkbox-wrapper {
        margin-top: 2px;
    }
    .popup-checkbox-custom {
        width: 17px;
        height: 17px;
    }
    .popup-checkbox-icon {
        width: 11px;
        height: 11px;
    }
    .popup-consent-text {
        font-size: 11.5px;
        line-height: 1.4;
    }
}

@media (max-width: 380px) {
    .popup-overlay {
        padding: 8px;
    }
    .popup-container {
        border-radius: 18px;
    }
    .popup-inner {
        padding: 20px 14px 20px 14px;
    }
    .popup-header-badges {
        margin-bottom: 10px;
    }
    .popup-content-block {
        margin-bottom: 14px;
    }
    .popup-main-title {
        font-size: 19px !important;
    }
    .popup-main-subtitle {
        font-size: 12.5px !important;
    }
    .popup-form {
        margin-top: 0;
    }
    .popup-form-row {
        gap: 8px;
    }
    .popup-input,
    .popup-btn-submit {
        height: 46px !important;
        min-height: 46px !important;
        font-size: 14px !important;
    }
    .popup-consent-block {
        margin-top: 12px;
    }
    .popup-checkbox-custom {
        width: 16px;
        height: 16px;
    }
    .popup-checkbox-icon {
        width: 10px;
        height: 10px;
    }
    .popup-consent-text {
        font-size: 11px;
    }
}
