/* === Вход, восстановление и задание пароля === */

body.auth-body {
    background:
        radial-gradient(ellipse 80% 60% at 15% 0%, rgba(65, 93, 132, 0.08), transparent 70%),
        var(--color-bg);
}

/* .content растягивается между шапкой и подвалом - так карточку можно
   поставить по центру высоты. */
.auth-body .content {
    display: flex;
    flex-direction: column;
}

.auth-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem 3rem;
}

.auth-shell {
    width: 100%;
    max-width: 460px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 1px 2px rgba(43, 38, 32, 0.04),
        0 12px 32px -8px rgba(43, 38, 32, 0.10);
    /* Мягкое появление: чуть снизу и из прозрачности. */
    animation: auth-enter 420ms var(--ease-out) both;
}

@keyframes auth-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* --- Форма --- */

/* Название системы над заголовком. */
.auth-card-eyebrow {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-soft);
    margin-bottom: 0.5rem;
}

.auth-card {
    padding: 2.75rem 2.75rem 2.5rem;
}

.auth-title {
    font-size: 1.55rem;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--color-text);
    text-wrap: balance;
    margin-bottom: 0.45rem;
}

.auth-subtitle {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    line-height: 1.55;
    margin-bottom: 1.75rem;
}

.auth-email {
    color: var(--color-text);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.auth-form .form-field {
    margin-bottom: 1.15rem;
}

.auth-form label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.4rem;
}

.auth-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

/* Поле с иконкой слева. */
.auth-input {
    position: relative;
}

.auth-input-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    color: var(--color-text-soft);
    pointer-events: none;
    transition: color 0.15s ease;
}

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

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    width: 100%;
    height: 46px;
    padding: 0 0.9rem 0 2.6rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--color-text);
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    background: var(--color-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
    .auth-form input:hover:not(:focus) {
        border-color: var(--color-text-soft);
    }
}

.auth-form input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(65, 93, 132, 0.18);
}

.auth-form .has-error input {
    border-color: var(--color-danger);
}

.auth-form .has-error input:focus {
    box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.14);
}

.field-error {
    color: var(--color-danger);
    font-size: 0.8rem;
    line-height: 1.45;
    margin-top: 0.4rem;
}

/* Caps Lock при вводе пароля - частая причина "неверного пароля". */
.auth-caps-hint {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: var(--color-warning);
}

.auth-caps-hint::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

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

/* --- Кнопка --- */

.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    height: 46px;
    margin-top: 0.4rem;
    padding: 0 1rem;
    background-color: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform var(--duration-press) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .auth-submit:hover {
        background-color: var(--color-primary-hover);
    }
}

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

.auth-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-surface), 0 0 0 5px var(--color-primary);
}

/* Отправка идет: кнопка неактивна, слева крутится индикатор (auth.js). */
.auth-submit.is-loading {
    cursor: progress;
    background-color: var(--color-primary-hover);
    transform: none;
}

.auth-submit.is-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

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

/* --- Сообщения --- */

.auth-alert,
.auth-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    font-size: 0.88rem;
    line-height: 1.45;
    margin-bottom: 1.25rem;
}

.auth-alert svg,
.auth-notice svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
}

.auth-alert {
    background: var(--color-danger-bg);
    border: 1px solid rgba(179, 38, 30, 0.2);
    color: var(--color-danger);
}

.auth-notice {
    background: var(--color-primary-tint);
    border: 1px solid rgba(65, 93, 132, 0.2);
    color: var(--color-primary-hover);
}

.auth-notice-success {
    background: var(--color-success-bg);
    border-color: rgba(77, 124, 15, 0.22);
    color: var(--color-success-hover);
}

/* --- Ссылки --- */

.auth-forgot-link,
.auth-inline-link {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
}

.auth-forgot-link {
    font-size: 0.8rem;
}

.auth-inline-link {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

.auth-forgot-link:hover,
.auth-inline-link:hover,
.auth-forgot-link:focus-visible,
.auth-inline-link:focus-visible {
    color: var(--color-primary-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
    outline: none;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin: -0.5rem 0 1.5rem -0.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.auth-back-link svg {
    width: 16px;
    height: 16px;
    transition: transform var(--duration-press) var(--ease-out);
}

.auth-back-link:hover,
.auth-back-link:focus-visible {
    color: var(--color-primary);
}

.auth-back-link:hover svg {
    transform: translateX(-2px);
}

/* Нижняя строка карточки: "Нет доступа?", "Письмо не пришло?". */
.auth-card-footer {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
    text-align: center;
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

/* --- Экраны-состояния: письмо отправлено, ссылка устарела --- */

.auth-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 1.25rem;
    border-radius: 14px;
    background: var(--color-primary-tint);
    color: var(--color-primary);
}

.auth-state-icon svg {
    width: 26px;
    height: 26px;
}

.auth-state-icon-muted {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
}

.auth-hints {
    list-style: none;
    margin: -0.25rem 0 1.5rem;
    padding: 0.85rem 1rem;
    background: var(--color-surface-alt);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.auth-hints li {
    display: flex;
    gap: 0.6rem;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--color-text-muted);
}

.auth-hints li::before {
    content: '';
    flex-shrink: 0;
    width: 5px;
    height: 5px;
    margin-top: 0.5em;
    border-radius: 50%;
    background: var(--color-text-soft);
}

.auth-resend-form {
    margin: 0;
}

/* --- Требования к паролю, отмечаются по мере ввода (auth.js) --- */

.auth-rules {
    list-style: none;
    margin: -0.2rem 0 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.auth-rules li {
    position: relative;
    padding-left: 1.5rem;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--color-text-muted);
    transition: color 0.2s ease;
}

.auth-rules li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.2em;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--color-border-strong);
    border-radius: 50%;
    background: var(--color-surface);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Галочка внутри кружка. */
.auth-rules li::after {
    content: '';
    position: absolute;
    left: 5px;
    top: calc(0.2em + 3px);
    width: 4px;
    height: 7px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg) scale(0.4);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.25s var(--ease-out);
}

.auth-rules li.is-met {
    color: var(--color-success-hover);
}

.auth-rules li.is-met::before {
    background: var(--color-success);
    border-color: var(--color-success);
}

.auth-rules li.is-met::after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

/* --- Поле пароля с переключателем видимости --- */

.password-field input[type="password"],
.password-field input[type="text"] {
    padding-right: 2.9rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.45rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--color-text-soft);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.password-toggle:hover {
    color: var(--color-primary);
    background: var(--color-surface-alt);
}

.password-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-primary);
}

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

.password-toggle .icon-eye-off {
    display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye {
    display: none;
}

.password-toggle[aria-pressed="true"] .icon-eye-off {
    display: block;
}

/* --- Модальное окно с инструкцией по регистрации --- */

.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(43, 38, 32, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
    /* Мягкое появление, как у .modal-overlay: окно открывается снятием
       hidden, и @starting-style срабатывает при каждом открытии. */
    opacity: 1;
    transition: opacity var(--duration-modal) ease;
}

@starting-style {
    .auth-modal-overlay {
        opacity: 0;
    }
}

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

.auth-modal-overlay > .auth-modal {
    transform: scale(1);
    transition: transform var(--duration-modal) var(--ease-out);
}

@starting-style {
    .auth-modal-overlay > .auth-modal {
        transform: scale(0.96);
    }
}

.auth-modal {
    position: relative;
    background: var(--color-surface-alt);
    border-radius: 16px;
    padding: 2rem 2.25rem;
    max-width: 480px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.auth-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.9rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
}

.auth-modal-close:hover {
    color: var(--color-text);
}

.auth-modal h2 {
    font-size: 1.2rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    padding-right: 1.5rem;
}

/* Модалка "Сессия завершена": иконка-часы и кнопка-действие вместо крестика. */
.inactivity-modal h2 {
    padding-right: 0;
}

.inactivity-modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin-bottom: 1rem;
    border-radius: 50%;
    background: var(--color-primary-tint);
    color: var(--color-primary);
}

.inactivity-modal-icon svg {
    width: 24px;
    height: 24px;
}

.inactivity-modal .auth-submit {
    margin-top: 1.4rem;
}

.auth-info-lead {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.auth-steps {
    list-style: none;
    padding-left: 0;
    margin: 0;
    text-align: left;
}

.auth-step {
    display: flex;
    gap: 0.9rem;
    position: relative;
    padding-bottom: 1.5rem;
}

.auth-step:last-child {
    padding-bottom: 0;
}

.auth-step:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 0.875rem;
    top: 1.9rem;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

.auth-step-number {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.auth-step-body {
    flex: 1;
    padding-top: 0.15rem;
}

.auth-step-title {
    display: block;
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.auth-step-text {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

.auth-checklist {
    list-style: none;
    margin: 0.6rem 0 0;
    padding: 0.75rem 0.9rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.auth-checklist li {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.85rem;
    color: var(--color-text);
    line-height: 1.4;
}

.auth-checklist li::before {
    content: '';
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
}

/* --- Адаптив --- */

@media (max-width: 480px) {
    .auth-page {
        padding: 1.25rem 1rem 2rem;
        align-items: flex-start;
    }

    .auth-card {
        padding: 2rem 1.5rem;
    }

    .auth-modal {
        padding: 1.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-shell {
        animation: none;
    }

    .auth-submit.is-loading::before {
        animation-duration: 1.6s;
    }
}
