/* ══════════════════════════════════════════════════════════════════
   LOGIN-CSS - INHALTSVERZEICHNIS
   ──────────────────────────────────────────────────────────────────
   Spezifische Styles fuer alle Auth-Seiten:
   login.php, 2fa.php, passwort-vergessen.php, passwort-reset.php,
   erster-login.php, registrierung.php, kein-zugriff.php, etc.

   Sektionen (suche im Editor nach ═══-Markern):

    1. PAGE & CONTAINER         - Hintergrund, Container, Form-Row
    2. HEADER & BRANDING        - Logo, Titel, Version
    3. CARD                     - Weisse Karten-Box
    4. MESSAGES                 - Error/Warning/Info/Success
    5. FORM & INPUTS            - Inputs mit Icon, Autofill-Reset
    6. CODE-INPUT (2FA)         - 6-stellige Code-Boxen
    7. BUTTONS                  - Login-Button + States
    8. LINKS & FOOTER           - Sekundaere Links
    9. RESOLUTION WARNING       - Mobile-/Aufloesungs-Hinweis
   10. PASSWORD REQUIREMENTS    - Live-Validierung der Pw-Regeln
   11. STEPS PROGRESS           - Mehrstufige Flow-Anzeige
   12. CODE TIMER & RESEND      - Countdown + Erneut-Senden
   13. CAPTCHA                  - Slider-Captcha Hilfe
   14. LOGIN TOOLBAR            - Theme-Toggle etc.
   ══════════════════════════════════════════════════════════════════ */

/**
 * Markenportal - Login Page Styles
 * Gemeinsame Styles für alle Login-Seiten:
 * - login.php
 * - 2fa.php
 * - erster-login.php
 * - passwort-vergessen.php
 * - passwort-reset.php
 */

/* ─── Base ──────────────────────────────────────────────────────────── */
html, body {
    height: 100%;
    overflow: auto;
}


/* ══════════════════════════════════════════════════════════════════
    1. PAGE & CONTAINER
   Login-Page-Hintergrund + Container-Layout
   ══════════════════════════════════════════════════════════════════ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

/* Brand gradient background */
.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    right: -50%;
    bottom: -50%;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255, 0, 80, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(250, 155, 210, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 0, 80, 0.05) 0%, transparent 70%);
    pointer-events: none;
    animation: gradient-shift 20s ease-in-out infinite;
}

@keyframes gradient-shift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(2%, -2%) rotate(1deg); }
    66% { transform: translate(-2%, 2%) rotate(-1deg); }
}

.login-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

/* Wide-Variante für Pre-Auth-Formulare mit vielen Feldern (z. B.
   /registrierung Form-Step und Gruppen-Auswahl-Step). Behält den
   Login-Family-Look (Logo, Gradient, Card), gibt dem Form aber Luft
   zu atmen - schmaler 420px-Stack wäre bei 5 Inputs + 14 Modul-Pillen
   zu eng. Inputs mit 2-Spalten-Grid (siehe .form-row-2) nutzen die
   Breite zusätzlich aus. */
.login-container.login-container-wide {
    max-width: 640px;
}

/* 2-Spalten-Grid für kurze Form-Felder die nebeneinander stehen können
   (Vorname/Nachname, Telefon/Position). Auf Mobile bricht's automatisch
   auf 1 Spalte (siehe Mobile-Override). */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ─── Header ────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
    2. HEADER & BRANDING
   Logo, Titel, Version, Subtitle
   ══════════════════════════════════════════════════════════════════ */

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 1rem;
    filter: drop-shadow(0 0 40px var(--brand-red-glow)) drop-shadow(0 0 80px var(--brand-red-glow));
    animation: signet-pulse 3s ease-in-out infinite;
}

.login-logo.login-logo-lg {
    width: 120px;
    height: 120px;
}

@keyframes signet-pulse {
    0%, 100% { filter: drop-shadow(0 0 40px var(--brand-red-glow)) drop-shadow(0 0 80px var(--brand-red-glow)); }
    50% { filter: drop-shadow(0 0 50px var(--brand-red-glow)) drop-shadow(0 0 100px rgba(255, 0, 80, 0.5)); }
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-title {
    font-family: 'ReutlingenSans', sans-serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.login-title strong {
    font-weight: 700;
    color: var(--brand-red);
}

.login-version {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

/* ─── Card ──────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
    3. CARD
   Weisse Karten-Box mit Schatten
   ══════════════════════════════════════════════════════════════════ */

.login-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

/* ─── Messages ──────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
    4. MESSAGES
   Error/Warning/Info/Success-Banner
   ══════════════════════════════════════════════════════════════════ */

.login-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.login-message svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

.login-message-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.login-message-warning {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.25);
    color: #fbbf24;
}

.login-message-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: #60a5fa;
}

/* Inline-Links innerhalb von Hinweisboxen erben die Box-Farbe und werden
   dezent unterstrichen, statt im Browser-Default als knallblauer Link zu
   wirken. Gilt für error/warning/info/success gleichermaßen. */
.login-message a {
    color: inherit;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.login-message a:hover {
    text-decoration: none;
}

.login-message-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: #4ade80;
}

/* ─── Form ──────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
    5. FORM & INPUTS
   Form-Group, Input-Wrapper, Autofill-Reset
   ══════════════════════════════════════════════════════════════════ */

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group label svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.input-wrapper {
    position: relative;
}

.input-wrapper svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition);
}

/* Login Input Styles - Überschreibt Browser-Defaults */
.login-form .input-wrapper input,
.login-form .input-wrapper input[type="email"],
.login-form .input-wrapper input[type="password"],
.login-form .input-wrapper input[type="text"] {
    width: 100%;
    height: auto;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    font-family: 'Abel', sans-serif;
    font-size: 1rem;
    background: #333333;
    background: var(--bg-input, #333333);
    border: 1px solid #3a3a3a;
    border: 1px solid var(--border, #3a3a3a);
    border-radius: 6px;
    border-radius: var(--radius-md, 6px);
    color: #ffffff;
    color: var(--text-primary, #ffffff);
    transition: all 0.15s ease;
    transition: all var(--transition, 0.15s ease);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
}

/* Autofill-Styles überschreiben (Chrome, Safari).
   Browser-Autofill malt sonst seinen eigenen gelben/blauen Hintergrund.
   Wir kapern das mit einem riesigen Inset-Shadow als Pseudo-Background.
   Default = Dark; Light wird unten in einem [data-theme="light"]-Block
   uebersteuert (sonst kleben die Inputs auch im Light-Mode dunkel,
   sobald der Browser autofillt). */
.login-form .input-wrapper input:-webkit-autofill,
.login-form .input-wrapper input:-webkit-autofill:hover,
.login-form .input-wrapper input:-webkit-autofill:focus,
.login-form .input-wrapper input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #333333 inset !important;
    -webkit-text-fill-color: #ffffff !important;
    border: 1px solid #3a3a3a !important;
    transition: background-color 5000s ease-in-out 0s;
}

[data-theme="light"] .login-form .input-wrapper input:-webkit-autofill,
[data-theme="light"] .login-form .input-wrapper input:-webkit-autofill:hover,
[data-theme="light"] .login-form .input-wrapper input:-webkit-autofill:focus,
[data-theme="light"] .login-form .input-wrapper input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #f0f0f2 inset !important;
    -webkit-text-fill-color: #1d1d1f !important;
    border: 1px solid #d2d2d7 !important;
}

.login-form .input-wrapper input:hover {
    border-color: #4a4a4a;
    border-color: var(--border-hover, #4a4a4a);
}

.login-form .input-wrapper input:focus {
    outline: none;
    border-color: #3b82f6;
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.3);
}

.input-wrapper input:focus + svg,
.input-wrapper:focus-within svg {
    color: var(--accent, #3b82f6);
}

.login-form .input-wrapper input::placeholder {
    color: #707070;
    color: var(--text-muted, #707070);
}

/* ─── Code Input (2FA, Erster Login) ────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
    6. CODE-INPUT (2FA)
   6-stellige Code-Eingabe-Boxen
   ══════════════════════════════════════════════════════════════════ */

.code-input {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    text-align: center;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

/* Individual code boxes */
.code-input-wrapper {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

input[type="text"].code-input-box {
    width: 48px;
    height: 72px;
    text-align: center;
    font-family: 'Abel', sans-serif;
    font-size: 1.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all 0.15s ease;
}

input[type="text"].code-input-box:hover {
    border-color: var(--border-hover);
}

input[type="text"].code-input-box:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted), 0 0 20px rgba(59, 130, 246, 0.3);
}

/* ─── Button ────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
    7. BUTTONS
   Primaerer Login-Button + States
   ══════════════════════════════════════════════════════════════════ */

.login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    margin-top: 0.25rem;
    font-family: 'Abel', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.login-button:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-glow);
}

.login-button:active {
    transform: scale(0.98);
}

.login-button svg {
    width: 18px;
    height: 18px;
}

.login-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Links ─────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
    8. LINKS & FOOTER
   Sekundaere Links, Footer-Bereich
   ══════════════════════════════════════════════════════════════════ */

.login-links {
    display: flex;
    justify-content: space-between;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.login-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

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

.login-link svg {
    width: 14px;
    height: 14px;
}

/* ─── Footer ────────────────────────────────────────────────────────── */
.login-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.login-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.login-footer a:hover {
    color: var(--accent);
}

/* ─── Resolution Warning ────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
    9. RESOLUTION WARNING
   Hinweis bei kleiner Bildschirmaufloesung
   ══════════════════════════════════════════════════════════════════ */

.resolution-warning {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.98);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.resolution-warning-content {
    max-width: 400px;
}

.resolution-warning svg {
    width: 64px;
    height: 64px;
    color: var(--brand-red);
    margin-bottom: 1.5rem;
}

.resolution-warning h2 {
    font-family: 'ReutlingenSans', sans-serif;
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0 0 1rem;
}

.resolution-warning p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
}


/* ══════════════════════════════════════════════════════════════════
   10. PASSWORD REQUIREMENTS
   Live-Validierung der Passwort-Regeln
   ══════════════════════════════════════════════════════════════════ */

.password-requirement svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.password-requirement.valid {
    color: var(--success);
}

.password-requirement.valid svg {
    color: var(--success);
}

/* ─── Steps Indicator ───────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════════
   11. STEPS PROGRESS
   Mehrstufiger Flow: Login-Steps Bar mit Dots
   ══════════════════════════════════════════════════════════════════ */

.login-steps,
.steps {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.login-step,
.step {
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    transition: all 0.2s ease;
}

.login-step.active,
.step.active {
    background: var(--accent);
}

.login-step.completed,
.step.done {
    background: var(--success);
}


/* ══════════════════════════════════════════════════════════════════
   12. CODE TIMER & RESEND
   Countdown + Erneut-Senden-Link
   ══════════════════════════════════════════════════════════════════ */

.code-timer strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.resend-link:disabled,
.resend-link.disabled {
    color: var(--text-muted);
    pointer-events: none;
}


/* ══════════════════════════════════════════════════════════════════
   13. CAPTCHA
   Slider-Captcha Label/Hint
   ══════════════════════════════════════════════════════════════════ */

.captcha-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ─── Login-Card Toolbar ────────────────────────────────────────────────
   Absolute oben rechts INNERHALB der `.login-container`-Card auf allen
   Pre-Auth-Seiten (login, registrierung, datenschutz, ...). Damit sitzt
   der Toggle visuell am Card-Header und ist nicht weit weg am Viewport-
   Rand. Container ist auf weitere Controls vorbereitet. */

/* ══════════════════════════════════════════════════════════════════
   14. LOGIN TOOLBAR
   Theme-Toggle + andere Toolbar-Elemente
   ══════════════════════════════════════════════════════════════════ */

.login-toolbar {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* .theme-toggle hat in app.css ein `margin-left: 8px` (passt zum Header,
   wo er neben anderen Controls steht). In der Login-Toolbar steht er
   allein - margin-left zuruecksetzen, sonst sitzt er nicht buendig
   rechts. */
.login-toolbar .theme-toggle {
    margin-left: 0;
}

/* ──────────────────────────────────────────────────────────────────────
   MOBILE-OVERRIDES (Touch-First Optimierung)

   Greift unter 600px Viewport-Breite. Best Practice:
   - Touch-Targets >= 48px (Apple HIG: 44pt, Material: 48dp)
   - Volle Viewport-Breite minus minimaler Edge-Padding
   - Inputs >= 16px font-size (iOS Safari zoomt sonst beim Fokus)
   - Login-Links untereinander statt nebeneinander
   - Logo + Header etwas kompakter, damit das Form schneller ins Bild kommt

   Wichtig: das Markenportal selbst sperrt unter 1024×768 ab (siehe
   resolution-warning in login.php). Die /registrierung-Seite ist die
   einzige öffentliche Seite, die diese Sperre umgehen muss - der
   QR-Code-Scan-Use-Case ist mobil. Daher diese Mobile-Optimierung
   exklusiv für login.css, das app.css-Lockout läuft separat.
   ────────────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .login-page {
        padding: 1rem;
        align-items: flex-start;     /* Form ans obere Ende, nicht zentriert wegen Tastatur */
        padding-top: 1.5rem;
    }

    .login-container {
        max-width: 100%;
    }

    .login-logo {
        width: 72px;
        height: 72px;
        margin-bottom: 0.75rem;
    }

    .login-title {
        font-size: 1.4rem;
    }

    .login-card {
        padding: 1.25rem;
        border-radius: var(--radius-md);
    }

    /* Touch-freundliche Inputs: ausreichend hoch + 16px font damit iOS
       beim Fokus nicht zoomt. */
    .login-form .input-wrapper input,
    .login-form .input-wrapper input[type="email"],
    .login-form .input-wrapper input[type="password"],
    .login-form .input-wrapper input[type="text"] {
        padding-top: 1rem;
        padding-bottom: 1rem;
        font-size: 1rem;             /* schon 16px - verhindert iOS-Zoom */
    }

    /* Buttons mind. 48px hoch für Touch (Apple HIG / Material). */
    .login-button {
        padding-top: 0.95rem;
        padding-bottom: 0.95rem;
        font-size: 1rem;
    }

    /* Code-Boxen (2FA / Verify) etwas kleiner damit sie auf 360px-Screens
       in eine Reihe passen. */
    input[type="text"].code-input-box {
        width: 40px;
        height: 60px;
        font-size: 1.25rem;
    }

    /* Verify-Code-Single-Input bleibt vorhandenes 1-Feld-Pattern, nur
       grössere Schrift für Lesbarkeit. */
    .login-form input#code {
        text-align: center;
        letter-spacing: 0.4rem;
        font-size: 1.5rem;
    }

    /* Login-Links untereinander statt space-between - auf 360px wäre das
       sonst gequetscht. */
    .login-links {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }

    .login-link {
        font-size: 0.875rem;         /* einen Tick grösser für Touch-Erkennbarkeit */
    }

    /* Toggle-Chips (Module-Auswahl, Gruppen-Auswahl) bekommen mehr
       Padding für Touch-Komfort. */
    .toggle-chip {
        padding: 10px 14px !important;
    }

    /* 2-Spalten-Grid bricht auf Mobile auf 1-Spalte um. Wichtig: KEIN
       `gap` mehr - weder am login-form, noch am form-row-2. Stattdessen
       erzwingen wir alle vertikalen Abstaende ueber margin-bottom auf
       jedem Form-Block. Grund: Mischung von grid-row-gap (im form-row-2)
       und flex-gap (im login-form) wirkt visuell ungleich, selbst wenn
       beide nominell 1rem sind. Mit margin-bottom als einziger Quelle
       sind alle Uebergaenge garantiert exakt gleich. */
    .login-form { gap: 0; }

    .form-row-2 {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .login-form > .form-group,
    .login-form > .form-row-2,
    .form-row-2 > .form-group {
        margin-bottom: 1rem;
    }

    .login-form > *:last-child,
    .form-row-2 > *:last-child {
        margin-bottom: 0;
    }
}

/* Conditional Visibility für Cross-Device-Workflows. Auf der
   Registrierungs-Seite zeigen wir z. B. den „Zum Login"-Link nur auf
   Desktop, weil die Login-Seite selbst Mobile sperrt - ein Mobil-User
   würde dort nur den 1024×768-Hinweis sehen. Stattdessen kriegt er auf
   Mobile einen klaren Done-Hinweis: „Aktivierungslink am Computer öffnen". */
@media (max-width: 600px) {
    .desktop-only { display: none !important; }
}
@media (min-width: 601px) {
    .mobile-only { display: none !important; }
}
