/* static/css/login.css - вход и установка пароля: сплит-экран.
   Токены, шрифт и модалки - в base.css */

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

body {
    background: var(--surface);
}

.login-screen {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    min-height: 100vh; /* запас для браузеров без dvh */
    min-height: 100dvh;
}

/* ---------- Левая панель ---------- */

/* Глубокий фирменный синий + одно мягкое пятно света сверху слева - без размытых цветных пятен */
.login-panel {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(90% 60% at 0% 0%, rgba(126, 157, 201, 0.32), transparent 70%),
        #22344f;
    color: var(--accent-contrast);
    display: flex;
    align-items: center;
    padding: 56px clamp(32px, 6vw, 88px);
}

.login-panel-content {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 44px;
    width: 100%;
}

.login-panel-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: center;
    text-align: center;
    gap: 18px;
    max-width: 440px;
}

.login-panel-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-panel-icon svg {
    width: 22px;
    height: 22px;
}

.login-panel h1 {
    font-size: 34px;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
}

.login-panel p {
    max-width: 38ch;
    font-size: 16px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.78);
    text-wrap: pretty;
}

/* Чей сервис - мелко, капсом с разрядкой, между знаком и названием. Двойной класс -
   перебить общее .login-panel p выше */
.login-panel .login-panel-org {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: -8px; /* ближе к названию, чем к знаку - это одна подпись */
}

/* Мини-превью переписки - показывает, как выглядит сам чат, не настоящий диалог */
.login-preview {
    width: 100%;
    max-width: 400px;
    align-self: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-preview-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.login-preview-row.user {
    justify-content: flex-end;
}

.login-preview-avatar {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.login-preview-avatar svg {
    width: 13px;
    height: 13px;
}

.login-preview-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.45;
    max-width: 280px;
    text-align: left;
}

.login-preview-row.user .login-preview-bubble {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.login-preview-row.bot .login-preview-bubble {
    background: #fff;
    color: var(--text);
    box-shadow: 0 10px 30px -8px rgba(8, 15, 28, 0.45);
    border-top-left-radius: 5px;
}

.login-preview-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 13px 14px;
}

.login-preview-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: login-typing 1.2s infinite ease-in-out both;
}

.login-preview-dots span:nth-child(1) { animation-delay: -0.32s; }
.login-preview-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes login-typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.35; }
    40% { transform: scale(1); opacity: 1; }
}

/* ---------- Правая панель - форма ---------- */

.login-form-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 32px;
    background: var(--surface);
}

.login-form {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-form h2 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 6px;
}

.login-error,
.login-success {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: var(--radius-md);
    padding: 11px 14px;
    font-size: 14px;
    line-height: 1.45;
}

.login-error {
    background: color-mix(in srgb, var(--danger) 8%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--danger) 22%, var(--surface));
    color: var(--danger);
}

/* После установки пароля по ссылке - редирект сюда с ?password_set=1 */
.login-success {
    background: color-mix(in srgb, var(--success) 8%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--success) 22%, var(--surface));
    color: var(--success);
}

.login-error svg,
.login-success svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Пояснение под заголовком формы: чей аккаунт (set_password.html), что будет
   дальше (password_reset.html) */
.set-password-hint {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: -10px;
    overflow-wrap: anywhere;
}

/* Обычный абзац, а не строка "Аккаунт: ..." - отступ от заголовка не поджимаем */
.password-reset-note {
    margin-top: -6px;
    line-height: 1.55;
}

.set-password-hint strong {
    color: var(--text);
    font-weight: 500;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 13.5px;
    color: var(--text);
    font-weight: 500;
}

.login-field input {
    height: 46px;
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 0 14px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

/* Поле со ссылкой в строке подписи: "Пароль" слева, "Забыли пароль?" справа над полем */
.login-field-with-link {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "label link"
        "input input";
    align-items: baseline;
    column-gap: 12px;
}

.login-field-with-link label { grid-area: label; }
.login-field-with-link .password-input-wrap { grid-area: input; }

.login-field-link {
    grid-area: link;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 4px;
    transition: color 150ms ease;
}

.login-field input:focus {
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.password-input-wrap {
    position: relative;
    display: flex;
}

.password-input-wrap input {
    flex: 1;
    min-width: 0;
    padding-right: 46px; /* место под кнопку-глазок, не залезает на текст */
}

.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 150ms ease, background-color 150ms ease;
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.password-toggle .icon-eye-off {
    display: none; /* показывается вместо icon-eye, когда пароль виден - переключает login.js */
}

.login-submit {
    margin-top: 6px;
    height: 46px;
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: var(--radius-full);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease, transform 160ms var(--ease-out);
}

.login-submit:active { transform: scale(0.98); }

/* Ссылка <a>, оформленная как .login-submit - без подчеркивания, текст по центру */
a.login-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.login-help-link {
    align-self: center;
    margin-top: 2px;
    padding: 4px 6px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 4px;
    transition: color 150ms ease, text-decoration-color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .password-toggle:hover { color: var(--text); background: var(--surface-sunken); }
    .login-submit:hover { background: var(--accent-hover); }
    .login-help-link:hover { color: var(--accent); text-decoration-color: currentColor; }
    .login-field-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
}

/* ---------- Модалки страницы входа (общие стили модалок - в base.css) ---------- */

.register-help-dialog {
    width: min(460px, calc(100vw - 32px));
    padding: 28px;
}

/* Модалка про автовыход по неактивности - текст без списков/шагов, поэтому уже */
.inactivity-dialog {
    width: min(400px, calc(100vw - 32px));
    padding: 28px;
}

.dialog-title {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    padding-right: 28px; /* не наезжать на крестик закрытия */
}

.dialog-subtitle {
    font-size: 14.5px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 22px;
}

.register-steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 24px;
}

.register-step {
    display: flex;
    gap: 14px;
}

.register-step-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.register-step-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 3px 0 3px;
}

.register-step-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

.register-step-list {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

.register-step-list li { margin-bottom: 2px; }

/* ---------- Телефон и узкие окна ---------- */

@media (max-width: 860px) {
    .login-screen {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    /* Панель сжимается в шапку: знак + название, описание и превью прячем - форма важнее */
    .login-panel {
        padding: 20px;
    }

    .login-panel-content {
        gap: 0;
    }

    /* На телефоне панель - шапка: знак и название слева, не по центру */
    .login-panel-intro {
        flex-direction: row;
        align-items: center;
        align-self: flex-start;
        text-align: left;
        gap: 12px;
    }

    .login-panel-icon {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }

    .login-panel-icon svg {
        width: 18px;
        height: 18px;
    }

    .login-panel h1 {
        font-size: 20px;
    }

    /* в том числе подпись "Минприроды России" - в шапку-строку не помещается */
    .login-panel p,
    .login-preview {
        display: none;
    }

    .login-form-col {
        /* Без этого форма центрируется в оставшейся высоте - на телефоне гигантский отступ сверху */
        align-items: flex-start;
        padding: 36px 20px;
    }

    .login-form h2 {
        font-size: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-preview-dots span { animation-duration: 2s; }
}
