/* ============================================================
   SignalAds Modal Login — launcher button + modal chrome + form.
   All styles scoped under .sa-modal-login-scope to prevent any
   leak into the rest of the page. Bootstrap styles are loaded
   pre-prefixed (sa-modal-bootstrap.min.css) and apply only here.
   ============================================================ */

.sa-modal-login-scope {
    --sa-accent: #7a9ae6;
    --sa-accent-dark: #6282d6;
    --sa-text: #1f2937;
    --sa-muted: #6b7280;
    --sa-line: #e2e8f0;
    --sa-bg: #ffffff;
    --sa-bg-soft: #f8fafc;
    --sa-success: #16a34a;
    --sa-danger: #dc2626;
    --sa-radius: 10px;
    --sa-font: 'Vazirmatn', 'Tahoma', -apple-system, 'Segoe UI', sans-serif;
    font-family: var(--sa-font);
    direction: rtl;
}

/* ===== Body state when modal is open =====
   All body children EXCEPT the modal scope, our toast wrap, and the admin
   bar are hidden via display:none. The dark overlay becomes the visible
   "clean placeholder" backdrop while the user authenticates. */
body.sa-modal-bg-hidden > *:not(.sa-modal-login-scope):not(.sa-auth-toast-wrap):not(#wpadminbar) {
    display: none !important;
}
body.sa-modal-bg-hidden {
    background: #0f172a !important;
    min-height: 100vh;
}

/* ===== Launcher button (visible on the page) ===== */
.sa-modal-login-scope .sa-modal-login-launcher {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: var(--sa-radius);
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .15s ease, opacity .15s ease;
    box-shadow: 0 6px 14px -4px rgba(122, 154, 230, .45);
    font-family: var(--sa-font);
    line-height: 1;
    text-decoration: none;
}
.sa-modal-login-scope .sa-modal-login-launcher:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px -6px rgba(122, 154, 230, .65);
}
.sa-modal-login-scope .sa-modal-login-launcher:active {
    transform: translateY(0);
    opacity: .92;
}
.sa-modal-login-scope .sa-modal-login-launcher-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sa-modal-login-scope .sa-modal-login-launcher-ic svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* ===== Overlay + dialog ===== */
/* z-index very high to ensure modal sits above sticky headers, admin bar,
   WC cart fragments, and other plugin overlays. */
.sa-modal-login-scope .sa-modal-login-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000 !important;
    background: rgba(15, 23, 42, .6);
    backdrop-filter: blur(2px);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity .18s ease;
}
.sa-modal-login-scope .sa-modal-login-overlay[hidden] {
    display: none !important;
}
.sa-modal-login-scope .sa-modal-login-overlay.is-open {
    opacity: 1;
}

.sa-modal-login-scope .sa-modal-login-dialog {
    background: var(--sa-bg);
    border-radius: 16px;
    box-shadow: 0 25px 60px -10px rgba(15, 23, 42, .35);
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    transform: translateY(-12px);
    transition: transform .22s ease;
    font-family: var(--sa-font);
    color: var(--sa-text);
}
.sa-modal-login-scope .sa-modal-login-overlay.is-open .sa-modal-login-dialog {
    transform: translateY(0);
}

.sa-modal-login-scope .sa-modal-login-dialog--sm { max-width: 380px; }
.sa-modal-login-scope .sa-modal-login-dialog--md { max-width: 460px; }
.sa-modal-login-scope .sa-modal-login-dialog--lg { max-width: 580px; }

.sa-modal-login-scope .sa-modal-login-close {
    position: absolute !important;
    top: 14px !important;
    left: 14px !important;
    width: 36px !important;
    height: 36px !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: rgba(15, 23, 42, .12) !important;
    color: #1f2937 !important;
    cursor: pointer !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    transition: background .15s ease, color .15s ease !important;
    font-family: Arial, sans-serif !important;
    line-height: 1 !important;
}
.sa-modal-login-scope .sa-modal-login-close:hover,
.sa-modal-login-scope .sa-modal-login-close:focus {
    background: #dc2626 !important;
    color: #ffffff !important;
    outline: none !important;
}
.sa-modal-login-scope .sa-modal-login-close-x {
    display: inline-block !important;
    font-size: 26px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    color: inherit !important;
    font-family: Arial, "Helvetica Neue", sans-serif !important;
}
.sa-modal-login-scope .sa-modal-login-close:hover {
    background: var(--sa-danger);
    color: #fff;
}

.sa-modal-login-scope .sa-modal-login-body {
    padding: 32px 28px 24px;
    text-align: center;
    box-sizing: border-box;
}

/* ===== Form-head (logo + title) ===== */
.sa-modal-login-scope .sa-modal-login-form-head {
    margin-bottom: 18px;
}
.sa-modal-login-scope .sa-auth-logo {
    font-size: 3rem;
    color: var(--sa-accent);
    margin: 0 0 8px;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}
.sa-modal-login-scope .sa-auth-logo-icon,
.sa-modal-login-scope .sa-auth-logo svg {
    width: 48px;
    height: 48px;
    display: block;
    color: var(--sa-accent);
}
.sa-modal-login-scope .sa-auth-logo-img {
    display: block;
    max-height: 56px;
    max-width: 220px;
    width: auto;
    height: auto;
    margin: 0 auto 8px;
    object-fit: contain;
}
.sa-modal-login-scope .sa-auth-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--sa-text);
    margin: 0 0 6px;
}
.sa-modal-login-scope .sa-auth-subtitle {
    color: var(--sa-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* ===== Forms ===== */
.sa-modal-login-scope .sa-auth-form {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
}
.sa-modal-login-scope .sa-auth-field {
    margin: 0 0 12px;
    text-align: left;
}
.sa-modal-login-scope .sa-auth-input {
    border-radius: var(--sa-radius) !important;
    border: 1px solid var(--sa-line) !important;
    padding: 12px 14px !important;
    font-size: 14px !important;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
    font-family: var(--sa-font);
    text-align: right !important;
    direction: ltr;
}
.sa-modal-login-scope .sa-auth-input:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(122, 154, 230, .22) !important;
    border-color: var(--sa-accent) !important;
}
.sa-modal-login-scope .sa-auth-otp-input {
    letter-spacing: 0.5em;
    text-align: center !important;
    font-size: 1.1rem !important;
    font-weight: 700;
}

/* ===== Primary button (saturated when enabled) ===== */
.sa-modal-login-scope .sa-auth-btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--sa-accent) 0%, var(--sa-accent-dark) 100%);
    color: #fff;
    border: 0;
    border-radius: var(--sa-radius);
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .2s ease, transform .1s ease, opacity .2s ease, box-shadow .2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    margin: 0 0 12px;
    font-family: var(--sa-font);
    box-shadow: 0 6px 14px -4px rgba(122, 154, 230, .55);
}
.sa-modal-login-scope .sa-auth-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px -6px rgba(122, 154, 230, .7);
}
.sa-modal-login-scope .sa-auth-btn-primary:active {
    transform: translateY(0);
    opacity: .92;
}
.sa-modal-login-scope .sa-auth-btn-primary:disabled {
    background: #cbd5e1 !important;
    color: #f8fafc !important;
    opacity: 0.75;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.sa-modal-login-scope .sa-auth-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    display: inline-block;
    animation: sa-modal-spin .75s linear infinite;
}
@keyframes sa-modal-spin { to { transform: rotate(360deg); } }

/* ===== OTP step hint ===== */
.sa-modal-login-scope .sa-auth-otp-hint {
    color: var(--sa-muted);
    font-size: 0.88rem;
    margin: 8px 0 14px;
}
.sa-modal-login-scope .sa-auth-otp-hint code {
    background: var(--sa-bg-soft);
    padding: 2px 8px;
    border-radius: 4px;
    direction: ltr;
    display: inline-block;
}

/* ===== Link buttons (resend, change phone) ===== */
.sa-modal-login-scope .sa-auth-btn-link {
    background: transparent;
    color: var(--sa-accent);
    border: 0;
    padding: 6px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    margin: 4px 0;
    font-family: var(--sa-font);
}
.sa-modal-login-scope .sa-auth-btn-link:hover:not(:disabled) {
    text-decoration: underline;
}
.sa-modal-login-scope .sa-auth-btn-link:disabled {
    color: var(--sa-muted);
    cursor: not-allowed;
    opacity: .7;
}
/* Resend OTP — prominent pill, visually distinct from the plain link buttons */
.sa-modal-login-scope [data-sa-auth-resend] {
    background: rgba(122, 154, 230, .12);
    color: var(--sa-accent-dark, #6282d6);
    border: 1.5px solid var(--sa-accent, #7a9ae6);
    border-radius: 999px;
    padding: 7px 20px;
    font-weight: 700;
    transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.sa-modal-login-scope [data-sa-auth-resend]:hover:not(:disabled) {
    background: var(--sa-accent, #7a9ae6);
    border-color: var(--sa-accent-dark, #6282d6);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 12px -4px rgba(122, 154, 230, .55);
}
.sa-modal-login-scope [data-sa-auth-resend]:disabled {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #94a3b8;
    opacity: 1;
}
.sa-modal-login-scope .sa-auth-change-phone {
    color: var(--sa-muted);
    font-weight: 500;
    font-size: 12px;
}

/* ===== Footer ===== */
.sa-modal-login-scope .sa-auth-footer {
    margin: 14px 0 0;
    color: var(--sa-muted);
    font-size: 12px;
}
.sa-modal-login-scope .sa-auth-link {
    color: var(--sa-accent);
    text-decoration: none;
    font-weight: 500;
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
    .sa-modal-login-scope .sa-modal-login-dialog {
        max-width: 100% !important;
        margin: 8px;
    }
    .sa-modal-login-scope .sa-modal-login-body {
        padding: 26px 20px 18px;
    }
}
