/* ورودی OTP انیمیشنی — الهام code.xr / family-style OTP */

.xr-otp {
    --xr-otp-accent: #2a78b8;
    --xr-otp-accent-soft: rgba(42, 120, 184, 0.22);
    --xr-otp-error: #e53935;
    --xr-otp-success: #2e7d32;
    --xr-otp-slot-bg: #f4f8fc;
    --xr-otp-slot-border: rgba(42, 120, 184, 0.2);
    position: relative;
    width: 100%;
    direction: ltr;
    text-align: center;
    user-select: none;
}

.xr-otp__capture {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
    left: -9999px;
}

.xr-otp__slots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    flex-wrap: nowrap;
    cursor: text;
    padding: 0.15rem 0;
}

.xr-otp__sep {
    width: 0.65rem;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, var(--xr-otp-accent), transparent);
    opacity: 0.55;
    flex-shrink: 0;
    margin: 0 0.1rem;
}

.xr-otp__slot {
    position: relative;
    flex-shrink: 0;
}

.xr-otp__slot-inner {
    position: relative;
    width: 2.65rem;
    height: 3.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--xr-otp-slot-bg);
    border: 2px solid var(--xr-otp-slot-border);
    box-shadow: 0 4px 14px rgba(8, 34, 72, 0.08);
    transition:
        transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.2s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
    overflow: hidden;
}

.xr-otp__slot--active .xr-otp__slot-inner {
    transform: scale(1.06);
    border-color: var(--xr-otp-accent);
    background: #fff;
    box-shadow: 0 8px 22px var(--xr-otp-accent-soft);
}

.xr-otp__slot--filled .xr-otp__slot-inner {
    background: #fff;
    border-color: rgba(42, 120, 184, 0.45);
}

.xr-otp__slot--error .xr-otp__slot-inner {
    border-color: var(--xr-otp-error);
    background: #fff5f5;
}

.xr-otp__slot--verify .xr-otp__slot-inner {
    animation: xr-otp-verify-pulse 0.55s ease-in-out infinite;
    animation-delay: calc(var(--xr-i, 0) * 70ms);
}

.xr-otp__digit {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.45rem;
    font-weight: 800;
    font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
    color: #0a1224;
    line-height: 1;
}

.xr-otp__digit-val {
    position: relative;
    z-index: 2;
    display: inline-block;
    min-width: 0.65rem;
    text-align: center;
}

.xr-otp__digit-val--pop {
    animation: xr-otp-digit-pop 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.xr-otp__digit-ph {
    position: absolute;
    z-index: 1;
    color: rgba(10, 18, 36, 0.14);
    font-weight: 700;
    pointer-events: none;
}

.xr-otp__slot--filled .xr-otp__digit-ph {
    opacity: 0;
    transform: translateY(-120%);
    transition: opacity 0.15s ease, transform 0.2s ease;
}

.xr-otp__ring {
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    border: 3px solid var(--xr-otp-accent);
    pointer-events: none;
    animation: xr-otp-ring-breathe 1.35s ease-in-out infinite;
    z-index: 3;
}

.xr-otp__caret {
    position: absolute;
    bottom: 0.55rem;
    left: 50%;
    width: 1px;
    height: 1.1rem;
    background: var(--xr-otp-accent);
    transform: translateX(-50%);
    animation: xr-otp-caret 1s step-end infinite;
    z-index: 4;
}

.xr-otp--shake .xr-otp__slots {
    animation: xr-otp-shake 0.58s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.xr-otp--error-flash .xr-otp__slot-inner {
    animation: xr-otp-error-pulse 0.42s ease-in-out 3;
}

.xr-otp--error-flash .xr-otp__digit-val {
    color: var(--xr-otp-error);
}

.xr-otp--success .xr-otp__slot-inner {
    border-color: var(--xr-otp-success);
    background: #f1faf3;
}

.xr-otp--disabled {
    opacity: 0.65;
    pointer-events: none;
}

@keyframes xr-otp-digit-pop {
    0% {
        opacity: 0;
        transform: translateY(110%) scale(0.75) rotate(6deg);
    }
    55% {
        opacity: 1;
        transform: translateY(-8%) scale(1.08) rotate(-2deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
    }
}

@keyframes xr-otp-ring-breathe {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.72; transform: scale(1.02); }
}

@keyframes xr-otp-caret {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes xr-otp-shake {
    0%, 100% { transform: translateX(0); }
    12% { transform: translateX(-6px) rotate(-1deg); }
    24% { transform: translateX(6px) rotate(1deg); }
    36% { transform: translateX(-5px); }
    48% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    72% { transform: translateX(3px); }
}

@keyframes xr-otp-error-pulse {
    0%, 100% {
        border-color: var(--xr-otp-error);
        background: #fff5f5;
        box-shadow: 0 0 0 rgba(229, 57, 53, 0);
    }
    50% {
        border-color: #ff5252;
        background: #ffebee;
        box-shadow: 0 0 14px rgba(229, 57, 53, 0.35);
    }
}

@keyframes xr-otp-verify-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.97); }
}

@media (max-width: 420px) {
    .xr-otp__slot-inner {
        width: 2.35rem;
        height: 2.85rem;
    }

    .xr-otp__slots {
        gap: 0.4rem;
    }

    .xr-otp__digit {
        font-size: 1.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .xr-otp__digit-val--pop,
    .xr-otp__ring,
    .xr-otp__caret,
    .xr-otp__slot--verify .xr-otp__slot-inner,
    .xr-otp--shake .xr-otp__slots {
        animation: none !important;
    }

    .xr-otp__slot--active .xr-otp__slot-inner {
        transform: none;
    }
}
