/* =============================================================================
   ACCESSIBILITY STYLES - WCAG 2.1 Level AA Compliance
   ============================================================================= */

/* Skip Links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    z-index: 1000;
    font-weight: bold;
    font-size: 14px;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    color: #fff;
    text-decoration: underline;
}

/* Focus Indicators */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus,
.btn:focus,
.nav-link:focus,
.navbar-brand:focus,
.navbar-toggler:focus,
[tabindex]:focus {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 2px #fff, 0 0 0 5px #005fcc !important;
}

/* High contrast focus for dark backgrounds */
.navbar-dark .nav-link:focus,
.navbar-dark .navbar-brand:focus,
.bg-dark *:focus {
    outline: 3px solid #ffd700 !important;
    box-shadow: 0 0 0 2px #000, 0 0 0 5px #ffd700 !important;
}

/* Remove outline for mouse users, keep for keyboard users */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

/* Touch Target Sizes (44x44px minimum) */
.btn,
.nav-link,
.navbar-toggler,
button,
input[type="submit"],
input[type="button"],
input[type="reset"],
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Ensure sufficient spacing between interactive elements */
.nav-item + .nav-item {
    margin-left: 8px;
}

/* Text and Background Contrast Improvements */
.text-white {
    color: #ffffff !important;
}

.text-dark {
    color: #212529 !important;
}

/* Ensure link contrast in footer */
.footer .footer-link {
    color: #e9ecef !important;
    text-decoration: underline;
}

.footer .footer-link:hover,
.footer .footer-link:focus {
    color: #ffd700 !important;
    text-decoration: underline;
}

/* Enhanced button contrast */
.btn-primary {
    background-color: #0056b3 !important;
    border-color: #0056b3 !important;
    color: #ffffff !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #004085 !important;
    border-color: #004085 !important;
    color: #ffffff !important;
}

/* Screen Reader Only Content */
.sr-only {
    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;
}

.sr-only-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* Enhanced Visual Indicators */
.required::after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

.error {
    border: 2px solid #dc3545 !important;
    background-color: #f8d7da !important;
}

.success {
    border: 2px solid #28a745 !important;
    background-color: #d4edda !important;
}

/* Form Enhancement */
label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-control {
    border: 2px solid #ced4da;
    border-radius: 4px;
    font-size: 16px; /* Prevents zoom on iOS */
    line-height: 1.5;
    padding: 0.75rem;
}

.form-control:focus {
    border-color: #005fcc;
    box-shadow: 0 0 0 0.2rem rgba(0, 95, 204, 0.25);
}

/* Improved List Styling */
ul, ol {
    padding-left: 2rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Table Accessibility */
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border: 1px solid #dee2e6;
    padding: 0.75rem;
    text-align: left;
}

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

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .nav-link {
        text-decoration: underline;
    }

    .card {
        border: 2px solid currentColor;
    }
}

/* Responsive Typography */
@media (max-width: 768px) {
    body {
        font-size: 18px;
        line-height: 1.6;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 0.75rem 1rem;
        font-size: 16px;
    }
}

/* Print Styles */
@media print {
    .skip-link,
    .navbar,
    .cookie-consent,
    .footer {
        display: none !important;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }

    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }
}

/* Language Direction Support */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .nav-item + .nav-item {
    margin-left: 0;
    margin-right: 8px;
}

/* Cookie Consent Accessibility */
.cookie-consent .btn {
    min-height: 44px;
    margin: 0.25rem;
}

.cookie-consent-modal {
    max-height: 90vh;
    overflow-y: auto;
}

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

/* Enhanced Navigation Indicators */
/* Removed bullet point before active navigation items as per user request */

/* Improved Modal Accessibility */
.modal {
    display: none;
}

.modal.show {
    display: block;
}

.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.75);
}

/* Loading State Indicators */
.loading {
    position: relative;
}

.loading::after {
    content: "Lädt...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
}

/* Error Message Styling */
.error-message {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 0.75rem 1rem;
    border-radius: 0.25rem;
    margin-top: 0.5rem;
}

/* Success Message Styling */
.success-message {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 0.75rem 1rem;
    border-radius: 0.25rem;
    margin-top: 0.5rem;
}

/* Focus Management for Dynamic Content */
.focus-trap {
    position: relative;
}

.focus-trap::before,
.focus-trap::after {
    content: "";
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* Improved Text Selection */
::selection {
    background-color: #005fcc;
    color: #ffffff;
}

::-moz-selection {
    background-color: #005fcc;
    color: #ffffff;
}