/* ==========================================================================
   BonusPlus Loyalty System - Modal Window Styles
   Light / Dark Themes with Modal Form Aesthetics
   ========================================================================== */

@keyframes bpModalPop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.bp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bp-modal-overlay-bg, rgba(15, 23, 42, 0.65));
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-sizing: border-box;
}

.bp-modal-content {
    background: var(--bp-bg-card, #ffffff);
    color: var(--bp-text-primary, #1e293b);
    border: 1px solid var(--bp-border-card, #e2e8f0);
    padding: 18px 22px;
    border-radius: var(--bp-radius-card, 14px);
    width: 420px;
    max-width: 92%;
    box-shadow: var(--bp-shadow-modal, 0 16px 40px rgba(0, 0, 0, 0.2));
    box-sizing: border-box;
    position: relative;
    animation: bpModalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

:root[data-bp-theme="dark"] .bp-modal-content,
[data-bp-theme="dark"] .bp-modal-content,
.bp-modal-content.bp-theme-dark,
.bp-modal-overlay.bp-theme-dark .bp-modal-content {
    background: #252830;
    color: #f3f4f6;
    border-color: #383c48;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.bp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 10px;
}

.bp-modal-header legend {
    margin: 0;
    padding: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--bp-text-primary, #1e293b);
    border: none;
    display: block;
    width: auto;
}

:root[data-bp-theme="dark"] .bp-modal-header legend,
[data-bp-theme="dark"] .bp-modal-header legend,
.bp-theme-dark .bp-modal-header legend {
    color: #f3f4f6;
}

.bp-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--bp-text-primary, #1e293b);
    margin: 0;
    line-height: 1.35;
}

.bp-modal-close,
.close.close-bpm,
.close.js-close-date-modal {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--bp-text-secondary, #64748b);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    flex-shrink: 0;
    user-select: none;
    padding: 0;
    margin: -4px -4px 0 0;
}

.bp-modal-close:hover,
.close.close-bpm:hover,
.close.js-close-date-modal:hover {
    background: var(--bp-btn-flat-bg, #f1f5f9);
    color: var(--bp-text-primary, #1e293b);
}

:root[data-bp-theme="dark"] .bp-modal-close:hover,
[data-bp-theme="dark"] .bp-modal-close:hover,
.bp-theme-dark .bp-modal-close:hover {
    background: #373c49;
    color: #f3f4f6;
}

.bp-modal-body {
    display: flex;
    flex-direction: column;
}

/* Modal Inputs, Selects & Textfields */
.bp-modal-content .bp-mui-textfield,
.bp-modal-content .bp-mui-select,
.bp-modal-content .mui-textfield,
.bp-modal-content .mui-select {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
    position: relative;
}

.bp-modal-content label {
    display: block;
    color: var(--bp-text-secondary, #64748b);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 3px;
    padding: 0;
}

:root[data-bp-theme="dark"] .bp-modal-content label,
[data-bp-theme="dark"] .bp-modal-content label,
.bp-theme-dark .bp-modal-content label {
    color: #a1a7b5;
}

.bp-modal-content input,
.bp-modal-content select {
    box-sizing: border-box;
    display: block;
    background-color: var(--bp-bg-input, #ffffff);
    color: var(--bp-text-primary, #1e293b);
    border: 1px solid var(--bp-border-input, #cbd5e1);
    outline: none;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--bp-radius-input, 8px);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    height: 38px;
    min-height: 38px;
    box-shadow: var(--bp-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.bp-modal-content select {
    padding-right: 32px;
    cursor: pointer;
}

.bp-modal-content input:focus,
.bp-modal-content select:focus {
    border-color: var(--infopush-bonusplus-site-color, #007bff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--infopush-bonusplus-site-color, #007bff) 22%, transparent);
}

:root[data-bp-theme="dark"] .bp-modal-content input,
:root[data-bp-theme="dark"] .bp-modal-content select,
[data-bp-theme="dark"] .bp-modal-content input,
[data-bp-theme="dark"] .bp-modal-content select,
.bp-theme-dark .bp-modal-content input,
.bp-theme-dark .bp-modal-content select {
    background-color: #1d2027;
    color: #f3f4f6;
    border-color: #424754;
}

.bp-modal-content select option {
    background: transparent;
    background-color: transparent;
    color: var(--bp-text-primary, inherit);
    padding: 6px 10px;
}

/* Compact BonusPlus-themed CAPTCHA */
.bp-captcha-container {
    z-index: 100004;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.bp-captcha-popup {
    width: 420px;
    max-width: 92%;
    padding: 18px 22px;
    border: 1px solid var(--bp-border-card, #e2e8f0);
    border-radius: var(--bp-radius-card, 14px);
    background: var(--bp-bg-card, #ffffff);
    color: var(--bp-text-primary, #1e293b);
    box-shadow: var(--bp-shadow-modal, 0 16px 40px rgba(0, 0, 0, 0.2));
    font-family: inherit;
}

.bp-captcha-title {
    padding: 0 38px 0 0;
    color: inherit;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    text-align: left;
}

.bp-captcha-body {
    margin: 3px 0 12px;
    padding: 0;
    text-align: left;
}

.bp-captcha-desc {
    margin: 0 0 14px;
    color: var(--bp-text-secondary, #64748b);
    font-size: 12px;
    line-height: 1.45;
}

.bp-captcha-image {
    display: block;
    width: auto;
    max-width: 170px;
    height: 48px;
    margin: 0 auto;
    border: 1px solid var(--bp-border-input, #cbd5e1);
    border-radius: 8px;
    background: #ffffff;
    object-fit: contain;
}

.bp-captcha-image-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    margin: 0 0 14px;
}

.bp-captcha-refresh {
    margin: 0;
    padding: 2px 4px;
    border: 0;
    background: transparent;
    color: var(--infopush-bonusplus-site-color, #007bff);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    line-height: 1.35;
    text-decoration: underline;
}

.bp-captcha-refresh:hover {
    color: var(--infopush-bonusplus-site-color-hover, #0056b3);
}

.bp-captcha-refresh:disabled {
    cursor: wait;
    opacity: 0.55;
}

.bp-captcha-input-label {
    width: 100%;
    margin: 0 0 4px;
    justify-content: flex-start;
    color: var(--bp-text-secondary, #64748b);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    text-align: left;
}

.bp-captcha-input {
    box-sizing: border-box;
    width: 100%;
    height: 38px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--bp-border-input, #cbd5e1);
    border-radius: var(--bp-radius-input, 8px);
    background: var(--bp-bg-input, #ffffff);
    color: var(--bp-text-primary, #1e293b);
    box-shadow: var(--bp-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
    font-size: 14px;
}

.bp-captcha-error {
    width: 100%;
    margin: 6px 0 0;
    padding: 0;
    justify-content: flex-start;
    background: transparent;
    box-shadow: none;
    color: #ef4444;
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
}

.bp-captcha-error::before {
    display: none;
}

.bp-captcha-input:focus {
    border-color: var(--infopush-bonusplus-site-color, #007bff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--infopush-bonusplus-site-color, #007bff) 22%, transparent);
}

.bp-captcha-actions {
    width: 100%;
    margin: 16px 0 0;
    gap: 10px;
    justify-content: flex-end;
}

.bp-captcha-close {
    top: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: var(--bp-text-secondary, #64748b);
    font-size: 24px;
    line-height: 1;
}

.bp-captcha-close:hover {
    background: var(--bp-btn-flat-bg, #f1f5f9);
    color: var(--bp-text-primary, #1e293b);
}

.bp-captcha-confirm,
.bp-captcha-cancel {
    min-height: 36px;
    margin: 0;
    padding: 0 15px;
    border-radius: var(--bp-radius-btn, 8px);
    font-size: 13px;
    font-weight: 600;
}

.bp-captcha-confirm {
    background: var(--infopush-bonusplus-site-color, #007bff);
    color: var(--infopush-bonusplus-text-color, #ffffff);
}

.bp-captcha-confirm:hover {
    background: var(--infopush-bonusplus-site-color-hover, #0056b3);
}

.bp-captcha-cancel {
    background: var(--bp-btn-flat-bg, #f1f5f9);
    color: var(--bp-text-primary, #1e293b);
}

.bp-captcha-popup.bp-theme-dark {
    background: #252830;
    color: #f3f4f6;
    border-color: #383c48;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.bp-captcha-popup.bp-theme-dark .bp-captcha-input {
    background: #1d2027;
    color: #f3f4f6;
    border-color: #424754;
}

.bp-captcha-popup.bp-theme-dark .bp-captcha-input::placeholder {
    color: #8f96a3;
}

.bp-captcha-popup.bp-theme-dark .bp-captcha-desc,
.bp-captcha-popup.bp-theme-dark .bp-captcha-input-label {
    color: #a1a7b5;
}

.bp-captcha-popup.bp-theme-dark .bp-captcha-close {
    color: #a1a7b5;
}

.bp-captcha-popup.bp-theme-dark .bp-captcha-close:hover {
    background: #373c49;
    color: #f3f4f6;
}

.bp-captcha-popup.bp-theme-dark .bp-captcha-cancel {
    background: #373c49;
    color: #f3f4f6;
}

@media (max-width: 420px) {
    .bp-captcha-popup {
        padding: 16px;
    }

    .bp-captcha-actions {
        flex-direction: column-reverse;
    }

    .bp-captcha-confirm,
    .bp-captcha-cancel {
        width: 100%;
    }
}

:root[data-bp-theme="dark"] .bp-modal-content select option,
[data-bp-theme="dark"] .bp-modal-content select option,
.bp-theme-dark .bp-modal-content select option {
    background: transparent;
    background-color: transparent;
    color: #f3f4f6;
}

:root[data-bp-theme="light"] .bp-modal-content select option,
[data-bp-theme="light"] .bp-modal-content select option,
.bp-theme-light .bp-modal-content select option {
    background: transparent;
    background-color: transparent;
    color: #1e293b;
}

/* Modal Buttons & Footer */
.bp-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
}

.bp-modal-content .bp-mui-btn,
.bp-modal-content button.bp-mui-btn,
.bp-modal-content button,
.bp-modal-overlay .bp-mui-btn,
.bp-modal-overlay button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    color: var(--bp-text-primary, #1e293b);
    background-color: var(--bp-btn-flat-bg, #f1f5f9);
    height: 38px;
    min-height: 38px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--bp-radius-btn, 8px);
    cursor: pointer;
    text-align: center;
    text-transform: none;
    white-space: nowrap;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: none;
    box-sizing: border-box;
}

.bp-modal-footer button.bp-d-none,
.bp-modal-content .bp-d-none,
.bp-modal-overlay .bp-d-none,
.bp-modal-content [style*="display: none"],
.bp-modal-overlay [style*="display: none"],
.bp-d-none {
    display: none;
}

.bp-modal-content .bp-mui-btn--flat,
.bp-modal-content button.bp-mui-btn--flat,
.bp-modal-content .close-bpm,
.bp-modal-overlay .bp-mui-btn--flat,
.bp-modal-overlay button.bp-mui-btn--flat,
.bp-modal-overlay .close-bpm {
    background-color: var(--bp-btn-flat-bg, #f1f5f9);
    color: var(--bp-text-primary, #1e293b);
    border: 1px solid transparent;
}

.bp-modal-content .bp-mui-btn--flat:hover,
.bp-modal-content button.bp-mui-btn--flat:hover,
.bp-modal-content .close-bpm:hover,
.bp-modal-overlay .bp-mui-btn--flat:hover,
.bp-modal-overlay button.bp-mui-btn--flat:hover,
.bp-modal-overlay .close-bpm:hover {
    background-color: var(--bp-btn-flat-bg-hover, #e2e8f0);
    color: var(--bp-text-primary, #1e293b);
}

.bp-modal-content .bp-mui-btn--primary,
.bp-modal-content .bp-mui-btn--raised.bp-mui-btn--primary,
.bp-modal-content .bp-btn-primary,
.bp-modal-content button.bp-btn-primary,
.bp-modal-content button.bp-mui-btn--primary,
.bp-modal-overlay .bp-mui-btn--primary,
.bp-modal-overlay .bp-btn-primary,
.bp-modal-overlay button.bp-btn-primary,
#confirm_bp_modal,
#send_bp_modal,
.js-save-modal-date {
    background-color: var(--infopush-bonusplus-site-color, #007bff);
    color: var(--infopush-bonusplus-text-color, #ffffff);
    border: 1px solid var(--infopush-bonusplus-site-color, #007bff);
}

.bp-modal-content .bp-mui-btn--primary:hover,
.bp-modal-content .bp-mui-btn--raised.bp-mui-btn--primary:hover,
.bp-modal-content .bp-btn-primary:hover,
.bp-modal-content button.bp-btn-primary:hover,
.bp-modal-content button.bp-mui-btn--primary:hover,
.bp-modal-overlay .bp-mui-btn--primary:hover,
.bp-modal-overlay .bp-btn-primary:hover,
.bp-modal-overlay button.bp-btn-primary:hover,
#confirm_bp_modal:hover,
#send_bp_modal:hover,
.js-save-modal-date:hover {
    background-color: var(--infopush-bonusplus-site-color-hover, #0056b3);
    color: var(--infopush-bonusplus-text-color, #ffffff);
    border-color: var(--infopush-bonusplus-site-color-hover, #0056b3);
}

:root[data-bp-theme="dark"] .bp-modal-content .bp-mui-btn--flat,
:root[data-bp-theme="dark"] .bp-modal-overlay .bp-mui-btn--flat,
:root[data-bp-theme="dark"] .bp-modal-content .close-bpm,
:root[data-bp-theme="dark"] .bp-modal-overlay .close-bpm,
[data-bp-theme="dark"] .bp-modal-content .bp-mui-btn--flat,
[data-bp-theme="dark"] .bp-modal-overlay .bp-mui-btn--flat,
[data-bp-theme="dark"] .bp-modal-content .close-bpm,
[data-bp-theme="dark"] .bp-modal-overlay .close-bpm,
.bp-theme-dark .bp-modal-content .bp-mui-btn--flat,
.bp-theme-dark .bp-modal-overlay .bp-mui-btn--flat,
.bp-theme-dark .bp-modal-content .close-bpm,
.bp-theme-dark .bp-modal-overlay .close-bpm,
.bp-modal-overlay.bp-theme-dark .bp-mui-btn--flat,
.bp-modal-overlay[data-bp-theme="dark"] .bp-mui-btn--flat {
    background-color: #2d313c;
    color: #f3f4f6;
    border-color: #383c48;
}

:root[data-bp-theme="dark"] .bp-modal-content .bp-mui-btn--flat:hover,
:root[data-bp-theme="dark"] .bp-modal-overlay .bp-mui-btn--flat:hover,
:root[data-bp-theme="dark"] .bp-modal-content .close-bpm:hover,
:root[data-bp-theme="dark"] .bp-modal-overlay .close-bpm:hover,
[data-bp-theme="dark"] .bp-modal-content .bp-mui-btn--flat:hover,
[data-bp-theme="dark"] .bp-modal-overlay .bp-mui-btn--flat:hover,
[data-bp-theme="dark"] .bp-modal-content .close-bpm:hover,
[data-bp-theme="dark"] .bp-modal-overlay .close-bpm:hover,
.bp-theme-dark .bp-modal-content .bp-mui-btn--flat:hover,
.bp-theme-dark .bp-modal-overlay .bp-mui-btn--flat:hover,
.bp-theme-dark .bp-modal-content .close-bpm:hover,
.bp-theme-dark .bp-modal-overlay .close-bpm:hover,
.bp-modal-overlay.bp-theme-dark .bp-mui-btn--flat:hover,
.bp-modal-overlay[data-bp-theme="dark"] .bp-mui-btn--flat:hover {
    background-color: #373c49;
    color: #f3f4f6;
}

.bp-modal-submit-btn {
    width: 100%;
}

/* СМС верификация и описания */
.bp-modal-content-sms {
    width: 100%;
    max-width: 400px;
    position: relative;
}

.bp-modal-desc {
    font-size: 13px;
    color: var(--bp-text-secondary, #64748b);
    margin: 4px 0 0;
    line-height: 1.4;
    font-weight: normal;
}

:root[data-bp-theme="dark"] .bp-modal-desc,
[data-bp-theme="dark"] .bp-modal-desc,
.bp-theme-dark .bp-modal-desc {
    color: #a1a7b5;
}

.bp-sms-timer-block {
    text-align: right;
    margin-top: 0;
    font-size: 12px;
    color: var(--bp-text-secondary, #64748b);
}

.bp-link-action {
    color: var(--infopush-bonusplus-site-color, #007bff);
    cursor: pointer;
    text-decoration: underline;
    font-weight: 500;
    transition: opacity 0.2s;
}

.bp-link-action:hover {
    opacity: 0.85;
}

/* Смена pending-номера выглядит как ссылка, а не как кнопка модального footer. */
.bp-modal-content button.bp-registration-change-phone,
.bp-modal-overlay button.bp-registration-change-phone {
    display: block;
    width: fit-content;
    height: auto;
    min-height: 0;
    margin-top: 4px;
    padding: 0;
    justify-content: flex-start;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--infopush-bonusplus-site-color, #007bff);
    box-shadow: none;
    font-size: 12px;
    line-height: 1.3;
    text-decoration: underline;
}

.bp-modal-content button.bp-registration-change-phone:hover,
.bp-modal-overlay button.bp-registration-change-phone:hover {
    background: transparent;
    color: var(--infopush-bonusplus-site-color-hover, var(--infopush-bonusplus-site-color, #007bff));
}

.bp-error-msg {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.bp-modal-content .bp-sms-timer-block {
    order: 1;
    margin-top: 2px;
    margin-bottom: 0;
    line-height: 1.1;
}

.bp-sms-timer-block,
.bp-modal-content .bp-sms-timer-block {
    text-align: right;
    font-size: 11px;
    line-height: 1.1;
    color: var(--bp-text-secondary, #64748b);
}

/* Утилиты видимости */
.bp-d-none {
    display: none;
}

.bp-d-flex {
    display: flex;
}

.bp-d-block {
    display: block;
}
