/* پنجره و صفحه ورود/ثبت‌نام */
.pm-auth {
    --pa-ink: #0f172b;
    --pa-muted: #5a6880;
    --pa-line: #e2e7f0;
    --pa-paper: #f5f7fb;
    --pa-teal: #00ac94;
    --pa-teal-ink: #00806e;
    --pa-teal-soft: #e2f5f1;
    --pa-gold: #c9a14a;
    --pa-danger: #c2303a;
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-family: IRANSans, Tahoma, sans-serif;
    direction: rtl;
}

    /* #loginWrapper در site.css قدیمی display:none دارد؛ با id بازنویسی می‌شود */
    .pm-auth.is-open,
    #loginWrapper.pm-auth.is-open {
        display: flex;
    }

body.pm-auth-open {
    overflow: hidden;
}

.pm-auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 14, 28, .62);
    backdrop-filter: blur(4px);
    animation: pmAuthFade .2s ease;
}

.pm-auth-dialog {
    position: relative;
    display: grid;
    grid-template-columns: 300px 1fr;
    width: 820px;
    max-width: 100%;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    border-radius: 26px;
    background: #fff;
    box-shadow: 0 30px 80px -20px rgba(9, 14, 28, .55);
    animation: pmAuthIn .28s cubic-bezier(.2, .8, .2, 1);
}

@keyframes pmAuthFade {
    from { opacity: 0; }
}

@keyframes pmAuthIn {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
}

/* ستون معرفی */
.pm-auth-side {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px 26px;
    background: radial-gradient(420px 260px at 20% 110%, rgba(201, 161, 74, .28), transparent 70%), radial-gradient(380px 260px at 90% -10%, rgba(0, 172, 148, .25), transparent 70%), var(--pa-ink);
    color: #e9eef7;
    overflow: hidden;
}

.pm-auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 16px;
}

    .pm-auth-brand img {
        border-radius: 50%;
    }

.pm-auth-fan {
    position: relative;
    height: 170px;
    margin-top: 6px;
}

    .pm-auth-fan img {
        position: absolute;
        bottom: 0;
        left: 50%;
        width: 112px;
        aspect-ratio: 4 / 5;
        object-fit: cover;
        border-radius: 14px;
        border: 3px solid #fff;
        box-shadow: 0 16px 30px -12px rgba(0, 0, 0, .6);
    }

        .pm-auth-fan img:nth-child(1) { transform: translateX(-104%) rotate(-10deg); }
        .pm-auth-fan img:nth-child(2) { transform: translateX(4%) rotate(10deg); }
        .pm-auth-fan img:nth-child(3) { transform: translateX(-50%) translateY(-12px); z-index: 1; width: 124px; }

.pm-auth-side-title {
    margin: 4px 0 0;
    font-size: 16px;
    text-wrap: balance;
    font-weight: bold;
    line-height: 1.7;
    color: #fff;
}

.pm-auth-perks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
    font-size: 13px;
    color: #b7c2d6;
}

    .pm-auth-perks li {
        display: flex;
        align-items: center;
        gap: 9px;
    }

        .pm-auth-perks li::before {
            content: "";
            flex: none;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background: rgba(0, 172, 148, .2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ac94' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 11px no-repeat;
        }

/* ستون فرم */
.pm-auth-main {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 460px;
    padding: 40px 40px 32px;
    overflow-y: auto;
    color: var(--pa-ink);
}

.pm-auth-close {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--pa-line);
    background: #fff;
    color: var(--pa-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 3;
}

    .pm-auth-close:hover {
        color: var(--pa-ink);
        border-color: var(--pa-ink);
    }

    .pm-auth-close svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
    }

.pm-auth-loading {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(1px);
}

    .pm-auth-loading span {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 38px;
        height: 38px;
        margin: -19px 0 0 -19px;
        border-radius: 50%;
        border: 3px solid var(--pa-teal-soft);
        border-top-color: var(--pa-teal);
        animation: pmAuthSpin .8s linear infinite;
    }

@keyframes pmAuthSpin {
    to { transform: rotate(360deg); }
}

.pm-auth-step {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
}

.pm-auth-head h2 {
    margin: 12px 0 6px;
    font-size: 22px;
    font-weight: bold;
    color: var(--pa-ink);
    text-align: right;
}

.pm-auth-head p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.9;
    color: var(--pa-muted);
    text-align: right;
}

.pm-auth-badge {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 15px;
    background: var(--pa-teal-soft);
    color: var(--pa-teal-ink);
}

    .pm-auth-badge svg {
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.pm-auth-phone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--pa-paper);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .03em;
}

    .pm-auth-phone a {
        font-size: 13px;
        color: var(--pa-teal-ink);
        font-weight: 500;
        letter-spacing: 0;
        cursor: pointer;
    }

.pm-auth form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pm-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pm-field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--pa-ink);
}

    .pm-field-label small {
        color: var(--pa-muted);
        font-weight: normal;
    }

.pm-field-hint {
    color: var(--pa-teal);
    font-size: 12px;
}

.pm-auth input.pm-referral {
    height: 48px;
    font-size: 15px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

    .pm-auth input.pm-referral::placeholder {
        text-transform: none;
        letter-spacing: 0;
        font-size: 13px;
    }

.pm-auth input[type="tel"],
.pm-auth input[type="text"],
.pm-auth input[type="password"] {
    width: 100%;
    height: 54px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1.5px solid var(--pa-line);
    background: #fff;
    font-family: inherit;
    font-size: 17px;
    color: var(--pa-ink);
    text-align: left;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}

    .pm-auth input::placeholder {
        color: #a9b4c4;
    }

    .pm-auth input:focus {
        outline: none;
        border-color: var(--pa-teal);
        box-shadow: 0 0 0 4px rgba(0, 172, 148, .14);
    }

.pm-auth input.pm-otp {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: .5em;
    padding-left: calc(16px + .5em);
}

.pm-pass {
    position: relative;
    display: block;
}

    .pm-pass input {
        padding-left: 76px !important;
    }

.pm-pass-toggle {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: var(--pa-paper);
    color: var(--pa-muted);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.pm-auth-error:empty,
.pm-auth-error .validation-summary-valid {
    display: none;
}

.pm-auth-error ul {
    list-style: none;
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: #fdecee;
    color: var(--pa-danger);
    font-size: 13px;
    line-height: 1.9;
}

.pm-auth-submit {
    height: 54px;
    border: 0;
    border-radius: 14px;
    background: var(--pa-ink);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background .15s, transform .1s;
}

    .pm-auth-submit:hover {
        background: #1b2640;
    }

    .pm-auth-submit:active {
        transform: scale(.99);
    }

    .pm-auth-submit:disabled {
        opacity: .6;
        cursor: wait;
    }

.pm-resend {
    display: flex;
    justify-content: center;
    font-size: 13px;
    color: var(--pa-muted);
}

.pm-resend-link {
    display: none;
    color: var(--pa-teal-ink);
    font-weight: bold;
    cursor: pointer;
}

.pm-resend.is-ready .pm-resend-wait {
    display: none;
}

.pm-resend.is-ready .pm-resend-link {
    display: inline;
}

.pm-resend-wait b {
    display: inline-block;
    min-width: 40px;
    color: var(--pa-ink);
    font-variant-numeric: tabular-nums;
}

.pm-auth-alt {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding-top: 14px;
    border-top: 1px dashed var(--pa-line);
    font-size: 13px;
    color: var(--pa-muted);
}

    .pm-auth-alt a {
        color: var(--pa-teal-ink);
        font-weight: bold;
        cursor: pointer;
    }

.pm-auth-gift {
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    background: #fbf5e6;
    color: #7a5d17;
    font-size: 12.5px;
    text-align: center;
}

.pm-auth a:focus-visible,
.pm-auth button:focus-visible {
    outline: 3px solid rgba(0, 172, 148, .45);
    outline-offset: 2px;
}

/* صفحه مستقل /Login */
.pm-auth.pm-auth--page,
#loginWrapper.pm-auth--page {
    position: static;
    display: flex;
    min-height: 100vh;
    background: #f5f7fb;
}

    .pm-auth.pm-auth--page .pm-auth-dialog {
        animation: none;
        box-shadow: 0 20px 60px -30px rgba(9, 14, 28, .35);
        border: 1px solid var(--pa-line);
    }

@media (max-width: 760px) {
    .pm-auth {
        align-items: flex-end;
        padding: 0;
    }

    .pm-auth-dialog {
        grid-template-columns: 1fr;
        border-radius: 24px 24px 0 0;
        max-height: 92vh;
    }

    .pm-auth-side {
        display: none;
    }

    .pm-auth-main {
        min-height: 0;
        padding: 30px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    }

    .pm-auth.pm-auth--page {
        align-items: center;
        padding: 16px;
    }

        .pm-auth.pm-auth--page .pm-auth-dialog {
            border-radius: 24px;
        }
}

@media (prefers-reduced-motion: reduce) {
    .pm-auth-backdrop,
    .pm-auth-dialog {
        animation: none;
    }
}
