/* Публичная страница входа — оболочка. Основной цвет: #9640A3 */
:root {
    --portal-primary: #9640A3;
    --portal-primary-dark: #7a3385;
    --portal-text: #1f2937;
    --portal-muted: #C6C6C6;
    --portal-secondary: #868686;
    --portal-border: #e5e7eb;
    --portal-radius: 10px;
    --portal-input-border: #9640a3;
    --portal-input-error: #ff7775;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body.portal-auth-body {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    color: var(--portal-text);
    background: #fff;
}

.portal-auth {
    display: flex;
    min-height: 100vh;
}

/* Левая колонка: фоновое изображение — замените URL в blade или здесь */
.portal-auth__left {
    position: relative;
    z-index: 1;
    flex: 0 0 58%;
    max-width: 58%;
    min-height: 100vh;
    overflow: visible;
    background-color: #0f172a;
}

.portal-auth__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-color: #1e293b;
    /* Задайте в blade: .portal-auth__bg { --portal-left-image: url('...'); } */
    background-image: var(
        --portal-left-image,
        linear-gradient(145deg, #1e3a5f 0%, #0f172a 45%, #1a1033 100%)
    );
    background-size: cover;
    background-position: center;
}

.portal-auth__m {
    position: absolute;
    top: 0%;
    right: -10%;
    width: clamp(160px, 38vw, 520px);
    height: auto;
    max-height: min(92vh, 75vw);
    object-fit: contain;
    pointer-events: none;
    transform: rotate(0deg);
    z-index: 10;
    filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.25));
}

@media (max-width: 1400px) {
    .portal-auth__m {
        width: clamp(140px, 36vw, 440px);
        max-height: min(88vh, 80vw);
    }
}

@media (max-width: 1100px) {
    .portal-auth__m {
        width: clamp(120px, 34vw, 360px);
        right: -12%;
        max-height: min(85vh, 85vw);
    }
}

/* Ноутбуки: 901–1536px по ширине — уже левая колонка, аккуратнее «M», форма */
@media (min-width: 901px) and (max-width: 1536px) {
    .portal-auth__left {
        flex: 0 0 54%;
        max-width: 54%;
    }

    .portal-auth__right {
        padding: 2rem 1.35rem 1.25rem;
    }

    .portal-auth__m {
        width: clamp(125px, 28vw, 400px);
        max-height: min(80vh, 62vw);
        right: -9%;
    }

    .portal-auth__tagline {
        font-size: clamp(1.05rem, 2vw, 1.45rem);
    }

    .portal-auth__logo img {
        max-height: clamp(3rem, 9vw, 4.75rem);
    }

    .portal-auth__inner,
    .portal-auth__bottom {
        max-width: min(400px, 92%);
    }
}

/* Ноутбуки с низкой высотой (768–900px): не обрезаем форму и букву M */
@media (min-width: 901px) and (max-height: 900px) {
    .portal-auth__m {
        max-height: min(62vh, 58vw);
        width: clamp(110px, 26vw, 320px);
    }

    .portal-auth__logo {
        margin-bottom: 0.65rem;
    }

    .portal-auth__logo img {
        max-height: 3.25rem;
    }

    .portal-auth__tagline {
        font-size: 1.05rem;
        margin-bottom: 1.1rem;
    }

    .portal-auth__field {
        margin-bottom: 0.75rem;
    }

    .portal-auth__row {
        margin: 0.85rem 0 1rem;
    }

    .portal-auth__stores {
        margin-top: 1.35rem;
    }

    .portal-auth__bottom {
        padding-top: 1.1rem;
    }
}

/* Правая колонка */
.portal-auth__right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 100vh;
    padding: 2.5rem 1.75rem 1.5rem;
    background: #fff;
    position: relative;
    z-index: 1;
    isolation: isolate;
}

.portal-auth__middle {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.portal-auth__inner {
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.portal-auth__form {
    width: 100%;
    text-align: left;
}

.portal-auth__logo {
    margin: 0 0 1.35rem;
    text-align: center;
    line-height: 0;
}

.portal-auth__logo img {
    display: inline-block;
    width: auto;
    max-width: min(100%, 168px);
    height: auto;
    max-height: clamp(3.25rem, 12vw, 5.25rem);
    vertical-align: middle;
    aspect-ratio: 1;
    object-fit: contain;
}

.portal-auth__tagline {
    text-align: center;
    font-size: 25px;
    font-weight: 600;
    color: var(--portal-primary);
    margin: 0 0 2rem;
}

.portal-auth__field {
    margin-bottom: 1rem;
}

.portal-auth__input {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--portal-input-border);
    border-radius: 7px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}

.portal-auth__input:focus {
    border-color: var(--portal-input-border);
    box-shadow: 0 0 0 3px rgba(150, 64, 163, 0.2);
}

/* Ошибка: класс на инпуте, на обёртке поля или aria-invalid */
.portal-auth__input--error,
.portal-auth__field--error .portal-auth__input,
.portal-auth__input[aria-invalid="true"] {
    border-color: var(--portal-input-error);
}

.portal-auth__input--error:focus,
.portal-auth__field--error .portal-auth__input:focus,
.portal-auth__input[aria-invalid="true"]:focus {
    border-color: var(--portal-input-error);
    box-shadow: 0 0 0 3px rgba(255, 119, 117, 0.25);
}

.portal-auth__input-wrap {
    position: relative;
}

.portal-auth__input-wrap .portal-auth__input {
    padding-right: 3rem;
}

.portal-auth__toggle-pass {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    padding: 0.35rem;
    cursor: pointer;
    color: var(--portal-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.portal-auth__toggle-pass:hover {
    color: var(--portal-primary);
    background: rgba(150, 64, 163, 0.08);
}

.portal-auth__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.25rem 0 1.5rem;
    flex-wrap: wrap;
}

.portal-auth__remember {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--portal-muted);
    cursor: pointer;
    user-select: none;
}

.portal-auth__remember input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex-shrink: 0;
    border: 2px solid #9640a3;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    vertical-align: middle;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.portal-auth__remember input[type="checkbox"]:checked {
    background-color: #9640a3;
    border-color: #9640a3;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10' fill='none'%3E%3Cpath stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1%205.2%20L4.5%208.5%20L11%201.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0.65rem auto;
}

.portal-auth__remember input[type="checkbox"]:focus-visible {
    outline: 2px solid #9640a3;
    outline-offset: 2px;
}

.portal-auth__link {
    font-size: 0.9rem;
    color: var(--portal-muted);
    text-decoration: none;
}

.portal-auth__link:hover {
    color: var(--portal-primary);
    text-decoration: none;
}

.portal-auth__submit {
    width: 100%;
    padding: 0.95rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--portal-primary);
    border: none;
    border-radius: var(--portal-radius);
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
}

.portal-auth__submit:hover {
    background: #ba5eb1;
}

.portal-auth__submit:active {
    transform: scale(0.99);
}

.portal-auth__app-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--portal-secondary);
    margin: 0 0 0.75rem;
}

.portal-auth__stores {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 2rem;
}

.portal-auth__store-link {
    display: block;
    line-height: 0;
    border-radius: 8px;
    overflow: hidden;
    opacity: 0.95;
    transition: opacity 0.15s;
}

.portal-auth__store-link:hover {
    opacity: 1;
}

.portal-auth__store-link img {
    display: block;
    height: 44px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
}

/* Плейсхолдер, пока нет картинок бейджей */
.portal-auth__store-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    height: 44px;
    padding: 0 12px;
    background: #111;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    letter-spacing: 0.02em;
}

.portal-auth__bottom {
    flex-shrink: 0;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 1.5rem;
}

.portal-auth__footer {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.portal-auth__footer a {
    font-size: 0.8rem;
    color: var(--portal-muted);
    text-decoration: underline;
}

.portal-auth__footer a:hover {
    color: var(--portal-primary);
}

@media (max-width: 900px) {
    .portal-auth {
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* Левая колонка (фон + M) на мобилке не показываем */
    .portal-auth__left {
        display: none;
    }

    .portal-auth__right {
        flex: 1;
        width: 100%;
        max-width: none;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
        justify-content: flex-start;
    }

    /* Лого, слоган и форма — одна колонка по центру экрана */
    .portal-auth__middle {
        flex: 1 1 auto;
        align-items: center;
        justify-content: flex-start;
        padding-top: 0.5rem;
    }

    .portal-auth__inner {
        max-width: 400px;
    }

    .portal-auth__bottom {
        max-width: 400px;
    }

    .portal-auth__logo {
        margin-bottom: 0.75rem;
    }

    .portal-auth__logo img {
        max-height: clamp(2.75rem, 14vw, 4.25rem);
    }

    .portal-auth__tagline {
        font-size: clamp(1.05rem, 4.2vw, 1.35rem);
        margin-bottom: 1.35rem;
    }

    .portal-auth__stores {
        margin-top: 0;
        gap: 0.5rem;
        justify-content: center;
    }

    .portal-auth__store-link img {
        height: 40px;
        max-width: 118px;
    }

    .portal-auth__bottom {
        width: 100%;
        max-width: none;
        padding-top: 1.25rem;
        margin-top: auto;
    }

    .portal-auth__footer {
        margin-top: 1rem;
    }
}

/* Модалка OTP (push) */
.portal-auth__otp-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.portal-auth__otp-modal[hidden] {
    display: none !important;
}

.portal-auth__otp-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.portal-auth__otp-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    padding: 1.5rem 1.35rem;
    background: #fff;
    border-radius: var(--portal-radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    border: 1px solid var(--portal-border);
}

/* .portal-auth__otp-dialog--with-close {
    padding-top: 2.75rem;
} */

.portal-auth__otp-dialog--with-close .portal-auth__otp-title {
    padding-right: 2rem;
}

.portal-auth__modal-close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--portal-secondary);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.portal-auth__modal-close:hover {
    color: var(--portal-text);
    background-color: rgba(15, 23, 42, 0.06);
}

.portal-auth__modal-close:focus-visible {
    outline: 2px solid var(--portal-primary);
    outline-offset: 2px;
}

.portal-auth__otp-title {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--portal-text);
}

.portal-auth__otp-text {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--portal-secondary);
}

.portal-auth__otp-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.portal-auth__otp-input {
    text-align: center;
    font-size: 1.35rem;
    letter-spacing: 0.35em;
    font-weight: 600;
}

.portal-auth__otp-resend {
    margin-top: 0.75rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--portal-primary);
    background: rgba(150, 64, 163, 0.08);
    border: 1px solid rgba(150, 64, 163, 0.25);
    border-radius: var(--portal-radius);
    cursor: pointer;
}

.portal-auth__otp-resend:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.portal-auth__otp-meta {
    margin: 0.65rem 0 0;
    font-size: 0.8rem;
    color: var(--portal-secondary);
}

.portal-auth__otp-back {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--portal-secondary);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.portal-auth__otp-back:hover {
    color: var(--portal-primary);
}

.portal-auth__qr-row {
    margin-top: 1rem;
    text-align: center;
}

.portal-auth__qr-open {
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--portal-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    padding: 0.25rem 0.5rem;
}

.portal-auth__qr-open:hover {
    color: var(--portal-primary-dark);
}

.portal-auth__qr-canvas-host {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.portal-auth__qr-canvas-host canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}
