/**
 * TaleTamer Accessibility Styles
 * WCAG 2.1 AA Compliance
 */

/* 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,
.sr-only-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0.5rem 1rem !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    background: #000 !important;
    color: #fff !important;
    text-decoration: none !important;
    z-index: 9999 !important;
}

/* Skip to Main Content Link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    z-index: 1000;
    font-weight: 600;
    transition: top 0.3s ease;
}

.skip-to-main:focus {
    top: 0;
    color: #fff;
}

/* Enhanced Focus Styles */
*:focus {
    outline: 2px solid #0066cc !important;
    outline-offset: 2px !important;
}

/* High contrast focus for buttons */
.btn:focus,
button:focus {
    outline: 3px solid #0066cc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px #fff, 0 0 0 4px #0066cc !important;
}

/* Form focus enhancements */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: #0066cc !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25) !important;
    outline: 2px solid #0066cc !important;
    outline-offset: 1px !important;
}

/* Link focus */
a:focus {
    background-color: #fff3cd !important;
    outline: 2px solid #0066cc !important;
    outline-offset: 1px !important;
}

/* Navigation focus */
.nav-link:focus {
    background-color: rgba(0, 102, 204, 0.1) !important;
    outline: 2px solid #0066cc !important;
    outline-offset: 1px !important;
}

/* Modal focus management */
.modal {
    outline: none;
}

.modal-dialog {
    outline: none;
}

/* Ensure sufficient color contrast */
.text-muted {
    color: #6c757d !important; /* Meets 4.5:1 ratio */
}

/* Button contrast improvements */
.btn-outline-secondary {
    color: #495057 !important;
    border-color: #495057 !important;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background-color: #495057 !important;
    border-color: #495057 !important;
    color: #fff !important; /* Weißer Text auf dunklem Hintergrund */
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: #0066cc !important;
    border-color: #0066cc !important;
    color: #fff !important;
}

.btn-outline-success:hover,
.btn-outline-success:focus {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    color: #fff !important;
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #fff !important;
}

.btn-outline-warning:hover,
.btn-outline-warning:focus {
    background-color: #856404 !important; /* Dunkleres Gelb für besseren Kontrast */
    border-color: #856404 !important;
    color: #fff !important;
}

.btn-outline-info:hover,
.btn-outline-info:focus {
    background-color: #17a2b8 !important;
    border-color: #17a2b8 !important;
    color: #fff !important;
}

.btn-outline-light:hover,
.btn-outline-light:focus {
    background-color: #6c757d !important; /* Dunklerer Hintergrund statt hellgrau */
    border-color: #6c757d !important;
    color: #fff !important;
}

.btn-outline-dark:hover,
.btn-outline-dark:focus {
    background-color: #343a40 !important;
    border-color: #343a40 !important;
    color: #fff !important;
}

/* Standard Button Hover-Verbesserungen */
.btn-primary:hover,
.btn-primary:focus {
    background-color: #0056b3 !important; /* Dunkleres Blau */
    border-color: #004085 !important;
    color: #fff !important;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: #545b62 !important;
    border-color: #4e555b !important;
    color: #fff !important;
}

.btn-success:hover,
.btn-success:focus {
    background-color: #218838 !important;
    border-color: #1e7e34 !important;
    color: #fff !important;
}

.btn-danger:hover,
.btn-danger:focus {
    background-color: #c82333 !important;
    border-color: #bd2130 !important;
    color: #fff !important;
}

.btn-warning:hover,
.btn-warning:focus {
    background-color: #e0a800 !important;
    border-color: #d39e00 !important;
    color: #000 !important; /* Schwarzer Text auf gelbem Hintergrund */
}

.btn-info:hover,
.btn-info:focus {
    background-color: #138496 !important;
    border-color: #117a8b !important;
    color: #fff !important;
}

.btn-light:hover,
.btn-light:focus {
    background-color: #e2e6ea !important;
    border-color: #dae0e5 !important;
    color: #000 !important; /* Schwarzer Text auf hellem Hintergrund */
}

.btn-dark:hover,
.btn-dark:focus {
    background-color: #23272b !important;
    border-color: #1d2124 !important;
    color: #fff !important;
}

/* Error states with better contrast */
.is-invalid {
    border-color: #dc3545 !important;
}

.invalid-feedback {
    color: #dc3545 !important;
    font-weight: 600 !important;
}

/* Success states */
.is-valid {
    border-color: #28a745 !important;
}

.valid-feedback {
    color: #28a745 !important;
    font-weight: 600 !important;
}

/* Loading states */
[aria-busy="true"] {
    cursor: wait !important;
    opacity: 0.7 !important;
    pointer-events: none !important;
}

[aria-busy="true"]::after {
    content: " (Lädt...)";
    font-size: 0.875rem;
    color: #6c757d;
}

/* Required field indicators */
.form-label .text-danger {
    font-weight: bold;
}

/* Better spacing for touch targets */
.btn {
    min-height: 44px !important; /* WCAG minimum touch target */
    min-width: 44px !important;
}

.form-control,
.form-select {
    min-height: 44px !important;
}

/* Improve table accessibility */
.table th {
    font-weight: 600 !important;
    border-bottom: 2px solid #dee2e6 !important;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.03) !important;
}

/* Alert improvements */
.alert {
    border-left: 4px solid;
    padding-left: 1rem !important;
}

.alert-danger {
    border-left-color: #dc3545 !important;
}

.alert-success {
    border-left-color: #28a745 !important;
}

.alert-warning {
    border-left-color: #ffc107 !important;
}

.alert-info {
    border-left-color: #17a2b8 !important;
}

/* Dropdown improvements */
.dropdown-menu {
    border: 2px solid #dee2e6 !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.dropdown-item:focus,
.dropdown-item:hover {
    background-color: #0066cc !important;
    color: #fff !important;
}

/* Card improvements */
.card {
    border: 1px solid #dee2e6 !important;
}

.card-header {
    border-bottom: 2px solid #dee2e6 !important;
    font-weight: 600 !important;
}

/* Progress bar accessibility */
.progress {
    background-color: #e9ecef !important;
    border: 1px solid #dee2e6 !important;
}

.progress-bar {
    transition: width 0.6s ease !important;
}

/* Tooltip improvements */
.tooltip {
    font-size: 0.875rem !important;
    z-index: 1070 !important;
}

.tooltip-inner {
    background-color: #000 !important;
    color: #fff !important;
    border: 1px solid #000 !important;
    padding: 0.5rem 0.75rem !important;
}

/* Badge improvements */
.badge {
    font-weight: 600 !important;
    padding: 0.375em 0.75em !important;
}

/* Pagination improvements */
.page-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25) !important;
    outline: 2px solid #0066cc !important;
    outline-offset: 1px !important;
}

/* Custom checkbox/radio improvements */
.form-check-input:focus {
    border-color: #0066cc !important;
    box-shadow: 0 0 0 0.25rem rgba(0, 102, 204, 0.25) !important;
    outline: 2px solid #0066cc !important;
    outline-offset: 1px !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-color: #000 !important;
    }
    
    .btn-primary {
        background-color: #000 !important;
        border-color: #000 !important;
        color: #fff !important;
    }
    
    .btn-outline-primary {
        color: #000 !important;
        border-color: #000 !important;
    }
}

/* 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;
    }
}

/* Dark mode support (if implemented) */
@media (prefers-color-scheme: dark) {
    :root {
        --bs-body-bg: #1a1a1a;
        --bs-body-color: #e9ecef;
    }
    
    .skip-to-main {
        background: #fff;
        color: #000;
    }
    
    .skip-to-main:focus {
        color: #000;
    }
}
