/* ==========================================================================
 * Auth_Replace.css — Полная тема для страницы авторизации Battery Passport
 * Author: Mikhail Deynekin (mid1977@gmail.com)
 * ========================================================================== */

/* Сброс и базовая типографика */
*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont,
                 "SF Pro Text", "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── Тема: light/dark через переменные ─────────────────── */

:root {
    color-scheme: light;

    /* фон страницы */
    --auth-bg:  #eef2ff;
    --auth-bg-gradient:
        radial-gradient(circle at 10% 20%, #e0f2fe 0, transparent 45%),
        radial-gradient(circle at 90% 20%, #e9d5ff 0, transparent 45%),
        radial-gradient(circle at 50% 100%, #fee2e2 0, transparent 50%),
        linear-gradient(135deg, #e5e7eb 0%, #f9fafb 100%);

    /* карточка */
    --auth-card-bg:     #ffffff;
    --auth-card-border: rgba(148,163,184,.45);
    --auth-card-shadow: 0 24px 60px rgba(15,23,42,.18);
    --auth-card-radius: 1.4rem;

    /* текст */
    --auth-fg:       #0f172a;
    --auth-fg-muted: #6b7280;
    --auth-fg-soft:  #9ca3af;

    /* бренд */
    --auth-brand:      #0f172a;
    --auth-brand-soft: #e0f2fe;

    /* инпуты (светлая тема) */
    --auth-input-bg:         #f9fafb;
    --auth-input-border:     #d1d5db;
    --auth-input-fg:         #111827;
    --auth-input-placeholder:#9ca3af;
    --auth-input-focus:      #2563eb;
    --auth-input-ring:       rgba(37,99,235,.18);

    /* кнопка */
    --auth-btn-bg:     linear-gradient(135deg, #2563eb, #4f46e5);
    --auth-btn-hover:  linear-gradient(135deg, #1d4ed8, #4338ca);
    --auth-btn-shadow: 0 14px 30px rgba(37,99,235,.35);

    /* ошибка */
    --auth-error-bg:     #fef2f2;
    --auth-error-border: #fecaca;
    --auth-error-fg:     #b91c1c;

    /* ссылки */
    --auth-link:       #2563eb;
    --auth-link-hover: #1d4ed8;
}

html.dark {
    color-scheme: dark;

    --auth-bg:  #020617;
    --auth-bg-gradient:
        radial-gradient(circle at 0% 0%, rgba(56,189,248,.18) 0, transparent 55%),
        radial-gradient(circle at 100% 0%, rgba(129,140,248,.20) 0, transparent 55%),
        radial-gradient(circle at 50% 120%, rgba(248,113,113,.22) 0, transparent 60%),
        linear-gradient(135deg, #020617 0%, #020617 100%);

    --auth-card-bg:     rgba(15,23,42,.96);
    --auth-card-border: rgba(148,163,184,.5);
    --auth-card-shadow: 0 28px 70px rgba(15,23,42,.95);
    --auth-card-radius: 1.4rem;

    --auth-fg:       #e5e7eb;
    --auth-fg-muted: #a5b4fc;
    --auth-fg-soft:  #64748b;

    --auth-brand:      #38bdf8;
    --auth-brand-soft: rgba(56,189,248,.16);

    /* инпуты (тёмная тема) */
    --auth-input-bg:         rgba(15,23,42,.86);
    --auth-input-border:     #1e293b;
    --auth-input-fg:         #e5e7eb;
    --auth-input-placeholder:#64748b;
    --auth-input-focus:      #38bdf8;
    --auth-input-ring:       rgba(56,189,248,.24);

    --auth-btn-bg:     linear-gradient(135deg, #0ea5e9, #6366f1);
    --auth-btn-hover:  linear-gradient(135deg, #38bdf8, #818cf8);
    --auth-btn-shadow: 0 18px 40px rgba(15,23,42,.9);

    --auth-error-bg:     rgba(239,68,68,.12);
    --auth-error-border: rgba(252,165,165,.45);
    --auth-error-fg:     #fecaca;

    --auth-link:       #38bdf8;
    --auth-link-hover: #7dd3fc;
}

/* ── Макет: страница без вертикального скролла ─────────── */

body {
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--auth-bg);
    background-image: var(--auth-bg-gradient);
    background-attachment: fixed;
    color: var(--auth-fg);
    overflow: hidden;
}

main.auth-wrapper {
    flex: 1 0 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

@media (max-width: 640px) {
    main.auth-wrapper {
        padding: 1.2rem;
    }
}

/* ── Карточка логина ───────────────────────────────────── */

.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: var(--auth-card-radius);
    background: var(--auth-card-bg);
    border: 1px solid var(--auth-card-border);
    box-shadow: var(--auth-card-shadow);
    padding: 2.25rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    row-gap: .8rem;
}

@media (max-height: 720px) {
    .auth-card {
        padding: 1.8rem 1.7rem 1.6rem;
    }
}
@media (max-height: 640px) {
    .auth-card {
        padding: 1.5rem 1.5rem 1.4rem;
    }
}

/* ── Бренд ---------------------------------------------------------------- */

.auth-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin-bottom: 1.7rem;
}

.auth-brand__icon {
    width: 2.3rem;
    height: 2.3rem;
    color: var(--auth-brand);
    flex-shrink: 0;
}

.auth-brand__name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--auth-fg);
    letter-spacing: -.015em;
}

/* ── Заголовки ----------------------------------------------------------- */

.auth-card__title {
    margin: 0 0 .25rem;
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--auth-fg);
    letter-spacing: -.02em;
}

.auth-card__subtitle {
    margin: 0 0 1.7rem;
    font-size: .87rem;
    color: var(--auth-fg-muted);
}

/* ── Ошибка -------------------------------------------------------------- */

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .8rem 1rem;
    border-radius: .7rem;
    margin-bottom: 1.2rem;
    font-size: .86rem;
    font-weight: 500;
    line-height: 1.4;
    background: var(--auth-error-bg);
    border: 1px solid var(--auth-error-border);
    color: var(--auth-error-fg);
}

.auth-alert svg {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
    margin-top: .04em;
}

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

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: .2rem;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.auth-field__label {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--auth-fg-soft);
}

.auth-field__wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-field__icon {
    position: absolute;
    left: .85rem;
    width: 1.1rem;
    height: 1.1rem;
    color: var(--auth-fg-soft);
    pointer-events: none;
    transition: color .18s ease;
}

.auth-field__input {
    width: 100%;
    padding: .72rem 1rem .72rem 2.75rem;
    border-radius: .7rem;
    border: 1px solid var(--auth-input-border);
    background: var(--auth-input-bg);
    color: var(--auth-input-fg);
    font-size: .92rem;
    outline: none;
    transition:
        border-color .16s ease,
        box-shadow .16s ease,
        background-color .16s ease;
}

.auth-field__input::placeholder {
    color: var(--auth-input-placeholder);
}

.auth-field__input:focus {
    border-color: var(--auth-input-focus);
    box-shadow: 0 0 0 3px var(--auth-input-ring);
    background: var(--auth-input-bg);
}

.auth-field__wrap:focus-within .auth-field__icon {
    color: var(--auth-input-focus);
}

.auth-field__input--error {
    border-color: #ef4444;
}

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

.auth-field__toggle {
    position: absolute;
    right: .8rem;
    background: none;
    border: none;
    padding: .2rem;
    cursor: pointer;
    color: var(--auth-fg-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .16s ease, transform .12s ease;
}

.auth-field__toggle svg {
    width: 1.1rem;
    height: 1.1rem;
}

.auth-field__toggle:hover,
.auth-field__toggle.active {
    color: var(--auth-input-focus);
    transform: translateY(-1px);
}

/* ── Кнопка входа -------------------------------------------------------- */

.auth-btn {
    margin-top: .8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .82rem 1.5rem;
    border-radius: .8rem;
    border: none;
    outline: none;
    background-image: var(--auth-btn-bg);
    color: #ffffff;
    font-size: .94rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--auth-btn-shadow);
    transition:
        background-image .16s ease,
        transform .12s ease,
        box-shadow .16s ease,
        opacity .14s ease;
}

.auth-btn svg {
    width: 1.05rem;
    height: 1.05rem;
}

.auth-btn:hover {
    background-image: var(--auth-btn-hover);
    transform: translateY(-1px);
    opacity: .96;
}

.auth-btn:active {
    transform: translateY(0);
    box-shadow: 0 9px 24px rgba(15,23,42,.7);
    opacity: 1;
}

/* ── Доп. мелкий текст/ссылки (если появятся) ------------- */

.auth-meta {
    margin-top: 1.1rem;
    font-size: .78rem;
    color: var(--auth-fg-soft);
    display: flex;
    justify-content: space-between;
    gap: .75rem;
}

.auth-meta a {
    color: var(--auth-link);
    text-decoration: none;
}
.auth-meta a:hover {
    color: var(--auth-link-hover);
    text-decoration: underline;
}

/* ── Адаптивное «уплотнение» карточки --------------------- */

.auth-card.auth-compact-1 {
    padding-top: 1.6rem;
    padding-bottom: 1.4rem;
}
.auth-card.auth-compact-1 .auth-card__subtitle {
    margin-bottom: 1.1rem;
}
.auth-card.auth-compact-1 .auth-form {
    gap: .75rem;
}

.auth-card.auth-compact-2 .auth-brand {
    display: none;
}
.auth-card.auth-compact-2 {
    padding-top: 1.2rem;
}
.auth-card.auth-compact-2 .auth-card__title {
    margin-bottom: .15rem;
    font-size: 1.35rem;
}
.auth-card.auth-compact-2 .auth-card__subtitle {
    margin-bottom: .9rem;
    font-size: .8rem;
}
.auth-card.auth-compact-2 .auth-form {
    gap: .6rem;
}

/* опционально: скрыть логотип в header, если не хватает высоты */
body.auth-hide-header-brand header .bp-wrap > .flex > a:first-child {
    display: none;
}

/* ── FOOTER: как на остальных страницах ------------------- */

.bp-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(148,163,184,.35);
    background: rgba(248,250,252,.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

html.dark .bp-footer {
    border-top-color: rgba(15,23,42,.8);
    background: rgba(15,23,42,.96);
}

.bp-footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: .6rem 1.75rem .55rem;
}

.bp-footer-bottom {
    padding-top: .4rem;
    border-top: 1px solid rgba(226,232,240,.9);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    font-size: .72rem;
    white-space: nowrap;
    color: #6b7280;
}

html.dark .bp-footer-bottom {
    border-top-color: rgba(30,41,59,.95);
    color: #9ca3af;
}

.bp-footer-copy {
    display: inline-flex;
    align-items: center;
    gap: .15rem;
}

.bp-footer-copy a {
    color: #2563eb;
    text-decoration: none;
}
.bp-footer-copy a:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

html.dark .bp-footer-copy a {
    color: #38bdf8;
}
html.dark .bp-footer-copy a:hover {
    color: #7dd3fc;
}

.bp-footer-version {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

.bp-footer-version svg {
    width: .8rem;
    height: .8rem;
}

/* ── Мелкая адаптация для узких экранов ------------------- */

@media (max-width: 380px) {
    .auth-card {
        padding: 1.35rem 1.25rem 1.25rem;
        border-radius: 1.1rem;
    }
    .auth-brand {
        margin-bottom: 1.3rem;
    }
    .auth-card__subtitle {
        margin-bottom: 1.3rem;
    }
}

/* ── Уровень 3: скрываем header, карточка к верху ────────── */

body.auth-hide-header header.bp-header {
    display: none;
}

body.auth-hide-header main.auth-wrapper {
    align-items: flex-start;
    padding-top: 0;
    padding-bottom: 0;
}

body.auth-hide-header .auth-card {
    border-radius: 0 0 var(--auth-card-radius) var(--auth-card-radius);
    border-top: none;
    margin-top: 0;
}

/* ── Уровень 4: скрываем заголовок и подзаголовок ─────────── */

body.auth-minimal .auth-card__title,
body.auth-minimal .auth-card__subtitle {
    display: none;
}

body.auth-minimal .auth-form {
    margin-top: 0;
}

/* ── Минимальный режим: фон = фон инпутов, без рамки ───── */

body.auth-minimal {
    background-color: var(--auth-input-bg);
    background-image: none;
}

body.auth-minimal .auth-card {
    border: none;
    box-shadow: none;
    background: var(--auth-input-bg);
    border-radius: 0;
}

/* убираем лишние внешние отступы у main */
body.auth-minimal main.auth-wrapper {
    padding-top: 0;
    padding-bottom: 0;
}

/* и так же для случая, когда header ещё был скрыт раньше */
body.auth-hide-header.auth-minimal .auth-card {
    margin-top: 0;
}
