/* =========================================================
   پنجرهٔ ورود / ثبت‌نام با کد یک‌بارمصرف (OTP)
   طراحی شیشه‌ای، هم‌راستا با پوستهٔ اصلی سایت
   ========================================================= */

.auth-modal {
    --am-surface: rgba(255, 255, 255, 0.86);
    --am-surface-2: rgba(255, 255, 255, 0.98);
    --am-line: rgba(15, 23, 42, 0.09);
    --am-line-strong: rgba(15, 23, 42, 0.16);
    --am-text: #0f172a;
    --am-text-soft: #475569;
    --am-danger: #dc2626;
    --am-danger-soft: rgba(220, 38, 38, 0.08);
    --am-success: #16a34a;

    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 20px;
    font-family: inherit;
}

.auth-modal[hidden] {
    display: none;
}

/* ----------------------------- پس‌زمینه ----------------------------- */

.auth-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    opacity: 0;
    transition: opacity 280ms var(--ease, ease);
}

.auth-modal.is-open .auth-modal__backdrop {
    opacity: 1;
}

/* ----------------------------- کادر ----------------------------- */

.auth-modal__dialog {
    position: relative;
    width: min(980px, 100%);
    max-height: min(94dvh, 760px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
    overflow: hidden;
    border-radius: var(--radius-xl, 28px);
    background: var(--am-surface);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow:
        0 44px 100px -34px rgba(15, 23, 42, 0.55),
        0 0 0 1px rgba(15, 23, 42, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    opacity: 0;
    transform: translateY(22px) scale(0.965);
    transition:
        opacity 300ms var(--ease, ease),
        transform 340ms var(--ease, ease);
}

.auth-modal.is-open .auth-modal__dialog {
    opacity: 1;
    transform: none;
}

/* ----------------------------- دکمهٔ بستن ----------------------------- */

.auth-modal__close {
    position: absolute;
    top: 16px;
    inset-inline-end: 16px;
    z-index: 5;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--am-line);
    border-radius: 50%;
    background: var(--am-surface-2);
    color: var(--am-text-soft);
    font-size: 15px;
    cursor: pointer;
    transition: all var(--dur, 220ms) var(--ease, ease);
}

.auth-modal__close:hover {
    background: var(--brand-soft, #ffedd5);
    border-color: transparent;
    color: var(--brand-strong, #c2410c);
    transform: rotate(90deg);
}

.auth-modal__close:focus-visible {
    outline: 2px solid var(--brand, #ea580c);
    outline-offset: 2px;
}

/* =========================================================
   ستون فرم
   ========================================================= */

.auth-modal__form {
    position: relative;
    padding: 46px 44px 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.auth-step {
    display: none;
    animation: auth-step-in 320ms var(--ease, ease) both;
}

.auth-step.is-active {
    display: block;
}

@keyframes auth-step-in {
    from {
        opacity: 0;
        transform: translateX(14px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* نشان بالای عنوان */
.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px 5px 13px;
    margin-bottom: 16px;
    border-radius: 999px;
    background: var(--brand-soft, #ffedd5);
    color: var(--brand-strong, #c2410c);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.auth-badge i {
    font-size: 11px;
}

.auth-badge--code {
    background: rgba(29, 78, 216, 0.1);
    color: var(--accent, #1d4ed8);
}

.auth-title {
    font-size: clamp(21px, 2.6vw, 26px);
    font-weight: 800;
    line-height: 1.35;
    color: var(--am-text);
    letter-spacing: -0.4px;
}

.auth-desc {
    margin-top: 8px;
    font-size: 13.5px;
    line-height: 1.9;
    color: var(--am-text-soft);
}

.auth-phone-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 8px;
    background: var(--brand-soft, #ffedd5);
    color: var(--brand-strong, #c2410c);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

/* ----------------------------- فرم ----------------------------- */

.auth-form {
    margin-top: 24px;
}

.auth-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--am-text-soft);
}

.auth-field {
    position: relative;
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 14px;
    border-radius: var(--radius-md, 16px);
    border: 1.5px solid var(--am-line-strong);
    background: var(--am-surface-2);
    transition: border-color var(--dur, 220ms) var(--ease, ease),
                box-shadow var(--dur, 220ms) var(--ease, ease);
}

.auth-field:focus-within {
    border-color: var(--brand, #ea580c);
    box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.13);
}

.auth-field.is-invalid {
    border-color: var(--am-danger);
    box-shadow: 0 0 0 4px var(--am-danger-soft);
}

.auth-field__icon {
    display: grid;
    place-items: center;
    width: 26px;
    color: var(--am-text-soft);
    font-size: 16px;
    transition: color var(--dur, 220ms) var(--ease, ease);
}

.auth-field:focus-within .auth-field__icon {
    color: var(--brand, #ea580c);
}

.auth-input {
    flex: 1;
    height: 100%;
    padding: 0 10px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--am-text);
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 1.5px;
    font-variant-numeric: tabular-nums;
}

.auth-input::placeholder {
    font-weight: 500;
    letter-spacing: 0.5px;
    color: #94a3b8;
}

.auth-field__clear {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #94a3b8;
    cursor: pointer;
    font-size: 15px;
    transition: color var(--dur, 220ms) var(--ease, ease);
}

.auth-field__clear:hover {
    color: var(--am-danger);
}

.auth-field__clear[hidden] {
    display: none;
}

/* پیام خطا / راهنما */
.auth-hint {
    min-height: 20px;
    margin-top: 8px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.6;
    color: var(--am-danger);
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity 200ms var(--ease, ease), transform 200ms var(--ease, ease);
}

.auth-hint.is-visible {
    opacity: 1;
    transform: none;
}

/* دکمهٔ اصلی */
.auth-submit {
    position: relative;
    width: 100%;
    height: 54px;
    margin-top: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: var(--radius-md, 16px);
    background: linear-gradient(135deg, var(--brand, #ea580c), var(--brand-strong, #c2410c));
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 16px 34px -16px rgba(234, 88, 12, 0.75);
    transition: transform var(--dur, 220ms) var(--ease, ease),
                box-shadow var(--dur, 220ms) var(--ease, ease),
                opacity var(--dur, 220ms) var(--ease, ease);
}

.auth-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.34) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 620ms var(--ease, ease);
}

.auth-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 22px 42px -16px rgba(234, 88, 12, 0.8);
}

.auth-submit:hover:not(:disabled)::after {
    transform: translateX(120%);
}

.auth-submit:active:not(:disabled) {
    transform: translateY(0) scale(0.99);
}

.auth-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.auth-submit:focus-visible {
    outline: 2px solid var(--brand-deep, #9a3412);
    outline-offset: 3px;
}

.auth-submit.is-loading {
    pointer-events: none;
}

.auth-submit.is-loading .auth-submit__text {
    opacity: 0;
}

.auth-submit__spinner {
    position: absolute;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    opacity: 0;
    animation: auth-spin 700ms linear infinite;
}

.auth-submit.is-loading .auth-submit__spinner {
    opacity: 1;
}

@keyframes auth-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ----------------------------- کد OTP ----------------------------- */

.auth-otp {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.auth-otp__box {
    height: 62px;
    width: 100%;
    padding: 0;
    border: 1.5px solid var(--am-line-strong);
    border-radius: var(--radius-md, 16px);
    background: var(--am-surface-2);
    color: var(--am-text);
    font-family: inherit;
    font-size: 25px;
    font-weight: 800;
    text-align: center;
    caret-color: var(--brand, #ea580c);
    font-variant-numeric: tabular-nums;
    transition: border-color var(--dur, 220ms) var(--ease, ease),
                box-shadow var(--dur, 220ms) var(--ease, ease),
                background var(--dur, 220ms) var(--ease, ease),
                transform var(--dur, 220ms) var(--ease, ease);
}

.auth-otp__box:hover {
    border-color: var(--am-line-strong);
}

.auth-otp__box:focus {
    outline: 0;
    border-color: var(--brand, #ea580c);
    background: var(--am-surface-2);
    box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.14);
    transform: translateY(-2px);
}

.auth-otp__box.is-filled {
    border-color: rgba(234, 88, 12, 0.45);
    background: var(--brand-soft, #ffedd5);
    color: var(--brand-strong, #c2410c);
}

.auth-otp.is-invalid .auth-otp__box {
    border-color: var(--am-danger);
    background: var(--am-danger-soft);
    color: var(--am-danger);
}

.auth-otp.is-invalid {
    animation: auth-shake 420ms var(--ease, ease);
}

@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    18% { transform: translateX(-7px); }
    36% { transform: translateX(6px); }
    54% { transform: translateX(-4px); }
    72% { transform: translateX(3px); }
}

/* ----------------------------- شمارش معکوس ----------------------------- */

.auth-timer {
    margin-top: 16px;
}

.auth-timer__track {
    height: 4px;
    border-radius: 999px;
    background: var(--am-line);
    overflow: hidden;
}

.auth-timer__fill {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand, #ea580c), var(--brand-strong, #c2410c));
    transform-origin: right center;
    transition: width 1000ms linear;
}

.auth-timer__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 9px;
}

.auth-timer__meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--am-text-soft);
}

.auth-timer__meta i {
    font-size: 11px;
    opacity: 0.8;
}

.auth-timer__label {
    font-weight: 600;
}

.auth-timer__text {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--am-text);
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

.auth-resend {
    padding: 4px 2px;
    border: 0;
    background: none;
    color: var(--brand-strong, #c2410c);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 800;
    cursor: pointer;
    border-radius: 6px;
    transition: opacity var(--dur, 220ms) var(--ease, ease);
}

.auth-resend:hover:not(:disabled) {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-resend:disabled {
    color: #64748b;
    cursor: not-allowed;
    opacity: 1;
}

/* ----------------------------- لینک‌های کمکی ----------------------------- */

.auth-back,
.auth-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    margin-bottom: 14px;
    border: 0;
    background: none;
    color: var(--am-text-soft);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: color var(--dur, 220ms) var(--ease, ease);
}

.auth-back:hover,
.auth-link:hover {
    color: var(--brand-strong, #c2410c);
}

.auth-back i {
    font-size: 11px;
}

.auth-trouble {
    margin-top: 18px;
    font-size: 12.5px;
    color: var(--am-text-soft);
    text-align: center;
}

.auth-trouble .auth-link {
    margin: 0;
    color: var(--brand-strong, #c2410c);
}

.auth-legal {
    margin-top: 20px;
    font-size: 11.5px;
    line-height: 1.9;
    color: #94a3b8;
    text-align: center;
}

.auth-legal a {
    color: var(--am-text-soft);
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
}

.auth-legal a:hover {
    color: var(--brand-strong, #c2410c);
}

.auth-alt-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 14px;
    padding-top: 16px;
    border-top: 1px solid var(--am-line);
    color: var(--am-text-soft);
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    transition: color var(--dur, 220ms) var(--ease, ease);
}

.auth-alt-link:hover {
    color: var(--brand-strong, #c2410c);
}

/* ----------------------------- موفقیت ----------------------------- */

.auth-step--success {
    text-align: center;
    padding: 20px 0;
}

.auth-success {
    display: grid;
    place-items: center;
    margin-bottom: 22px;
    color: var(--am-success);
}

.auth-success__check {
    width: 82px;
    height: 82px;
    stroke-dasharray: 160;
    stroke-dashoffset: 160;
    animation: auth-draw 700ms var(--ease, ease) 120ms forwards;
}

.auth-success__check circle {
    opacity: 0;
    animation: auth-fade 300ms ease 120ms forwards;
}

.auth-success__check path {
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: auth-draw-path 480ms var(--ease, ease) 560ms forwards;
}

@keyframes auth-draw {
    to { stroke-dashoffset: 0; }
}

@keyframes auth-draw-path {
    to { stroke-dashoffset: 0; }
}

@keyframes auth-fade {
    to { opacity: 1; }
}

/* ----------------------------- برند موبایل ----------------------------- */

.auth-mobile-brand {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 15px;
    font-weight: 800;
    color: var(--am-text);
}

.auth-mobile-brand img {
    border-radius: 10px;
}

/* =========================================================
   پنل برند (ستون کنار)
   ========================================================= */

.auth-modal__brand {
    position: relative;
    padding: 46px 40px;
    display: flex;
    align-items: center;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(120% 90% at 90% 0%, rgba(255, 255, 255, 0.22), transparent 58%),
        linear-gradient(150deg, var(--brand-deep, #9a3412) 0%, var(--brand, #ea580c) 52%, #f59e0b 100%);
}

.auth-brand__glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(42px);
    pointer-events: none;
}

.auth-brand__glow--a {
    width: 260px;
    height: 260px;
    top: -90px;
    inset-inline-start: -70px;
    background: rgba(255, 255, 255, 0.32);
}

.auth-brand__glow--b {
    width: 220px;
    height: 220px;
    bottom: -80px;
    inset-inline-end: -60px;
    background: rgba(251, 191, 36, 0.5);
}

.auth-brand__content {
    position: relative;
    z-index: 1;
    width: 100%;
}

.auth-brand__logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-brand__logo img {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.16);
    padding: 5px;
    box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6);
}

.auth-brand__logo strong {
    display: block;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.auth-brand__logo small {
    display: block;
    margin-top: 1px;
    font-size: 11px;
    opacity: 0.82;
}

.auth-brand__headline {
    margin-top: 30px;
    font-size: clamp(19px, 2.2vw, 24px);
    font-weight: 800;
    line-height: 1.55;
    letter-spacing: -0.4px;
}

.auth-brand__features {
    margin-top: 26px;
    list-style: none;
    display: grid;
    gap: 14px;
}

.auth-brand__features li {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.95);
}

.auth-brand__ico {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.24);
    font-size: 13px;
    backdrop-filter: blur(6px);
}

.auth-brand__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 34px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.24);
    font-size: 11.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.86);
}

/* =========================================================
   دارک مود
   ========================================================= */

:root[data-theme="dark"] .auth-modal {
    --am-surface: rgba(13, 20, 34, 0.9);
    --am-surface-2: rgba(22, 32, 51, 0.92);
    --am-line: rgba(148, 163, 184, 0.16);
    --am-line-strong: rgba(148, 163, 184, 0.28);
    --am-text: #f8fafc;
    --am-text-soft: #cbd5e1;
    --am-danger: #f87171;
    --am-danger-soft: rgba(248, 113, 113, 0.12);
    --am-success: #4ade80;
}

:root[data-theme="dark"] .auth-modal__backdrop {
    background: rgba(2, 6, 23, 0.72);
}

:root[data-theme="dark"] .auth-modal__dialog {
    background: var(--am-surface);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow:
        0 44px 100px -30px rgba(0, 0, 0, 0.92),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

:root[data-theme="dark"] .auth-modal__close {
    background: rgba(22, 32, 51, 0.9);
    color: #cbd5e1;
}

:root[data-theme="dark"] .auth-modal__close:hover {
    background: rgba(251, 146, 60, 0.18);
    color: #fb923c;
}

:root[data-theme="dark"] .auth-input::placeholder {
    color: #64748b;
}

:root[data-theme="dark"] .auth-otp__box.is-filled {
    background: rgba(251, 146, 60, 0.16);
    border-color: rgba(251, 146, 60, 0.5);
    color: #fb923c;
}

:root[data-theme="dark"] .auth-badge {
    background: rgba(251, 146, 60, 0.16);
    color: #fb923c;
}

:root[data-theme="dark"] .auth-badge--code {
    background: rgba(96, 165, 250, 0.14);
    color: #93c5fd;
}

:root[data-theme="dark"] .auth-phone-chip {
    background: rgba(251, 146, 60, 0.16);
    color: #fb923c;
}

:root[data-theme="dark"] .auth-resend {
    color: #fb923c;
}

:root[data-theme="dark"] .auth-modal__brand {
    background:
        radial-gradient(120% 90% at 90% 0%, rgba(255, 255, 255, 0.14), transparent 58%),
        linear-gradient(150deg, #7c2d12 0%, #c2410c 52%, #b45309 100%);
}

/* =========================================================
   ریسپانسیو
   ========================================================= */

@media (max-width: 880px) {
    .auth-modal {
        padding: 14px;
    }

    .auth-modal__dialog {
        grid-template-columns: 1fr;
        max-height: 92dvh;
    }

    .auth-modal__brand {
        display: none;
    }

    .auth-mobile-brand {
        display: flex;
    }

    .auth-modal__form {
        padding: 40px 26px 30px;
    }

    .auth-modal__close {
        top: 12px;
        inset-inline-end: 12px;
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 420px) {
    .auth-modal__form {
        padding: 36px 18px 24px;
    }

    .auth-otp {
        gap: 7px;
    }

    .auth-otp__box {
        height: 54px;
        font-size: 21px;
        border-radius: 13px;
    }

    .auth-submit {
        height: 50px;
    }
}

/* ----------------------------- دسترس‌پذیری ----------------------------- */

@media (prefers-reduced-motion: reduce) {
    .auth-modal__dialog,
    .auth-modal__backdrop,
    .auth-step,
    .auth-otp.is-invalid,
    .auth-success__check,
    .auth-success__check circle,
    .auth-success__check path,
    .auth-submit::after {
        animation: none !important;
        transition-duration: 1ms !important;
    }

    .auth-success__check,
    .auth-success__check path {
        stroke-dashoffset: 0;
    }

    .auth-success__check circle {
        opacity: 1;
    }
}

/* قفل اسکرول صفحه هنگام باز بودن پنجره */
body.auth-modal-open {
    overflow: hidden;
}
