/*
 * Accessibility CSS für WCAG 2.1 Level AA Konformität
 * Enthält Fokusmanagement, Kontraste und Skip-Link
 */

/* Skip-Link - Zum Hauptinhalt springen */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #1976d2;
    color: white;
    padding: 8px;
    z-index: 100000;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 6px;
    color: white;
    text-decoration: none;
    outline: 3px solid #ffeb3b;
    outline-offset: 2px;
}

/* Fokusmanagement - Sichtbarer Fokus für alle interaktiven Elemente */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: 3px solid #1976d2;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px rgba(25, 118, 210, 0.2);
}

/* Fokus für Bootstrap-Buttons überschreiben */
.btn:focus {
    outline: 3px solid #1976d2 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px rgba(25, 118, 210, 0.2) !important;
}

/* Fokus für Navigationselemente */
.nav-link:focus {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Fokus für Formularelementen */
.form-control:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 0.2rem rgba(25, 118, 210, 0.25);
    outline: 3px solid #1976d2;
    outline-offset: 2px;
}

/* Kontraste für bessere Lesbarkeit */
/* Mindestkontrast 4.5:1 für normalen Text - überschreibt style.css */
.text-muted {
    color: #555555 !important; /* Verbesserter Kontrast von #6c757d statt default Bootstrap */
}

/* Links mit ausreichendem Kontrast */
a {
    color: #1565c0; /* Dunkleres Blau für besseren Kontrast */
}

a:hover {
    color: #0d47a1;
}

/* Fehlerfarben mit ausreichendem Kontrast */
.text-danger {
    color: #c62828 !important; /* Dunkleres Rot */
}

.alert-danger {
    background-color: #ffebee;
    border-color: #ef5350;
    color: #c62828;
}

/* Erfolgsfarben mit ausreichendem Kontrast */
.text-success {
    color: #2e7d32 !important; /* Dunkleres Grün */
}

.alert-success {
    background-color: #e8f5e8;
    border-color: #4caf50;
    color: #2e7d32;
}

/* Warnungsfarben mit ausreichendem Kontrast */
.text-warning {
    color: #ef6c00 !important; /* Dunkleres Orange */
}

.alert-warning {
    background-color: #fff8e1;
    border-color: #ff9800;
    color: #ef6c00;
}

/* Verbesserte Navbar-Kontraste */
.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.95) !important;
}

.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link:focus {
    color: #ffffff !important;
}

/* Verbesserte Button-Kontraste */
.btn-primary {
    background-color: #1976d2;
    border-color: #1976d2;
}

.btn-primary:hover {
    background-color: #1565c0;
    border-color: #1565c0;
}

.btn-outline-primary {
    color: #1976d2;
    border-color: #1976d2;
}

.btn-outline-primary:hover {
    background-color: #1976d2;
    border-color: #1976d2;
}

/* Screenreader-only Text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Fokus-Trap für Dialoge */
.modal:focus-within {
    outline: none;
}

.modal-content:focus {
    outline: 3px solid #1976d2;
    outline-offset: 2px;
}

/* Verbesserte Lesbarkeit bei 200% Zoom */
@media (min-width: 1200px) {
    .container,
    .container-lg,
    .container-md,
    .container-sm,
    .container-xl {
        max-width: 100%;
        padding: 0 15px;
    }
}

/* Touch-Target-Größen (mindestens 44px) - WCAG 2.1 AA konform */
.btn,
.nav-link,
a,
button,
input[type="button"],
input[type="submit"],
input[type="checkbox"],
input[type="radio"],
.dropdown-item,
.form-check-label {
    min-height: 44px;
    min-width: 44px;
}

/* Mobile-spezifische Touch-Target Optimierungen */
@media (max-width: 768px) {
    /* Erweiterte Touch-Targets für Mobile */
    .btn {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 0.6rem 1rem !important;
        font-size: 1rem !important;
    }
    
    /* Navigation Links */
    .nav-link,
    .dropdown-item {
        min-height: 48px !important;
        padding: 0.7rem 1rem !important;
        line-height: 1.4 !important;
    }
    
    /* AUSNAHME: KAI-Avatar in Navigation-Links soll klein bleiben */
    .nav-link img[src*="kai-avatar-custom.jpeg"] {
        width: 20px !important;
        height: 20px !important;
        max-width: 20px !important;
        max-height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
        object-fit: cover !important;
        border-radius: 50% !important;
    }
    
    /* Form Elemente */
    .form-control,
    .form-select {
        min-height: 48px !important;
        padding: 0.6rem 0.75rem !important;
        font-size: 1rem !important;
    }
    
    /* Checkboxen und Radio Buttons größer */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px !important;
        height: 24px !important;
        margin: 12px 8px 12px 0 !important;
    }
    
    /* Labels für Checkboxen und Radio Buttons */
    .form-check-label {
        min-height: 48px !important;
        display: flex !important;
        align-items: center !important;
        padding: 0.6rem 0.25rem !important;
        cursor: pointer !important;
        line-height: 1.4 !important;
    }
    
    /* Card Links und Buttons */
    .card .btn,
    .card a:not(.btn) {
        min-height: 48px !important;
        padding: 0.6rem 1rem !important;
    }
    
    /* Cookie Modal Buttons */
    #simple-cookie-modal button {
        min-height: 48px !important;
        min-width: 120px !important;
        padding: 0.6rem 1.2rem !important;
    }
    
    /* Alert Close Buttons */
    .alert .btn-close {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 0.6rem !important;
        opacity: 0.8 !important;
    }
    
    /* Footer Links */
    footer a,
    footer .btn-link {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 0.6rem 0.5rem !important;
        line-height: 1.4 !important;
    }
}

/* Spezielle Regeln für kleine Icons */
.nav-link i {
    font-size: 16px;
    vertical-align: middle;
}

/* Verbesserte Formular-Labels */
label {
    font-weight: 600;
    color: #333333;
    margin-bottom: 0.5rem;
}

/* Pflichtfeld-Kennzeichnung */
.required::after {
    content: " *";
    color: #c62828;
    font-weight: bold;
}

/* Fehlermeldungen für Formulare */
.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #c62828;
}

/* ARIA-Live-Regionen */
.aria-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Hochkontrast-Modus Unterstützung */
@media (prefers-contrast: high) {
    * {
        outline-width: 3px !important;
    }
    
    .btn {
        border-width: 2px !important;
    }
    
    a {
        text-decoration: underline;
    }
}

/* Reduzierte Animation für Nutzer mit vestibulären Störungen */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Unterstützung für bessere Zugänglichkeit */
@media (prefers-color-scheme: dark) {
    /* Wird implementiert wenn Dark Mode gewünscht */
}

/* Verbesserte Tabellen-Zugänglichkeit */
table {
    border-collapse: collapse;
}

th, td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: #333333;
}

/* Verbesserte Listen-Zugänglichkeit */
ul, ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

li {
    margin-bottom: 0.5rem;
}

/* ===================================
   ADVANCED ACCESSIBILITY FEATURES 2.0
   ===================================*/

/* Enhanced Focus für alle Elemente - überschreibt Standard */
*:focus-visible {
    outline: 3px solid #0066cc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 4px #0066cc !important;
}

/* Skip Links Container */
.skip-links {
    position: absolute;
    top: -40px;
    left: 6px;
    z-index: 1055;
}

.skip-link {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background: #000 !important;
    color: #fff !important;
    padding: 8px 16px !important;
    text-decoration: none !important;
    border-radius: 4px !important;
    font-weight: bold !important;
    font-size: 14px !important;
    transition: all 0.3s ease !important;
}

.skip-link:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    left: auto !important;
    clip: auto !important;
    outline: 3px solid #ffd700 !important;
    outline-offset: 2px !important;
}

/* Enhanced Screen Reader Support */
.sr-only-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: .25rem !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* Advanced Card Focus */
.card:focus,
.meal-card:focus,
.achievement-card:focus {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), 0 0 0 3px #0066cc !important;
    outline: none !important;
    transition: all 0.2s ease !important;
}

/* Interactive List Focus */
.list-group-item:focus,
.dropdown-item:focus {
    background-color: #0066cc !important;
    color: #ffffff !important;
    outline: 2px solid #ffd700 !important;
    outline-offset: -2px !important;
}

/* Modal Accessibility Enhancement */
.modal-dialog {
    outline: 2px solid #0066cc !important;
    outline-offset: 2px !important;
}

.modal.show .modal-dialog {
    animation: modalFadeIn 0.3s ease-out !important;
}

@keyframes modalFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(-30px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor !important;
    }
    
    .card {
        border: 2px solid #000 !important;
    }
    
    .form-control {
        border: 2px solid #000 !important;
    }
}

/* Enhanced Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .modal.show .modal-dialog {
        animation: none !important;
    }
    
    .card:focus {
        transform: none !important;
    }
}

/* Dark Mode Accessibility */
@media (prefers-color-scheme: dark) {
    .skip-link {
        background: #ffffff !important;
        color: #000000 !important;
    }
    
    *:focus-visible {
        outline-color: #66b3ff !important;
        box-shadow: 0 0 0 1px #000000, 0 0 0 4px #66b3ff !important;
    }
}

/* Error State Focus */
.is-invalid:focus,
input.error:focus {
    outline-color: #dc3545 !important;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 4px #dc3545 !important;
}

/* Success State Focus */
.is-valid:focus,
input.success:focus {
    outline-color: #28a745 !important;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 4px #28a745 !important;
}

/* Toast Accessibility */
.toast {
    border: 2px solid transparent !important;
}

.toast.show {
    animation: toastSlideIn 0.3s ease-out !important;
}

@keyframes toastSlideIn {
    0% {
        opacity: 0;
        transform: translateX(100%);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Loading Spinner Focus */
.spinner-border:focus,
.spinner-grow:focus {
    outline: 2px solid #0066cc !important;
    outline-offset: 2px !important;
}