/* ==========================================================================
   חלון כניסה עם קוד אימות ב-SMS או במייל.
   הצבעים והגופן מתואמים לטוקנים של האתר: ירוק #39B54A, טקסט #4D4D4D,
   רקע חלון #f8f8f8 וגופן FbAbsolutiHeb.
   ========================================================================== */

.otp-root {
    --otp-brand: #39B54A;
    --otp-brand-hover: #2E9C3E;
    --otp-brand-tint: rgba(57, 181, 74, 0.08);
    --otp-title: #39B54A;
    --otp-text: #4D4D4D;
    --otp-text-muted: #6b6b6b;
    --otp-placeholder: #9a9a9a;
    --otp-danger: #c62828;
    --otp-modal-bg: #f8f8f8;
    --otp-field-bg: #ffffff;
    --otp-border: #d6d6d6;
    --otp-overlay: rgba(0, 0, 0, 0.45);
    --otp-focus: 0 0 0 3px rgba(57, 181, 74, 0.35);
    --otp-radius-modal: 28px;
    --otp-radius-option: 14px;
    --otp-radius-pill: 999px;
    --otp-content: 480px;
    /* בדיוק הגופן של body ב-styles.css, כדי שהחלון לא ייראה שונה משאר האתר. */
    --otp-font: 'FbAbsolutiHeb-Light', Arial, sans-serif;
}

.otp-root *,
.otp-root *::before,
.otp-root *::after {
    box-sizing: border-box;
}

/* בלי זה display:flex של השכבה גובר על התכונה hidden והחלון לא נסגר */
.otp-root [hidden] {
    display: none !important;
}

/* ---------- שכבת רקע + חלון ---------- */
.otp-overlay {
    position: fixed;
    inset: 0;
    background: var(--otp-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1100;
    direction: rtl;
    text-align: right;
}

.otp-modal {
    position: relative;
    width: 100%;
    max-width: 580px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--otp-modal-bg);
    border-radius: var(--otp-radius-modal);
    padding: 36px 40px 34px;
    color: var(--otp-text);
    font-family: var(--otp-font);
}

.otp-close {
    position: absolute;
    top: 22px;
    inset-inline-end: 22px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--otp-text);
    background: transparent;
    color: var(--otp-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.otp-title {
    margin: 4px 0 24px;
    text-align: center;
    color: var(--otp-title);
    font-size: 30px;
    font-weight: 500;
    line-height: 1.2;
}

/* ---------- בחירת ערוץ ---------- */
.otp-channel {
    border: 0;
    margin: 0 0 32px;
    padding: 0;
}

.otp-channel legend {
    width: 100%;
    text-align: center;
    font-size: 15px;
    margin-bottom: 10px;
    padding: 0;
    float: none;
}

.otp-channel-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: var(--otp-content);
    margin: 0 auto;
}

.otp-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--otp-border);
    border-radius: var(--otp-radius-option);
    background: var(--otp-field-bg);
    font-size: 15px;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.otp-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.otp-radio {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 2px solid #9a9a9a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.otp-option svg {
    flex-shrink: 0;
    display: block;
}

.otp-option:has(input:checked) {
    border: 2px solid var(--otp-brand);
    padding: 9px 13px;
    background: var(--otp-brand-tint);
}

.otp-option:has(input:checked) .otp-radio {
    border-color: var(--otp-brand);
}

.otp-option:has(input:checked) .otp-radio::after {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--otp-brand);
}

.otp-option:has(input:focus-visible) {
    box-shadow: var(--otp-focus);
}

/* ---------- שדות ---------- */
.otp-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    max-width: var(--otp-content);
    margin: 0 auto;
}

.otp-field label {
    display: block;
    text-align: center;
    font-size: 15px;
    margin-bottom: 6px;
}

.otp-input {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--otp-radius-pill);
    background: var(--otp-field-bg);
    color: var(--otp-text);
    font-family: inherit;
    font-size: 15px;
    text-align: center;
}

.otp-input::placeholder {
    color: var(--otp-placeholder);
}

.otp-input:focus {
    outline: none;
    border-color: var(--otp-brand);
    box-shadow: var(--otp-focus);
}

.otp-input[aria-invalid="true"] {
    border-color: var(--otp-danger);
}

.otp-error {
    min-height: 18px;
    margin: 4px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--otp-danger);
}

/* ---------- כפתורים ---------- */
.otp-cta {
    display: block;
    width: 100%;
    max-width: 240px;
    margin: 16px auto 0;
    padding: 12px 24px;
    border: 0;
    border-radius: var(--otp-radius-pill);
    background: var(--otp-brand);
    color: #ffffff;
    font-family: inherit;
    font-size: 18px;
    cursor: pointer;
}

.otp-cta:hover {
    background: var(--otp-brand-hover);
    color: #ffffff;
}

.otp-cta:focus-visible {
    outline: none;
    box-shadow: var(--otp-focus);
}

.otp-cta[disabled] {
    opacity: 0.6;
    cursor: default;
}

.otp-link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--otp-brand);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.otp-link:hover {
    color: var(--otp-brand-hover);
}

.otp-link[disabled] {
    color: var(--otp-text-muted);
    text-decoration: none;
    cursor: default;
}

.otp-link:focus-visible {
    outline: none;
    box-shadow: var(--otp-focus);
    border-radius: 4px;
}

.otp-form-error {
    min-height: 20px;
    margin: 12px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--otp-danger);
}

/* הודעות ריקות לא תופסות מקום מתחת לכפתור */
.otp-form-error:empty,
.otp-status:empty {
    display: none;
}

/* ---------- שלב 2 ---------- */
.otp-step2 {
    text-align: center;
}

.otp-sent-to {
    margin: 0 0 20px;
    font-size: 16px;
    color: var(--otp-text-muted);
}

.otp-sent-to bdi {
    color: var(--otp-text);
    font-weight: 500;
}

.otp-code-wrap {
    position: relative;
    width: 100%;
    max-width: 336px;
    margin: 0 auto;
}

.otp-code-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    border: 0;
    outline: none;
    background: transparent;
    color: transparent;
    caret-color: transparent;
    font-size: 16px; /* מונע זום אוטומטי ב-iOS */
    cursor: text;
}

.otp-boxes {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.otp-box {
    height: 54px;
    border-radius: 12px;
    border: 1px solid var(--otp-border);
    background: var(--otp-field-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 500;
    color: var(--otp-text);
}

.otp-box.is-filled {
    border-color: #a8a8a8;
}

.otp-box.is-active {
    border: 2px solid var(--otp-brand);
    box-shadow: var(--otp-focus);
}

.otp-code-wrap.is-invalid .otp-box {
    border-color: var(--otp-danger);
}

.otp-resend {
    font-size: 15px;
    color: var(--otp-text-muted);
}

.otp-secondary {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin-top: 16px;
}

.otp-status {
    min-height: 20px;
    margin: 10px 0 0;
    font-size: 14px;
    color: var(--otp-text-muted);
}

.otp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 600px) {
    .otp-modal {
        padding: 32px 20px 28px;
        border-radius: 22px;
    }

    .otp-title {
        font-size: 26px;
        /* דוחף את הכותרת מתחת לכפתור הסגירה (X) כדי שלא יישב עליה במובייל */
        margin: 28px 0 20px;
    }

    .otp-fields {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .otp-channel-options {
        grid-template-columns: 1fr;
    }

    .otp-cta {
        max-width: none;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .otp-option,
    .otp-input,
    .otp-cta {
        transition: border-color .15s, background-color .15s, box-shadow .15s;
    }
}
