/* =========================================================
   auth.css — ورود / ثبت‌نام / فراموشی رمز / ورود با کد
   از توکن‌های style.css استفاده می‌کند (تم روشن و تیره)
   ========================================================= */

/* ---------- پوسته ---------- */
.auth {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(1.5rem, env(safe-area-inset-top)) 12px max(1.5rem, env(safe-area-inset-bottom));
}

.auth-shell {
    width: 100%;
    max-width: 440px;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-card {
    position: relative;
    overflow: hidden;
    max-width: none;
    padding: 2.4rem 2rem 1.9rem;
    border-radius: 18px;
    gap: 1.25rem;
}

.auth-back {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem 1rem;
    border-radius: 999px;
    font-size: .9rem;
    color: rgb(255 255 255 / .8);
    transition: background .15s, color .15s;
}

.auth-back:hover,
.auth-back:focus-visible {
    color: #fff;
    background: rgb(255 255 255 / .12);
    outline: 0;
}

/* ---------- لوگو ---------- */
.auth-logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: .25rem;
}

.auth-logo-wrap a {
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.auth-logo {
    display: block;
    max-width: 160px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 0;
}

/* ---------- Autofill ---------- */
.auth-card input:-webkit-autofill,
.auth-card input:-webkit-autofill:hover,
.auth-card input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    transition: background-color 9999s ease-in-out 0s;
}

/* ---------- مراحل ---------- */
.auth-card .step {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: authStep .35s cubic-bezier(.2, .7, .2, 1) both;
}

.auth-card .step > * {
    margin: 0 !important;
}

/* پیام خطای خالی جا اشغال نکند */
.auth-card .step > div:empty {
    display: none;
}

@keyframes authStep {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* سرتیتر هر مرحله */
.step-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    text-align: center;
    padding-bottom: .35rem;
}

.step-icon {
    width: 60px;
    height: 60px;
    display: grid;
    place-items: center;
    margin-bottom: .35rem;
    border-radius: 18px;
    font-size: 1.65rem;
    color: var(--accent);
    background: var(--accent-t);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}

.step-head h1 {
    font-size: 1.3rem;
    font-weight: 800;
}

.step-head p {
    max-width: 32ch;
    font-size: .92rem;
    line-height: 1.95;
    color: var(--muted);
}

.phone-show {
    display: inline-block;
    direction: ltr;
    unicode-bidi: isolate;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--text);
}

/* ---------- فیلدها ---------- */
.field {
    position: relative;
}

.field-icon {
    position: absolute;
    inset-block: 0;
    inset-inline-start: .95rem;
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    color: var(--muted);
    pointer-events: none;
    transition: color .15s;
}

.field:focus-within .field-icon {
    color: var(--primary);
}

.field .form-control {
    min-height: 52px;
    padding-inline-start: 2.8rem;
    border-width: 1.5px;
    border-radius: 12px;
    font-size: 1rem;
}

.field:has(.field-toggle) .form-control {
    padding-inline-end: 3.1rem;
}

/* فقط وقتی مقدار دارد (حروف فارسی placeholder نباید فاصله بگیرند) */
.field-phone .form-control:not(:placeholder-shown) {
    letter-spacing: .08em;
    font-weight: 700;
}

.field-toggle {
    position: absolute;
    inset-block: 0;
    inset-inline-end: .3rem;
    width: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    font-size: 1.15rem;
    color: var(--muted);
    transition: color .15s;
}

.field-toggle:hover {
    color: var(--text);
}

.field-toggle:focus-visible {
    outline: 0;
    box-shadow: var(--ring);
}

.field-hint {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: var(--muted);
}

/* ---------- پیام خطا ---------- */
.auth-card .step > [id^="e-"]:not(:empty),
.auth-card #reset-fields ~ [id^="e-"]:not(:empty) {
    padding: .6rem .85rem;
    border-radius: 10px;
    border-inline-start: 3px solid var(--danger);
    background: var(--danger-t);
    color: var(--danger) !important;
    font-size: .85rem;
    line-height: 1.8;
    animation: authErr .25s ease both;
}

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

/* ---------- دکمهٔ اصلی ---------- */
.auth-card .btn-red {
    position: relative;
    min-height: 52px;
    border-radius: 12px;
    font-size: 1.02rem;
    font-weight: 700;
    box-shadow: 0 10px 20px -10px color-mix(in srgb, var(--primary) 75%, transparent);
    transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
}

.auth-card .btn-red i {
    font-size: 1.15rem;
}

.auth-card .btn-red:not(:disabled):hover {
    transform: translateY(-1px);
}

.auth-card .btn-red:not(:disabled):active {
    transform: translateY(0);
    box-shadow: none;
}

.auth-card .btn-red:disabled {
    box-shadow: none;
}

/* حالت در حال ارسال */
.auth-card .btn-red.is-loading,
.auth-card .btn-red.is-loading:disabled {
    opacity: 1;
    color: transparent !important;
    pointer-events: none;
}

.auth-card .btn-red.is-loading::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid color-mix(in srgb, var(--on-primary) 30%, transparent);
    border-top-color: var(--on-primary);
    animation: authSpin .7s linear infinite;
}

@keyframes authSpin {
    to { transform: rotate(360deg); }
}

/* ---------- گزینه‌های ثانویه (ورود با کد / فراموشی / تغییر شماره) ---------- */
.auth-alt {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .8rem;
    color: var(--muted);
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.auth-card .btn-soft {
    width: 100%;
    min-height: 50px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
    background: var(--primary-t);
    color: var(--primary);
    font-weight: 700;
    white-space: nowrap;
}

.auth-card .btn-soft:hover,
.auth-card .btn-soft:focus-visible,
.auth-card .btn-soft:active {
    background: color-mix(in srgb, var(--primary) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--primary) 35%, transparent);
    color: var(--primary);
}

.auth-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
}

.auth-links--single {
    grid-template-columns: 1fr;
}

.auth-card .btn-ghost {
    min-height: 46px;
    padding: .4rem .6rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
}

.auth-card .btn-ghost:hover,
.auth-card .btn-ghost:focus-visible,
.auth-card .btn-ghost:active {
    border-color: var(--line-2, var(--line));
    background: color-mix(in srgb, var(--primary) 6%, var(--surface));
    color: var(--text);
}

.auth-card .btn-soft i,
.auth-card .btn-ghost i {
    font-size: 1.05rem;
}

/* ---------- خانه‌های کد ---------- */
.otp-box {
    display: flex;
    justify-content: center;
    gap: clamp(6px, 2vw, 12px);
}

.otp-box input {
    flex: 1 1 0;
    min-width: 0;
    max-width: 58px;
    height: 58px;
    padding: 0;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--line-2, var(--line));
    border-radius: 14px;
    outline: none;
    caret-color: var(--accent);
    transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
}

.otp-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
    transform: translateY(-2px);
}

.otp-box input:not(:placeholder-shown) {
    border-color: var(--primary);
    background: var(--primary-t);
}

/* دو input مرحلهٔ فراموشی رمز */
.auth-card #reset-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ---------- موبایل ---------- */
@media (max-width: 575.98px) {
    .auth {
        padding-inline: 10px;
    }

    .auth-card {
        padding: 2rem 1.25rem 1.5rem;
        border-radius: 20px;
        gap: 1.1rem;
    }

    .auth-logo {
        height: 56px;
    }

    .step-icon {
        width: 54px;
        height: 54px;
        font-size: 1.5rem;
    }

    .step-head h1 {
        font-size: 1.2rem;
    }

    /* جلوگیری از زوم خودکار iOS روی input */
    .auth-card .form-control {
        font-size: 16px;
    }

    .otp-box input {
        height: 54px;
        font-size: 1.4rem;
        border-radius: 12px;
    }

    .auth-card .btn-ghost {
        font-size: .86rem;
    }
}

/* صفحهٔ خیلی باریک: گزینه‌ها زیر هم */
@media (max-width: 359.98px) {
    .auth-links {
        grid-template-columns: 1fr;
    }
}

/* ---------- کاهش حرکت ---------- */
@media (prefers-reduced-motion: reduce) {
    .auth-card .step,
    .auth-card [id^="e-"] {
        animation: none;
    }

    .auth-card .btn-red,
    .otp-box input {
        transition: none;
    }

    .auth-card .btn-red.is-loading::after {
        animation-duration: 1.6s;
    }
}