/*
 * ACCESSIBILITY CONSOLIDATED - ALL ACCESSIBILITY STYLES
 * ====================================================
 * This consolidates all accessibility improvements into one file.
 * DO NOT CREATE accessibility-*-enhanced.css or accessibility-*-fix.css files!
 *
 * 📋 CONTAINS:
 * - High contrast and color fixes (WCAG 2.1 AA/AAA)
 * - Keyboard focus indicators (:focus-visible)
 * - Skip navigation links for screen readers
 * - Form accessibility (aria-required, error states)
 * - RTL language support and touch target sizes
 * - High contrast mode and reduced motion preferences
 *
 * 🎯 PERFORMANCE: Loads FIRST - critical for assistive technology
 * 📏 SIZE: ~201 lines | GZIPPED: ~4KB | CRITICAL: Yes (WCAG compliance)
 */

/* ===== HIGH CONTRAST & COLOR FIXES ===== */

/* Universal high contrast fixes - MIGRATED from accessibility-contrast-enhanced.css */
:root {
    --high-contrast-dark: #000000;
    --high-contrast-light: #ffffff;
    --readable-dark: #212529;
    --readable-light: #f8f9fa;
    --accessible-blue: #0d6efd;
    --wcag-aa-contrast: #374151; /* 4.5:1 ratio */
    --wcag-aaa-contrast: #1f2937; /* 7:1 ratio */
}

/* Fix dark text on dark backgrounds */
.bg-dark,
.bg-secondary,
.bg-primary,
.navbar-dark,
.card-dark,
[class*="bg-dark"],
[style*="background-color: #000"],
[style*="background-color: #111"],
[style*="background-color: #222"],
[style*="background-color: #333"] {
    color: var(--high-contrast-light) !important;
}

.bg-dark *:not(.btn):not(.badge),
.bg-secondary *:not(.btn):not(.badge),
.bg-primary *:not(.btn):not(.badge) {
    color: var(--high-contrast-light) !important;
}

/* Fix light text on light backgrounds */
.bg-light,
.bg-white,
.navbar-light,
.card-light,
[class*="bg-light"],
[style*="background-color: #fff"],
[style*="background-color: #eee"],
[style*="background-color: #ddd"],
[style*="background-color: #ccc"] {
    color: var(--readable-dark) !important;
}

.bg-light *:not(.btn):not(.badge),
.bg-white *:not(.btn):not(.badge) {
    color: var(--readable-dark) !important;
}

/* ===== KEYBOARD FOCUS INDICATORS ===== */

/* Enhanced focus visibility - overrides outline suppression */
*:focus-visible {
    outline: 3px solid var(--accessible-blue) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

/* Focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--accessible-blue) !important;
    outline-offset: 2px !important;
}

/* Custom focus for buttons */
.btn:focus-visible {
    outline: 3px solid var(--accessible-blue) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

/* ===== SKIP NAVIGATION ===== */

.skip-links {
    position: absolute;
    top: -100px;
    left: 0;
    z-index: 9999;
    width: 100%;
}

.skip-navigation {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    font-weight: 600;
    transition: top 0.3s ease;
    top: -100px;
}

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

/* ===== FORM ACCESSIBILITY ===== */

/* Required field indicators */
[aria-required="true"]::after,
.required::after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

/* Error states */
.form-control:invalid,
.form-control[aria-invalid="true"] {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

/* Error messages */
.error-message,
[role="alert"] {
    color: #dc3545;
    font-weight: 600;
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

/* Screen reader only text */
.sr-only,
.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;
}

/* ===== RTL SUPPORT ===== */

/* Right-to-left language support */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .navbar-nav {
    margin-left: auto;
    margin-right: 0;
}

[dir="rtl"] .dropdown-menu {
    right: 0;
    left: auto;
}

[dir="rtl"] .btn {
    text-align: center; /* Ensure buttons remain centered in RTL */
}

/* ===== TOUCH TARGET SIZES ===== */

/* Ensure minimum 44x44px touch targets (WCAG 2.5.5) */
.btn,
.nav-link,
.dropdown-toggle,
[role="button"],
input[type="button"],
input[type="submit"],
button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 1rem;
}

/* ===== HIGH CONTRAST MODE ===== */

@media (prefers-contrast: high) {
    :root {
        --bs-primary: #000000;
        --bs-secondary: #6c757d;
        --bs-body-color: #000000;
        --bs-body-bg: #ffffff;
    }
    
    .btn-primary {
        background-color: #000000 !important;
        border-color: #000000 !important;
        color: #ffffff !important;
    }
    
    .btn-secondary {
        background-color: #ffffff !important;
        border-color: #000000 !important;
        color: #000000 !important;
    }
}

/* ===== MOTION PREFERENCES ===== */

@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;
    }
}