/**
 * S4G Auth-Komponenten — nutzt ausschliesslich Tokens aus s4g-tokens.css.
 * Erste Komponente: Meldungen direkt im Formular statt als schwebender Toast.
 */

/* Meldungsbereich im Formular */
.s4g-formmessages {
  margin: 0 0 var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.s4g-alert {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  border-radius: var(--radius-md);
  padding: 12px var(--space-4);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

.s4g-alert__icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.s4g-alert--error {
  background: var(--s4g-red-50);
  border: 1px solid var(--s4g-red-200);
  color: var(--s4g-red-700);
}

.s4g-alert--success {
  background: var(--s4g-green-50);
  border: 1px solid var(--s4g-green-200);
  color: var(--s4g-green-700);
}

.s4g-alert p,
.s4g-auth .s4g-alert p { margin: 0; font-size: inherit; line-height: inherit; font-weight: 400; color: inherit; }
.s4g-alert p + p { margin-top: var(--space-1); }

/* ===========================================================================
   Auth-Layout (Anmelden, Passwort zuruecksetzen; Registrieren folgt)
   Markup: .s4g-auth > .s4g-auth__brand + .s4g-auth__panel
   Desktop: beide Spalten genau eine Bildschirmhoehe, die Illustration passt
   sich der verfuegbaren Hoehe an (kein Scrollen). Mobil: Markenleiste oben,
   Formular darunter.
   =========================================================================== */
.s4g-authpage { background: var(--color-surface); }

.s4g-auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-surface);
}

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

/* Linke Seite: Markenflaeche */
.s4g-auth__brand {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6) var(--space-7);
  color: var(--color-on-invert);
  background:
    radial-gradient(120% 90% at 85% 8%, rgba(121, 128, 219, .55), transparent 60%),
    radial-gradient(90% 70% at 10% 100%, rgba(65, 75, 178, .5), transparent 65%),
    var(--color-surface-invert);
}

.s4g-auth__brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .14) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .35;
  pointer-events: none;
}

/* logo.svg enthaelt Bildmarke UND Schriftzug -> kein zusaetzlicher Text */
.s4g-auth__logo { position: relative; z-index: 1; display: inline-flex; align-self: flex-start; border-radius: var(--radius-sm); }
.s4g-auth__logo img { display: block; height: 38px; width: auto; filter: brightness(0) invert(1); }

/* Illustration: nimmt nur den Platz, der uebrig ist */
.s4g-auth__art {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.s4g-auth__art img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  padding: var(--space-4);
  background: rgba(255, 255, 255, .92);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.s4g-auth__claim { position: relative; z-index: 1; max-width: 34ch; }
.s4g-auth__claim h2 {
  margin: 0 0 var(--space-2);
  font-size: clamp(24px, 2.2vw, 32px);
  line-height: 1.12;
  font-style: italic;
  font-weight: 800;
  letter-spacing: -.02em;
  text-wrap: balance;
  color: var(--color-on-invert);
}
.s4g-auth__claim p { margin: 0; font-size: 15px; font-weight: 300; line-height: 1.55; color: var(--color-on-invert-muted); }

.s4g-auth__facts { position: relative; z-index: 1; display: flex; flex-direction: column; gap: var(--space-2); margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--color-on-invert-muted); }
.s4g-auth__facts li { display: flex; align-items: center; gap: var(--space-2); }
.s4g-auth__facts svg { flex: 0 0 auto; width: 18px; height: 18px; stroke: #A9B2F2; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Rechte Seite: Formular */
.s4g-auth__panel {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-6) var(--space-7);
  background: var(--color-surface);
}
.s4g-auth__top { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-2); min-height: 48px; font-size: 14px; color: var(--color-text-subtle); }
.s4g-auth__top a { display: inline-flex; align-items: center; min-height: 48px; color: var(--s4g-indigo-600); font-weight: 600; text-decoration: none; }
.s4g-auth__top a:hover { text-decoration: underline; }

.s4g-form { width: 100%; max-width: 400px; margin: auto; padding: var(--space-5) 0; }
.s4g-form h1 {
  margin: 0 0 var(--space-2);
  font-size: 32px;
  line-height: 1.1;
  font-style: italic;
  font-weight: 800;
  letter-spacing: -.02em;
  text-wrap: balance;
  color: var(--color-text);
}
.s4g-form__lead { margin: 0 0 var(--space-6); font-size: 14.5px; font-weight: 400; line-height: 1.6; color: var(--color-text-muted); }
.s4g-form form { margin: 0; }

.s4g-field { margin-bottom: var(--space-4); }
.s4g-field > label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; line-height: 1.4; color: var(--color-text); }
.s4g-control { position: relative; display: flex; align-items: center; }
.s4g-auth .s4g-control input {
  display: block;
  width: 100%;
  height: auto;
  min-height: 48px;
  margin: 0;
  padding: 12px 52px 12px 14px;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: none;
  appearance: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.s4g-auth .s4g-control input::placeholder { color: var(--color-placeholder); opacity: 1; }
.s4g-auth .s4g-control input:hover { border-color: #CDC8E8; }
.s4g-auth .s4g-control input:focus { outline: 0; border-color: var(--color-focus); box-shadow: 0 0 0 4px rgba(65, 75, 178, .14); }
.s4g-control__icon { position: absolute; right: 8px; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; color: var(--color-text-subtle); background: none; border: 0; border-radius: var(--radius-sm); }
button.s4g-control__icon { cursor: pointer; }
button.s4g-control__icon:hover { background: var(--s4g-indigo-50); }
.s4g-control__icon svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.s4g-control__icon .s4g-eye-off { display: none; }
.s4g-control__icon[aria-pressed="true"] .s4g-eye { display: none; }
.s4g-control__icon[aria-pressed="true"] .s4g-eye-off { display: block; }
.s4g-field__hint { margin: 6px 0 0; font-size: 13px; color: var(--s4g-red-700); }

.s4g-form__help { display: flex; justify-content: flex-end; margin: -4px 0 var(--space-5); }
.s4g-form__help a { display: inline-flex; align-items: center; min-height: 40px; font-size: 13.5px; font-weight: 500; color: var(--s4g-indigo-600); text-decoration: none; }
.s4g-form__help a:hover { text-decoration: underline; }

.s4g-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 50px;
  margin: 0;
  padding: 13px var(--space-5);
  font: inherit;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-on-invert);
  background: var(--color-action);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), filter var(--dur-fast) var(--ease-out);
}
.s4g-btn:hover { filter: brightness(1.07); box-shadow: var(--shadow-md); }
.s4g-btn:active { transform: translateY(1px); }

.s4g-form__swap { margin: var(--space-5) 0 0; text-align: center; font-size: 14px; color: var(--color-text-muted); }
.s4g-form__swap a { color: var(--s4g-indigo-600); font-weight: 600; text-decoration: none; }
.s4g-form__swap a:hover { text-decoration: underline; }
.s4g-form__legal { margin: var(--space-4) 0 0; text-align: center; font-size: 12.5px; line-height: 1.5; color: var(--color-text-subtle); }
.s4g-form__legal a { color: var(--color-text-subtle); text-decoration: underline; }

.s4g-auth :where(a, button, input):focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.s4g-auth__brand :where(a):focus-visible { outline-color: var(--color-on-invert); }

/* Niedrige Bildschirme: Illustration weglassen statt scrollen */
@media (min-width: 921px) and (max-height: 720px) {
  .s4g-auth__art { display: none; }
  .s4g-auth__claim { margin-top: auto; }
}

@media (max-width: 920px) {
  .s4g-auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .s4g-auth__brand { position: relative; height: auto; gap: var(--space-4); padding: var(--space-5); }
  .s4g-auth__art, .s4g-auth__facts { display: none; }
  .s4g-auth__logo img { height: 32px; }
  .s4g-auth__claim h2 { font-size: 22px; }
  .s4g-auth__claim p { font-size: 14px; }
  .s4g-auth__panel { min-height: 0; padding: var(--space-4) var(--space-5) var(--space-6); }
  .s4g-auth__top { justify-content: flex-start; }
  .s4g-form { margin: 0 auto; padding-top: var(--space-2); }
  .s4g-form h1 { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .s4g-auth *, .s4g-auth *::before, .s4g-auth *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
