/**
 * PH Accessibility - Frontend Styles
 * Styles für barrierefreie Formular-Labels
 */

/* Visuell verstecktes Label - nur für Screenreader sichtbar */
.ph-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Inline Label für Checkboxen und Radio-Buttons */
.ph-inline-label {
    margin-left: 0.5em;
    cursor: pointer;
}

/* Floating Label Container */
.ph-floating-field {
    position: relative;
    display: block;
    width: 100%;
}

/* Floating Label - Basis-Stil */
.ph-floating-label {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: inherit;
    padding: 0 4px;
    color: #666;
    font-size: 0.9em;
    pointer-events: none;
    transition: all 0.2s ease-out;
    z-index: 1;
    line-height: 1.2;
    background: #fff;
}

/* Floating Label für Textarea - oben positioniert */
.ph-floating-field textarea ~ .ph-floating-label {
    top: 0.8em;
    transform: none;
}

/* Placeholder verstecken wenn Floating Label aktiv */
.ph-floating-field input::placeholder,
.ph-floating-field textarea::placeholder {
    color: transparent;
}

/* Floating Label - aktiver Zustand (bei Fokus oder wenn Inhalt vorhanden) */
.ph-floating-field input:focus ~ .ph-floating-label,
.ph-floating-field input:not(:placeholder-shown) ~ .ph-floating-label,
.ph-floating-field textarea:focus ~ .ph-floating-label,
.ph-floating-field textarea:not(:placeholder-shown) ~ .ph-floating-label,
.ph-floating-field select:focus ~ .ph-floating-label,
.ph-floating-field select:valid ~ .ph-floating-label {
    top: 0;
    transform: translateY(-50%);
    font-size: 0.75em;
    color: #0073aa;
}

/* Textarea: Label nach oben wenn aktiv */
.ph-floating-field textarea:focus ~ .ph-floating-label,
.ph-floating-field textarea:not(:placeholder-shown) ~ .ph-floating-label {
    top: 0;
    transform: translateY(-50%);
}

/* Unterstützung für dunkle Themes */
@media (prefers-color-scheme: dark) {
    .ph-floating-label {
        background: #1e1e1e;
        color: #aaa;
    }

    .ph-floating-field input:focus ~ .ph-floating-label,
    .ph-floating-field input:not(:placeholder-shown) ~ .ph-floating-label,
    .ph-floating-field textarea:focus ~ .ph-floating-label,
    .ph-floating-field textarea:not(:placeholder-shown) ~ .ph-floating-label,
    .ph-floating-field select:focus ~ .ph-floating-label,
    .ph-floating-field select:valid ~ .ph-floating-label {
        color: #5ca9e4;
    }
}

/* ============================================
   FOKUS-SICHTBARKEIT FIXES
   Verschiedene Stile zur Wiederherstellung sichtbarer Fokus-Indikatoren
   ============================================ */

/**
 * Variante 1: Standard-Outline (outline)
 * Klassischer Browser-Standard mit verbesserter Sichtbarkeit
 */
.ph-focus-outline a:focus,
.ph-focus-outline button:focus,
.ph-focus-outline input:focus,
.ph-focus-outline select:focus,
.ph-focus-outline textarea:focus,
.ph-focus-outline [tabindex]:focus,
.ph-focus-outline [role="button"]:focus,
.ph-focus-outline [role="link"]:focus {
    outline: 2px solid #0073aa !important;
    outline-offset: 2px !important;
}

/* Modern: Outline nur bei Tastaturnavigation zeigen */
.ph-focus-outline a:focus:not(:focus-visible),
.ph-focus-outline button:focus:not(:focus-visible),
.ph-focus-outline input:focus:not(:focus-visible),
.ph-focus-outline select:focus:not(:focus-visible),
.ph-focus-outline textarea:focus:not(:focus-visible),
.ph-focus-outline [tabindex]:focus:not(:focus-visible),
.ph-focus-outline [role="button"]:focus:not(:focus-visible),
.ph-focus-outline [role="link"]:focus:not(:focus-visible) {
    outline: none !important;
}

.ph-focus-outline a:focus-visible,
.ph-focus-outline button:focus-visible,
.ph-focus-outline input:focus-visible,
.ph-focus-outline select:focus-visible,
.ph-focus-outline textarea:focus-visible,
.ph-focus-outline [tabindex]:focus-visible,
.ph-focus-outline [role="button"]:focus-visible,
.ph-focus-outline [role="link"]:focus-visible {
    outline: 2px solid #0073aa !important;
    outline-offset: 2px !important;
}

/**
 * Variante 2: Box-Shadow (shadow)
 * Weicherer Fokus-Indikator, der Layout nicht beeinflusst
 */
.ph-focus-shadow a:focus,
.ph-focus-shadow button:focus,
.ph-focus-shadow input:focus,
.ph-focus-shadow select:focus,
.ph-focus-shadow textarea:focus,
.ph-focus-shadow [tabindex]:focus,
.ph-focus-shadow [role="button"]:focus,
.ph-focus-shadow [role="link"]:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.5) !important;
}

.ph-focus-shadow a:focus:not(:focus-visible),
.ph-focus-shadow button:focus:not(:focus-visible),
.ph-focus-shadow input:focus:not(:focus-visible),
.ph-focus-shadow select:focus:not(:focus-visible),
.ph-focus-shadow textarea:focus:not(:focus-visible),
.ph-focus-shadow [tabindex]:focus:not(:focus-visible),
.ph-focus-shadow [role="button"]:focus:not(:focus-visible),
.ph-focus-shadow [role="link"]:focus:not(:focus-visible) {
    box-shadow: none !important;
}

.ph-focus-shadow a:focus-visible,
.ph-focus-shadow button:focus-visible,
.ph-focus-shadow input:focus-visible,
.ph-focus-shadow select:focus-visible,
.ph-focus-shadow textarea:focus-visible,
.ph-focus-shadow [tabindex]:focus-visible,
.ph-focus-shadow [role="button"]:focus-visible,
.ph-focus-shadow [role="link"]:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.5) !important;
}

/**
 * Variante 3: Hochkontrast (high-contrast)
 * Maximale Sichtbarkeit für Benutzer mit Sehbeeinträchtigungen
 */
.ph-focus-high-contrast a:focus,
.ph-focus-high-contrast button:focus,
.ph-focus-high-contrast input:focus,
.ph-focus-high-contrast select:focus,
.ph-focus-high-contrast textarea:focus,
.ph-focus-high-contrast [tabindex]:focus,
.ph-focus-high-contrast [role="button"]:focus,
.ph-focus-high-contrast [role="link"]:focus {
    outline: 3px solid #000 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 6px #fff, 0 0 0 8px #000 !important;
}

.ph-focus-high-contrast a:focus:not(:focus-visible),
.ph-focus-high-contrast button:focus:not(:focus-visible),
.ph-focus-high-contrast input:focus:not(:focus-visible),
.ph-focus-high-contrast select:focus:not(:focus-visible),
.ph-focus-high-contrast textarea:focus:not(:focus-visible),
.ph-focus-high-contrast [tabindex]:focus:not(:focus-visible),
.ph-focus-high-contrast [role="button"]:focus:not(:focus-visible),
.ph-focus-high-contrast [role="link"]:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

.ph-focus-high-contrast a:focus-visible,
.ph-focus-high-contrast button:focus-visible,
.ph-focus-high-contrast input:focus-visible,
.ph-focus-high-contrast select:focus-visible,
.ph-focus-high-contrast textarea:focus-visible,
.ph-focus-high-contrast [tabindex]:focus-visible,
.ph-focus-high-contrast [role="button"]:focus-visible,
.ph-focus-high-contrast [role="link"]:focus-visible {
    outline: 3px solid #000 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 6px #fff, 0 0 0 8px #000 !important;
}

/* Dark Mode Anpassungen für Fokus-Styles */
@media (prefers-color-scheme: dark) {
    .ph-focus-outline a:focus-visible,
    .ph-focus-outline button:focus-visible,
    .ph-focus-outline input:focus-visible,
    .ph-focus-outline select:focus-visible,
    .ph-focus-outline textarea:focus-visible,
    .ph-focus-outline [tabindex]:focus-visible,
    .ph-focus-outline [role="button"]:focus-visible,
    .ph-focus-outline [role="link"]:focus-visible {
        outline-color: #5ca9e4 !important;
    }

    .ph-focus-shadow a:focus-visible,
    .ph-focus-shadow button:focus-visible,
    .ph-focus-shadow input:focus-visible,
    .ph-focus-shadow select:focus-visible,
    .ph-focus-shadow textarea:focus-visible,
    .ph-focus-shadow [tabindex]:focus-visible,
    .ph-focus-shadow [role="button"]:focus-visible,
    .ph-focus-shadow [role="link"]:focus-visible {
        box-shadow: 0 0 0 3px rgba(92, 169, 228, 0.6) !important;
    }

    .ph-focus-high-contrast a:focus-visible,
    .ph-focus-high-contrast button:focus-visible,
    .ph-focus-high-contrast input:focus-visible,
    .ph-focus-high-contrast select:focus-visible,
    .ph-focus-high-contrast textarea:focus-visible,
    .ph-focus-high-contrast [tabindex]:focus-visible,
    .ph-focus-high-contrast [role="button"]:focus-visible,
    .ph-focus-high-contrast [role="link"]:focus-visible {
        outline-color: #fff !important;
        box-shadow: 0 0 0 6px #000, 0 0 0 8px #fff !important;
    }
}
