/**
 * Fabre Breton Management Tool - Auth-Styles
 * 
 * Diese Datei stellt Auth-spezifische CSS-Styles bereit.
 */

/* Auth-Container Grundstruktur */
.fbm-auth-container {
    min-height: 100vh;
    width: 100%;
    background-size: cover;
    background-position: center;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Logo-Positionierung */
.fbm-auth-logo {
    text-align: center;
    padding: 20px 0;
    margin: 0;
    width: 100%;
    background: inherit;
}

.fbm-logo-img {
    max-height: 80px;
    max-width: 250px;
    height: auto;
    width: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    display: block;
}

/* Weißer Container mit Formular */
.fbm-auth-form {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    /* width wird dynamisch über Backend-Option gesetzt */
    max-width: 100%;
    min-width: 350px;
    margin: 0 auto;
}

/* Formular-Header */
.fbm-auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.fbm-auth-header h2 {
    margin: 0 0 10px 0;
    color: #1f2937;
    font-size: 28px;
    font-weight: 600;
}

.fbm-auth-header p {
    margin: 0;
    color: #6b7280;
    font-size: 16px;
}

/* Formular-Gruppen */
.fbm-form-group {
    margin-bottom: 20px;
}

.fbm-form-group label {
    display: block;
    margin-bottom: 8px;
    color: #374151;
    font-weight: 500;
    font-size: 14px;
}

.fbm-form-group input[type="text"],
.fbm-form-group input[type="email"],
.fbm-form-group input[type="password"],
.fbm-form-group input[type="date"],
.fbm-form-group select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    display: block;
}

/* iOS/Safari: natives Datumsfeld hat sonst eine feste Mindestbreite und ragt aus der Card */
.fbm-form-group input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    -webkit-min-logical-width: 0;
}

.fbm-date-input {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
}

.fbm-date-input input[type="date"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.fbm-field-hint {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.4;
    color: #6b7280;
}

.fbm-form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Passwort-Input mit Toggle (Button rechts im Feld, keine Bewegung) */
.fbm-password-input {
    position: relative;
    width: 100%;
}

.fbm-password-input input {
    padding-right: 48px; /* Platz für den Toggle-Button */
    box-sizing: border-box;
}

.fbm-password-input .fbm-password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    min-width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.fbm-password-input .fbm-password-toggle:hover {
    color: #667eea;
    transform: translateY(-50%); /* Keine Bewegung, nur Farbänderung */
}

/* Checkbox (Barrierefrei: höhere Spezifität gegen .fbm-form-group label { display: block }) */
.fbm-form-group:has(> .fbm-checkbox-label) {
    display: flex;
    justify-content: center;
}

.fbm-form-group label.fbm-checkbox-label {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin-bottom: 0;
    width: auto;
    max-width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: #6b7280;
    padding: 0.375rem 0;
}

.fbm-form-group label.fbm-checkbox-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    max-width: 1.25rem;
    flex-shrink: 0;
    margin: 0.125rem 0 0;
    padding: 0;
    border: none;
    box-shadow: none;
    accent-color: #667eea;
}

.fbm-form-group label.fbm-checkbox-label input[type="checkbox"]:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.fbm-form-group label.fbm-checkbox-label .fbm-checkbox-label__text {
    flex: 0 1 auto;
    min-width: 0;
}

.fbm-form-group label.fbm-checkbox-label .fbm-checkbox-label__text i[aria-hidden="true"] {
    margin-right: 0.375rem;
    color: #667eea;
}

.fbm-checkbox-label {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.625rem;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    text-align: left;
}

.fbm-checkbox-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    flex-shrink: 0;
    margin: 0.125rem 0 0;
    accent-color: #667eea;
}

/* Button */
.fbm-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.fbm-btn-primary {
    background: #667eea;
    color: white;
}

.fbm-btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-2px);
}

/* Login-Seite / nicht eingeloggt: Anmelde-Button und Auth-UI immer im Light-Mode,
   damit kein Dark-Mode vom vorherigen User übernommen wird. */
html[data-theme="light-mode"] .fbm-custom-page-wrapper .fbm-btn-primary,
body:not(.logged-in) .fbm-custom-page-wrapper .fbm-btn-primary {
    background: #667eea !important;
    color: #fff !important;
}
html[data-theme="light-mode"] .fbm-custom-page-wrapper .fbm-btn-primary:hover,
body:not(.logged-in) .fbm-custom-page-wrapper .fbm-btn-primary:hover {
    background: #5a67d8 !important;
    color: #fff !important;
}
html[data-theme="light-mode"] .fbm-custom-page-wrapper .fbm-btn-secondary,
body:not(.logged-in) .fbm-custom-page-wrapper .fbm-btn-secondary {
    background: #6b7280 !important;
    color: #fff !important;
}
html[data-theme="light-mode"] .fbm-custom-page-wrapper .fbm-btn-id-austria,
body:not(.logged-in) .fbm-custom-page-wrapper .fbm-btn-id-austria {
    background: #e60012 !important;
    color: #fff !important;
}
html[data-theme="light-mode"] .fbm-custom-page-wrapper .fbm-btn-id-austria:hover,
body:not(.logged-in) .fbm-custom-page-wrapper .fbm-btn-id-austria:hover {
    background: #c41e3a !important;
    color: #fff !important;
}

.fbm-btn-secondary {
    background: #6b7280;
    color: white;
}

.fbm-btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-2px);
}

/* Toggle-Button soll keine Bewegung haben (nur Hover-Farbe) */
.fbm-password-input .fbm-password-toggle.fbm-btn-secondary:hover {
    transform: translateY(-50%); /* Bleibt zentriert, keine Bewegung */
    background: transparent; /* Kein Hintergrund-Change */
}

/* Progress-Bar für Multi-Step */
.fbm-progress-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
}

.fbm-progress-bar::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e5e7eb;
    z-index: 1;
}

.fbm-progress-step {
    position: relative;
    z-index: 2;
    text-align: center;
    flex: 1;
}

.fbm-step-number {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    line-height: 40px;
    font-weight: 600;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.fbm-step-label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.fbm-progress-step.active .fbm-step-number {
    background: #667eea;
    color: white;
}

.fbm-progress-step.active .fbm-step-label {
    color: #667eea;
}

/* Schritt-Formulare */
.fbm-form-step {
    display: none;
}

.fbm-form-step.active {
    display: block;
}

/* Passwort-Reset Step 3: Drei Optionen */
.fbm-step3-intro {
    margin-bottom: 20px;
    color: #374151;
    font-size: 15px;
}

.fbm-reset-option {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.fbm-reset-option h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.fbm-reset-option h3 i {
    margin-right: 8px;
    color: #667eea;
}

.fbm-reset-option p {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

.fbm-reset-option .fbm-form-group {
    margin-bottom: 12px;
}

.fbm-reset-option .fbm-btn {
    margin-top: 4px;
}

.fbm-reset-contact-hint {
    font-size: 13px !important;
    color: #9ca3af !important;
}

/* Einladungscode: Label, QR-Scan (Kamera) — immer Spalte (schützt vor mobile „alle Kinder in einer Flex-Zeile“ in fbm-custom-layout) */
.fbm-form-group.fbm-invitation-code-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.fbm-invitation-code-group .fbm-form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

/* Einladungscode: Eingabe + QR-Icon rechts (wie Passwort-Toggle) */
.fbm-invitation-input-row {
    position: relative;
    width: 100%;
}

.fbm-invitation-input-row input[type="text"] {
    width: 100%;
    padding-right: 48px;
    box-sizing: border-box;
}

.fbm-invite-qr-trigger {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.fbm-invite-qr-trigger:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

.fbm-invite-qr-trigger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Registrierung Schritt 1: Hinweis auf öffentliche Gast-Seiten (z. B. Checkout / Abo) */
.fbm-registration-guest-cta {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(107, 114, 128, 0.25);
}

.fbm-registration-guest-cta__title {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
}

.fbm-registration-guest-cta__intro {
    margin: 0 0 0.85rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: #6b7280;
}

.fbm-registration-guest-cta__links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fbm-registration-guest-cta__link {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    text-decoration: none !important;
}

button.fbm-registration-guest-cta__link {
    font-family: inherit;
    line-height: inherit;
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
}

.fbm-registration-guest-cta__link i {
    margin-right: 0.4em;
    font-size: 0.9em;
    opacity: 0.9;
}

/* QR-Scanner-Modal: hoher z-index für Kamera/WebView; kein Padding am Root (Overlay = fullscreen) */
.fbm-invite-qr-modal.fbm-ui-modal {
    z-index: 2147483645 !important;
    padding: 0 !important;
    box-sizing: border-box;
    margin: 0 !important;
}

/* Geschlossen: kein unsichtbares Vollbild-Overlay über der Registrierungsseite (Rechtstext-Links!) */
.fbm-invite-qr-modal.fbm-ui-modal[aria-hidden="true"],
.fbm-invite-qr-modal.fbm-ui-modal[aria-hidden="true"] * {
    pointer-events: none !important;
}

.fbm-invite-qr-modal.fbm-ui-modal[aria-hidden="false"] {
    pointer-events: auto !important;
}

.fbm-invite-qr-modal.fbm-ui-modal[aria-hidden="false"] .fbm-ui-modal-container,
.fbm-invite-qr-modal.fbm-ui-modal[aria-hidden="false"] .fbm-invite-qr-modal-backdrop,
.fbm-invite-qr-modal.fbm-ui-modal[aria-hidden="false"] .fbm-ui-modal-close,
.fbm-invite-qr-modal.fbm-ui-modal[aria-hidden="false"] .fbm-invite-qr-modal-close,
.fbm-invite-qr-modal.fbm-ui-modal[aria-hidden="false"] .fbm-btn {
    pointer-events: auto !important;
}

.fbm-invite-qr-modal-backdrop,
.fbm-invite-qr-modal .fbm-ui-modal-overlay {
    cursor: pointer;
    background: rgba(15, 23, 42, 0.5) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

.fbm-invite-qr-modal .fbm-ui-modal-container {
    max-height: min(90vh, 640px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

/* Auth-Rechtstexte (Nutzungsbedingungen / Datenschutz) — schmal wie Passwort-Reset-Modal */
#fbm-legal-modal.fbm-ui-modal {
    padding: 16px;
    box-sizing: border-box;
}

#fbm-legal-modal .fbm-ui-modal-container,
#fbm-legal-modal .fbm-legal-modal-container,
.fbm-legal-modal-root .fbm-legal-modal-container {
    width: min(640px, 92vw) !important;
    max-width: min(640px, 92vw) !important;
}

#fbm-legal-modal .fbm-ui-modal-body,
.fbm-legal-modal-root .fbm-ui-modal-body {
    max-height: min(70vh, 560px);
    overflow-y: auto;
}

.fbm-legal-modal-root .fbm-legal-content,
#fbm-legal-modal .fbm-legal-content {
    max-width: 56rem;
    margin: 0 auto;
}

.fbm-invite-qr-modal .fbm-ui-modal-header {
    padding: 14px 16px;
}

.fbm-invite-qr-modal .fbm-ui-modal-title {
    font-size: 18px;
    font-weight: 600;
}

.fbm-invite-qr-modal-close {
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.fbm-invite-qr-modal .fbm-ui-modal-body {
    padding: 12px;
    flex: 1;
    min-height: 200px;
    overflow: auto;
    background: #0f172a;
}

.fbm-invite-qr-modal-error {
    display: none;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.45;
    color: #fecaca;
    background: rgba(127, 29, 29, 0.45);
    border: 1px solid rgba(248, 113, 113, 0.5);
}

.fbm-invite-qr-modal-error:not(:empty) {
    display: block;
}

.fbm-invite-qr-modal .fbm-ui-modal-footer {
    padding: 12px 16px;
}

.fbm-invite-qr-modal .fbm-ui-modal-footer .fbm-btn {
    width: 100%;
}

.fbm-invite-qr-reader {
    width: 100%;
    max-width: 100%;
    min-height: 200px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #334155;
    background: #0f172a;
    box-sizing: border-box;
}

.fbm-invite-qr-reader video,
.fbm-invite-qr-reader canvas {
    display: block;
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
}

/* Erfolgsmeldung: QR zum Teilen des Einladungscodes */
.fbm-invite-qrcode-wrap {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    text-align: center;
}

.fbm-invite-qrcode-wrap .fbm-groups-field-description {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #4b5563;
}

.fbm-invite-qrcode-wrap table {
    margin: 0 auto;
}

/* Responsive Design */
@media (max-width: 767px) {
    .fbm-auth-form {
        /* width und margin werden über Inline-CSS gesetzt */
        padding: 30px 20px;
    }
    
    .fbm-auth-logo {
        padding: 15px 0;
    }
    
    .fbm-logo-img {
        max-height: 60px;
        max-width: 200px;
    }
}
