/* Auth-Template v1.1 – Login, Registrierung, Passwort vergessen/zurücksetzen, 2FA.
   Farben über CSS-Variablen; Markenfarbe kommt aus der Konfiguration (--auth-primary). */

.auth-root {
  --auth-primary: #4f6bed;
  --auth-on-primary: #fff;
  --auth-bg: #f3f4f8;
  --auth-surface: #ffffff;
  --auth-text: #161a22;
  --auth-muted: #5b6273;
  --auth-border: #d8dbe4;
  --auth-input: #ffffff;
  --auth-error: #c42b2b;
  --auth-error-bg: #fdeeee;
  --auth-ok: #1d7a45;
  --auth-ok-bg: #e8f5ed;
  --auth-info-bg: color-mix(in srgb, var(--auth-primary) 10%, var(--auth-surface));
  --auth-warn: #9a6200;
  --auth-soft: color-mix(in srgb, var(--auth-primary) 22%, transparent);
  --auth-radius: 12px;
  --auth-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  .auth-root:not([data-theme="light"]) {
    --auth-bg: #0f1115; --auth-surface: #171a20; --auth-text: #e9ebf0; --auth-muted: #9aa1b1;
    --auth-border: #2d323c; --auth-input: #12151a; --auth-error: #ff8a80; --auth-error-bg: #3a1d1d;
    --auth-ok: #7fd6a0; --auth-ok-bg: #173323; --auth-warn: #f2c14e;
    color-scheme: dark;
  }
}
.auth-root[data-theme="dark"] {
  --auth-bg: #0f1115; --auth-surface: #171a20; --auth-text: #e9ebf0; --auth-muted: #9aa1b1;
  --auth-border: #2d323c; --auth-input: #12151a; --auth-error: #ff8a80; --auth-error-bg: #3a1d1d;
  --auth-ok: #7fd6a0; --auth-ok-bg: #173323; --auth-warn: #f2c14e;
  color-scheme: dark;
}

.auth-root, .auth-root * { box-sizing: border-box; }
.auth-root {
  position: relative;
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: 1fr;
  background: var(--auth-bg); color: var(--auth-text);
  font: 15px/1.5 var(--auth-font);
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 960px) { .auth-root { grid-template-columns: minmax(380px, 5fr) 7fr; } }

/* ---------- Markenbereich (nur Desktop) ---------- */
.auth-brand {
  display: none; position: relative; overflow: hidden; isolation: isolate;
  flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 48px 56px; color: #fff;
  background: linear-gradient(150deg, var(--auth-primary), color-mix(in srgb, var(--auth-primary) 45%, #05070d));
}
.auth-brand::before, .auth-brand::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(70px); opacity: .55;
}
.auth-brand::before { width: 420px; height: 420px; right: -140px; top: -120px; background: color-mix(in srgb, var(--auth-primary) 60%, #fff); }
.auth-brand::after { width: 360px; height: 360px; left: -120px; bottom: -140px; background: color-mix(in srgb, var(--auth-primary) 40%, #000); }
@media (min-width: 960px) { .auth-brand { display: flex; } }
.auth-brand-top { display: flex; align-items: center; gap: 12px; font-weight: 650; font-size: 18px; }
.auth-brand h2 { font-size: clamp(28px, 3vw, 40px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 20px; max-width: 14em; font-weight: 700; }
.auth-brand ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.auth-brand li { display: flex; gap: 10px; align-items: flex-start; opacity: .92; }
.auth-brand li svg { flex: none; margin-top: 2px; }
.auth-brand-foot { font-size: 13px; opacity: .7; }

.auth-logo {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: var(--auth-primary); color: var(--auth-on-primary); font-weight: 700; font-size: 16px;
}
.auth-brand .auth-logo { background: rgba(255,255,255,.16); backdrop-filter: blur(6px); }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Formularbereich ---------- */
/* Schutz gegen globale Styles der Host-App (main, label, h1, p …) */
.auth-root .auth-main, .auth-root .auth-card, .auth-root .auth-brand { margin: 0; max-width: none; min-width: 0; }
.auth-root .auth-card { max-width: 400px; }
.auth-root .auth-label, .auth-root .auth-check { margin: 0; padding: 0; text-transform: none; letter-spacing: normal; }
.auth-root .auth-field > label { margin: 0; }
.auth-root .auth-checks .auth-check { margin: 0; }
.auth-root .auth-terms { margin: -4px 0 16px; }
.auth-root p { max-width: none; }
.auth-main {
  display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
@media (max-width: 959px) { .auth-main { padding-top: max(64px, env(safe-area-inset-top)); } }
@media (min-width: 960px) { .auth-main { background: var(--auth-surface); padding: 48px; } }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--auth-surface); border-radius: 24px; padding: 32px 24px;
  box-shadow: 0 1px 2px rgba(16,24,40,.06), 0 12px 32px -12px rgba(16,24,40,.18);
}
@media (min-width: 960px) { .auth-card { box-shadow: none; padding: 0; border-radius: 0; } }
.auth-card-head { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 28px; }
@media (min-width: 960px) { .auth-card-head { display: none; } }

.auth-view { animation: auth-in .22s ease-out; }
@keyframes auth-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.auth-root .auth-title { font-size: 26px; line-height: 1.25; letter-spacing: -.015em; margin: 0 0 6px; font-weight: 700; }
.auth-sub { color: var(--auth-muted); margin: 0 0 24px; }

.auth-field { display: grid; gap: 6px; margin-bottom: 16px; }
.auth-label { font-size: 13px; font-weight: 600; }
.auth-input-wrap { position: relative; }
.auth-root .auth-input {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--auth-border); border-radius: var(--auth-radius);
  background: var(--auth-input); color: inherit;
  font: inherit; font-size: 16px; /* 16px verhindert Zoom auf iOS */
  transition: border-color .15s, box-shadow .15s;
}
.auth-root .auth-input::placeholder { color: color-mix(in srgb, var(--auth-muted) 70%, transparent); }
.auth-root .auth-input:hover { border-color: color-mix(in srgb, var(--auth-text) 30%, var(--auth-border)); }
.auth-root .auth-input:focus { outline: none; border-color: var(--auth-primary); box-shadow: 0 0 0 4px var(--auth-soft); }
.auth-root .auth-input[aria-invalid="true"] { border-color: var(--auth-error); }
.auth-root .auth-input.has-eye { padding-right: 52px; }
.auth-root .auth-eye {
  position: absolute; right: 4px; top: 4px; width: 40px; height: 40px;
  display: grid; place-items: center; border: 0; border-radius: 9px;
  background: none; color: var(--auth-muted); cursor: pointer;
}
.auth-root .auth-eye:hover { background: var(--auth-soft); color: var(--auth-text); }
.auth-hint { font-size: 13px; color: var(--auth-muted); display: flex; gap: 6px; align-items: center; }
.auth-hint.warn { color: var(--auth-warn); }
.auth-hint[hidden] { display: none; }
.auth-root .auth-otp { text-align: center; font-size: 26px; letter-spacing: .45em; padding-left: calc(14px + .45em); font-variant-numeric: tabular-nums; height: 60px; }

.auth-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 4px; }
.auth-meter span { height: 4px; border-radius: 2px; background: var(--auth-border); transition: background .2s; }
.auth-meter[data-score="1"] span:nth-child(-n+1) { background: var(--auth-error); }
.auth-meter[data-score="2"] span:nth-child(-n+2) { background: #e08a00; }
.auth-meter[data-score="3"] span:nth-child(-n+3) { background: #7cb342; }
.auth-meter[data-score="4"] span { background: var(--auth-ok); }

.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 4px 12px; flex-wrap: wrap; margin: -2px 0 20px; }
.auth-checks { display: grid; gap: 2px; }
.auth-check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; min-height: 32px; user-select: none; }
.auth-root .auth-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--auth-primary); flex: none; }

.auth-root .auth-link { color: var(--auth-primary); font-weight: 600; text-decoration: none; border-radius: 4px; }
.auth-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-root[data-theme="dark"] .auth-link { color: color-mix(in srgb, var(--auth-primary) 65%, #fff); }
@media (prefers-color-scheme: dark) { .auth-root:not([data-theme="light"]) .auth-link { color: color-mix(in srgb, var(--auth-primary) 65%, #fff); } }

.auth-root .auth-btn {
  width: 100%; min-height: 48px; padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid transparent; border-radius: var(--auth-radius);
  background: var(--auth-primary); color: var(--auth-on-primary);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: filter .15s, transform .05s, background .15s;
}
.auth-root .auth-btn:hover { filter: brightness(1.07); }
.auth-btn:active { transform: translateY(1px); }
.auth-btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.auth-btn[aria-busy="true"] { pointer-events: none; }
.auth-btn[aria-busy="true"] .auth-btn-label { opacity: .75; }
.auth-root .auth-btn.secondary { background: var(--auth-surface); color: var(--auth-text); border-color: var(--auth-border); }
.auth-root .auth-btn.secondary:hover { filter: none; background: color-mix(in srgb, var(--auth-text) 5%, var(--auth-surface)); }
.auth-btn + .auth-btn { margin-top: 10px; }
.auth-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: auth-spin .7s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--auth-muted); font-size: 13px; margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--auth-border); }

.auth-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--auth-radius); font-size: 14px; margin-bottom: 16px; }
.auth-alert[hidden] { display: none; }
.auth-alert svg { flex: none; margin-top: 1px; }
.auth-alert.error { background: var(--auth-error-bg); color: var(--auth-error); }
.auth-alert.ok { background: var(--auth-ok-bg); color: var(--auth-ok); }
.auth-alert.info { background: var(--auth-info-bg); color: var(--auth-text); }

.auth-panel { text-align: center; }
.auth-panel-icon { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; background: var(--auth-soft); color: var(--auth-primary); }
.auth-panel-icon.ok { background: var(--auth-ok-bg); color: var(--auth-ok); }
.auth-panel-icon.error { background: var(--auth-error-bg); color: var(--auth-error); }
.auth-panel p { color: var(--auth-muted); margin: 0 0 24px; }

.auth-terms { margin: -4px 0 16px; align-items: flex-start; }
.auth-terms input { margin-top: 3px; }
.auth-flow-links { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.auth-fixed-user { margin: -8px 0 16px; }
.auth-note { text-align: center; margin-top: 16px; font-size: 13px; color: var(--auth-muted); }
.auth-foot { text-align: center; margin-top: 24px; font-size: 14px; color: var(--auth-muted); }
.auth-back { display: inline-flex; align-items: center; gap: 6px; }
.auth-legal { text-align: center; margin-top: 32px; font-size: 12px; color: var(--auth-muted); display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.auth-legal a { color: inherit; }

.auth-theme {
  position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--auth-border); background: var(--auth-surface); color: var(--auth-muted); cursor: pointer;
}
.auth-theme:hover { color: var(--auth-text); }

.auth-root :focus-visible { outline: 3px solid var(--auth-soft); outline-offset: 2px; }
.auth-root .auth-input:focus-visible { outline: none; }
.auth-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .auth-view, .auth-spinner { animation: none; }
  .auth-input, .auth-btn, .auth-meter span { transition: none; }
}

/* Ohne Seitenspalte: Formular mittig über die ganze Breite */
.auth-root.auth-no-brand { grid-template-columns: 1fr !important; }
