/*
 * Login-Seiten für den Profil-Login (templates/user-profile). Ersetzt dort PrimeFlex und das Theme.
 * Markenfarben setzt LoginBrandingService als CSS-Variablen am html-Element (--brand*, --brand-d*, --icon-*).
 */
:root {
    --brand: #1f5fd6;
    --brand-fg: #ffffff;
    --brand-ink: #1f5fd6;
    --brand-d: #1f5fd6;
    --brand-d-fg: #ffffff;
    --brand-d-ink: #6f9cf0;
    --icon-bg: #1f5fd6;
    --icon-fg: #ffffff;

    --btn: var(--brand);
    --btn-fg: var(--brand-fg);
    --ink: var(--brand-ink);
    --bg: #ffffff;
    --canvas: #f4f6f9;
    --fg: #111827;
    --muted: #5f6b7a;
    --line: #d6dbe3;
    --field: #ffffff;
    --err: #b42318;
    --err-bg: #fef3f2;
    --scrim: rgb(0 0 0 / .4);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --btn: var(--brand-d);
        --btn-fg: var(--brand-d-fg);
        --ink: var(--brand-d-ink);
        --bg: #12161c;
        --canvas: #0b0e12;
        --fg: #eef1f5;
        --muted: #9aa5b4;
        --line: #2e3743;
        --field: #181d24;
        --err: #fda29b;
        --err-bg: #2a1614;
        --scrim: rgb(0 0 0 / .6);
        color-scheme: dark;
    }
}

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

html, body { height: 100%; }

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--fg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

.lp-main {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left));
}

.lp-card {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

@media (min-width: 560px) {
    body { background: var(--canvas); }
    .lp-main { align-items: center; padding-block: 40px; }
    .lp-card {
        background: var(--bg);
        border: 1px solid var(--line);
        border-radius: 16px;
        padding: 40px;
        box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px rgb(0 0 0 / .06);
    }
}

/* Kopf: Icon + App-Name */
.lp-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lp-icon {
    position: relative;
    width: 48px;
    height: 48px;
    flex: none;
    border-radius: 11px;
    overflow: hidden;
    display: grid;
    place-items: center;
    color: var(--icon-fg);
    font-weight: 700;
    font-size: 17px;
    background: var(--icon-bg);
    box-shadow: 0 0 0 1px rgb(0 0 0 / .08), 0 2px 6px rgb(0 0 0 / .12);
}
.lp-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--bg); }
.lp-appname { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }

.lp-head { display: flex; flex-direction: column; gap: 6px; }
.lp-head h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
.lp-head p { margin: 0; color: var(--muted); font-size: 15px; }
.lp-head strong { color: var(--fg); font-weight: 600; overflow-wrap: anywhere; }

/* Formulare */
.lp-form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.lp-field { display: flex; flex-direction: column; gap: 6px; }
.lp-field label { font-size: 14px; font-weight: 600; }
.lp-input {
    font: inherit;
    font-size: 16px;
    height: 48px;
    width: 100%;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--field);
    color: var(--fg);
}
.lp-input:focus, .lp-otp input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 25%, transparent);
}
.lp-input[aria-invalid="true"] { border-color: var(--err); }

.lp-error { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--err); }
.lp-error svg { flex: none; margin-top: 2px; }
.lp-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--err-bg); color: var(--err); font-size: 15px; }
.lp-alert svg { flex: none; margin-top: 2px; }
.lp-alert p { margin: 0; }

.lp-btn {
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    height: 48px;
    width: 100%;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: var(--btn);
    color: var(--btn-fg);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: filter .15s, opacity .15s;
}
.lp-btn:hover { filter: brightness(1.07); }
.lp-btn:disabled { opacity: .45; cursor: default; filter: none; }
.lp-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; }
.lp-btn.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.lp-btn.text { background: transparent; color: var(--fg); width: auto; }

.lp-link { color: var(--ink); font-weight: 500; text-decoration: none; }
.lp-link:hover { text-decoration: underline; }
.lp-meta { margin: 0; font-size: 14px; color: var(--muted); text-align: center; }
.lp-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; color: var(--muted); font-size: 15px; }
.lp-list li { display: flex; gap: 10px; align-items: flex-start; }
.lp-list svg { flex: none; margin-top: 3px; }

/* 6-stelliger Code */
.lp-otp { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.lp-otp input {
    font: inherit;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    height: 56px;
    width: 100%;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--field);
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}

/* Zustimmung */
.lp-check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.lp-check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--btn); }
.lp-check a { color: var(--ink); }
.lp-mailchip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    max-width: 100%;
    padding: 6px 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--line) 45%, transparent);
    font-size: 14px;
    font-weight: 500;
    overflow-wrap: anywhere;
}

/* Statussymbol (Fehler, Postfach) */
.lp-status { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--err-bg); color: var(--err); }
.lp-status.info { background: color-mix(in srgb, var(--ink) 12%, transparent); color: var(--ink); }

.lp-spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--ink);
    animation: lp-spin .8s linear infinite;
    align-self: center;
}
@keyframes lp-spin { to { transform: rotate(360deg); } }

.lp-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 16px;
    padding: 16px 24px max(22px, env(safe-area-inset-bottom));
    font-size: 13px;
    color: var(--muted);
}
.lp-foot a { color: inherit; text-decoration: none; }
.lp-foot a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Dialog für Datenschutz/Nutzungsbedingungen */
.legal-mask {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--scrim);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, visibility .2s;
}
.legal-mask.open { opacity: 1; visibility: visible; }
.legal-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 56rem;
    height: 90vh;
    height: 90dvh;
    background: var(--bg);
    border-radius: 16px;
    box-shadow: 0 24px 48px rgb(0 0 0 / .25);
    overflow: hidden;
    transform: scale(.96);
    transition: transform .2s;
}
.legal-mask.open .legal-dialog { transform: scale(1); }
.legal-header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 24px; border-bottom: 1px solid var(--line); }
.legal-title { flex: 1; margin: 0; font-size: 18px; font-weight: 600; }
.legal-icon {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.legal-icon:hover { background: color-mix(in srgb, var(--line) 50%, transparent); color: var(--fg); }
.legal-icon:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); }
.legal-body { position: relative; flex: 1; min-height: 0; background: #ffffff; }
.legal-body iframe { display: block; width: 100%; height: 100%; border: none; }
.legal-loading { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.legal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px; border-top: 1px solid var(--line); }
.legal-footer .lp-btn { width: auto; }

@media (max-width: 575px) {
    .legal-mask { padding: .5rem; }
    .legal-dialog { height: 100%; }
    .legal-footer { padding: 12px 16px; }
    .legal-footer .lp-btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation-duration: 2s !important; }
}
