/* =========================================================================
   Визуал стенда — копия kleinanzeigen.de/m-einloggen.html 1:1.
   Меняйте только этот файл, если нужно поменять внешний вид.
   Дизайн-токены — в :root. Компоненты: .topbar, .prompt-card, .field,
   .field-readonly, .btn, .link.
   ========================================================================= */

:root {
    /* палитра kleinanzeigen */
    --color-page-bg: #ffffff;
    --color-surface: #ffffff;
    --color-text: #0c0c0b;
    --color-text-muted: #767676;
    --color-border: #95958e;
    --color-border-strong: #0c0c0b;
    --color-brand: #326916;
    --color-brand-hover: #1d4b00;
    --color-accent: #b5e941;
    --color-accent-hover: #a5d82e;
    --color-accent-text: #1d4b00;
    --color-danger: #d50018;
    --color-danger-bg: #fbeaec;

    --radius-input: 8px;
    --radius-card: 16px;
    --radius-pill: 9999px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 40px;

    --card-w: 500px;
    --form-w: 420px;
    --topbar-h: 72px;

    --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--color-page-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- топбар: back / логотип / Hilfe --- */

.topbar {
    height: var(--topbar-h);
    padding: 12px var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e6e6e6;
    background: var(--color-surface);
}

.topbar__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--color-brand);
    text-decoration: none;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.topbar__back svg {
    width: 12px;
    height: 12px;
    display: block;
}

.topbar__logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.topbar__logo-img {
    height: 30px;
    width: auto;
    display: block;
}

.topbar__help {
    color: var(--color-brand);
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    line-height: 21px;
}

.topbar__help:hover {
    color: var(--color-brand-hover);
    text-decoration: underline;
}

/* --- страница --- */

.page {
    min-height: calc(100vh - var(--topbar-h));
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: var(--space-7) var(--space-4);
}

/* --- карточка "prompt" --- */

.prompt-card {
    width: 100%;
    max-width: var(--card-w);
    background: var(--color-surface);
    border-radius: var(--radius-card);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.prompt-card__header {
    padding: var(--space-7) var(--space-7) var(--space-5);
    text-align: center;
}

/* иллюстрация над заголовком (используется на 2FA-экране: жёлтый щит kleinanzeigen) */
.prompt-card__illustration {
    display: block;
    margin: 0 auto var(--space-5);
    width: 120px;
    height: 120px;
    max-width: 100%;
}

.prompt-card__title {
    margin: 0 0 var(--space-4);
    font-size: 18px;
    font-weight: 600;
    line-height: 27px;
    color: var(--color-text);
}

.prompt-card__subtitle {
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 21px;
    color: var(--color-text);
}

.prompt-card__body {
    padding: 0 var(--space-7) var(--space-7);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.form {
    width: 100%;
    max-width: var(--form-w);
    display: flex;
    flex-direction: column;
}

/* --- поле с "cut-out" label (label поверх верхней границы) --- */

.field {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field + .field,
.field-readonly + .field {
    margin-top: var(--space-3);
}

.field:focus-within {
    border-color: var(--color-border-strong);
    box-shadow: 0 0 0 1px var(--color-border-strong);
}

.field__input {
    width: 100%;
    height: 100%;
    padding: 0 var(--space-4);
    font-size: 16px;
    font-family: inherit;
    color: var(--color-text);
    background: transparent;
    border: 0;
    outline: none;
    border-radius: var(--radius-input);
}

.field__input::placeholder {
    color: transparent;
}

.field__label {
    position: absolute;
    top: -2px;
    left: 16px;
    padding: 1px 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 14px;
    line-height: 14px;
    font-weight: 400;
    pointer-events: none;
    transform: matrix(0.88, 0, 0, 0.88, -7.04, -8.1664);
    transform-origin: top left;
    z-index: 1;
}

.field__label .required {
    color: var(--color-text);
}

/* --- поле с "глазом" (показать/скрыть пароль) --- */

.field__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0 4px 0 0;
    background: transparent;
    border: 0;
    color: var(--color-accent-text);
    cursor: pointer;
    flex: none;
}

.field__toggle svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* --- поле в состоянии ошибки --- */

.field--error {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 1px var(--color-danger);
}

.field--error .field__label {
    color: var(--color-danger);
}

.field-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 6px 0 0;
    color: var(--color-danger);
    font-size: 13px;
    line-height: 18px;
    font-weight: 400;
}

.field-error::before {
    content: "⚠";
    flex: none;
    font-size: 14px;
    line-height: 1;
    margin-top: 1px;
}

/* «положительное» уведомление в той же строке, что и ошибка — для тоста rewind */
.field-error--info {
    color: var(--color-brand);
}

.field-error--info::before {
    content: "✓";
    color: var(--color-brand);
}

/* --- alert-баннер над формой (по образцу #prompt-alert у kleinanzeigen) --- */

.notice-banner {
    width: 100%;
    max-width: var(--form-w);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--color-danger);
    color: #ffffff;
    border-radius: var(--radius-input);
    font-size: 14px;
    line-height: 1.4;
    font-weight: 400;
}

/* --- зафиксированный e-mail (шаг 2, с "Bearbeiten") --- */

.field-readonly {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    height: 44px;
    padding: 0 var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-input);
}

.field-readonly__value {
    font-size: 16px;
    line-height: 17.6px;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

/* серое «поле-плашка» с маской номера на 2FA-экране (по образцу kleinanzeigen) */
.field-readonly--muted {
    background: #f0f0ec;
    justify-content: flex-start;
    margin-bottom: var(--space-3);
}

.field-readonly--muted .field-readonly__value {
    color: var(--color-text);
    font-weight: 400;
}

/* --- ссылки в форме --- */

.link {
    color: var(--color-brand);
    text-decoration: underline;
    font-size: 14px;
    font-weight: 600;
    line-height: 21px;
    background: none;
    border: 0;
    padding: 4px;
    border-radius: 3px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
}

.link:hover {
    color: var(--color-brand-hover);
}

.link--forgot {
    align-self: flex-start;
    margin-top: var(--space-4);
    padding-left: 0;
}

.link--footer {
    padding: 4px;
}

/* --- кнопка Weiter / Einloggen --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 4px var(--space-4);
    margin-top: var(--space-5);
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    line-height: 14px;
    text-decoration: none;
    border: 0;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background-color 0.15s;
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--color-accent);
    color: var(--color-accent-text);
}

.btn--primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.btn--secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border-strong);
}

.btn--secondary:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* --- футер карточки (Noch nicht registriert? …) --- */

.prompt-card__footer {
    margin: var(--space-4) 0 0;
    text-align: center;
    font-size: 14px;
    line-height: 21px;
    color: var(--color-text);
}

.prompt-card__footer .link {
    display: inline;
    padding: 0 4px;
}

/* --- спиннер в кнопке (состояние await_verdict) --- */

.btn--loading {
    cursor: wait;
    pointer-events: none;
}

.btn--loading .btn__label {
    visibility: hidden;
}

.btn__spinner {
    position: absolute;
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(29, 75, 0, 0.25);
    border-top-color: var(--color-accent-text);
    animation: btn-spinner 0.75s linear infinite;
}

.btn {
    position: relative;
}

@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

/* =========================================================================
   Страница успеха (success.html): топбар с email пользователя справа, карточка
   объявления kleinanzeigen, форма-опросник «Kaufen» и тост-подтверждение.
   Все переменные повторно используются из :root — цвета и радиусы общие
   со страницей логина.
   ========================================================================= */

/* --- топбар в стиле «angemeldet als: user@…» --- */

.topbar--success {
    justify-content: space-between;
    gap: var(--space-3);
}

.topbar__logo-link {
    flex: none;
}

.topbar__account {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--color-text);
    font-size: 14px;
    line-height: 21px;
    min-width: 0;
    flex: 0 1 auto;
}

.topbar__account-label {
    color: var(--color-text);
    flex: none;
}

.topbar__account-email {
    color: var(--color-text);
    font-weight: 400;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.topbar__account-logout {
    color: var(--color-brand);
    text-decoration: none;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--radius-pill);
}

.topbar__account-logout:hover {
    color: var(--color-brand-hover);
    background: rgba(50, 105, 22, 0.08);
}

.topbar__account-bell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--color-text);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.topbar__account-bell svg {
    width: 20px;
    height: 20px;
    display: block;
}

.topbar__account-bell:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* --- каркас страницы --- */

.success-page {
    min-height: calc(100vh - var(--topbar-h));
    padding: var(--space-6) var(--space-4);
    display: flex;
    justify-content: center;
    background: #f4f4f2;
}

.success-shell {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

/* карточка объявления над формой */

.listing-card {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-radius: var(--radius-card);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.listing-card__media {
    width: 100%;
    aspect-ratio: 3 / 2;
    background: #f0f0ec;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.listing-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.listing-card__image-fallback {
    width: 72px;
    height: 72px;
    color: var(--color-text-muted);
}

.listing-card__image-fallback svg {
    width: 100%;
    height: 100%;
    display: block;
}

.listing-card__body {
    padding: var(--space-5) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.listing-card__eyebrow {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 12px;
    line-height: 16px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.listing-card__title {
    margin: 0;
    font-size: 22px;
    line-height: 28px;
    font-weight: 700;
    color: var(--color-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.listing-card__meta {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-3);
}

.listing-card__price {
    color: var(--color-accent-text);
    font-weight: 700;
    font-size: 24px;
    line-height: 30px;
}

.listing-card__location {
    color: var(--color-text-muted);
    font-size: 14px;
    line-height: 20px;
}

.listing-card__link {
    margin-top: var(--space-2);
    color: var(--color-brand);
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    align-self: flex-start;
}

.listing-card__link:hover {
    color: var(--color-brand-hover);
}

/* карточка формы шире, чем у логина */

.prompt-card--wide {
    max-width: 720px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.prompt-card--wide .prompt-card__header {
    padding: var(--space-6) var(--space-6) var(--space-3);
    text-align: left;
}

.prompt-card--wide .prompt-card__body {
    padding: 0 var(--space-6) var(--space-6);
    align-items: stretch;
}

.form--wide {
    max-width: none;
}

/* секции формы */

.form-section {
    border: 0;
    padding: 0;
    margin: 0 0 var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.form-section__legend {
    padding: 0;
    margin: 0 0 var(--space-2);
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.form-section__hint {
    margin: 0 0 var(--space-2);
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 18px;
}

/* две колонки — Vorname/Nachname, PLZ/Ort */

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.form-row--3-2 {
    grid-template-columns: minmax(120px, 1fr) minmax(180px, 2fr);
}

.form-row .field + .field,
.form-section .field + .field {
    /* внутри grid и flex-column уже есть gap; сбрасываем legacy-отступ */
    margin-top: 0;
}

/* Ja/Nein-строки: заголовок слева, две кнопки-«пилюли» справа */

.choice-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 4px 0;
}

.choice-row__label {
    margin: 0;
    color: var(--color-text);
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
}

.choice-row__options {
    display: inline-flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
    color: var(--color-text);
    user-select: none;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.choice input {
    accent-color: var(--color-brand);
    margin: 0;
}

.choice:hover {
    border-color: var(--color-border-strong);
}

.choice:has(input:checked) {
    border-color: var(--color-brand);
    background: rgba(50, 105, 22, 0.08);
    color: var(--color-accent-text);
    font-weight: 600;
}

/* textarea вместо однострочного инпута */

.field--textarea {
    height: auto;
    align-items: stretch;
    padding: 6px 0;
}

.field__input--textarea {
    height: auto;
    min-height: 72px;
    padding: 10px var(--space-4);
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 20px;
}

/* тост «Anfrage gesendet» */

.toast {
    position: fixed;
    left: 50%;
    bottom: var(--space-6);
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-brand);
    color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    max-width: min(420px, calc(100vw - var(--space-6)));
}

.toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast__icon {
    flex: none;
    width: 28px;
    height: 28px;
    color: #ffffff;
}

.toast__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.toast__title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
}

.toast__text {
    margin: 0;
    font-size: 13px;
    line-height: 18px;
    opacity: 0.92;
}

/* адаптив: на узком экране складываем всё в один столбец */

@media (max-width: 560px) {
    .listing-card__media {
        aspect-ratio: 4 / 3;
    }

    .listing-card__body {
        padding: var(--space-4);
    }

    .listing-card__title {
        font-size: 20px;
        line-height: 26px;
    }

    .listing-card__price {
        font-size: 22px;
        line-height: 28px;
    }

    .form-row,
    .form-row--3-2 {
        grid-template-columns: 1fr;
    }

    /* --- Топбар на мобильном ---
       На iPhone (viewport ~ 375pt) полный «angemeldet als: <email> Ausloggen»
       + логотип не влезают в одну строку. Сжимаем: логотип и текст поменьше,
       label скрыт, email обрезается ellipsis'ом, gap уменьшен. */
    .topbar--success {
        padding: 10px 12px;
        gap: 8px;
    }

    .topbar--success .topbar__logo-img {
        height: 22px;
    }

    .topbar__account {
        gap: 8px;
        font-size: 13px;
        line-height: 18px;
    }

    .topbar__account-label {
        display: none;
    }

    .topbar__account-email {
        font-size: 13px;
        max-width: 160px;
    }

    .topbar__account-logout {
        padding: 4px 6px;
    }

    .topbar__account-bell {
        display: none;
    }

    /* карточка формы: убираем толстые отступы, чтоб контент не был зажат */
    .prompt-card--wide .prompt-card__header {
        padding: var(--space-5) var(--space-4) var(--space-3);
    }

    .prompt-card--wide .prompt-card__body {
        padding: 0 var(--space-4) var(--space-5);
    }

    .success-page {
        padding: var(--space-4) var(--space-3);
    }
}

/* --- утилиты --- */

[hidden] {
    display: none !important;
}
