/* Enhanced Accessibility Styles */

/* ARIA Live Regions */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Enhanced Focus Indicators */
*:focus {
    outline: 3px solid var(--secondary, #f59e0b);
    outline-offset: 3px;
    transition: outline-offset 0.2s ease;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--secondary, #f59e0b);
    outline-offset: 3px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }

    a {
        text-decoration: underline;
    }
}

/* 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;
    }
}

/* Keyboard Navigation Indicators */
.keyboard-nav *:focus {
    outline: 3px solid var(--secondary, #f59e0b);
    outline-offset: 3px;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

/* ARIA States */
[aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

[aria-hidden="true"] {
    display: none !important;
}

[aria-expanded="false"]+.dropdown,
[aria-expanded="false"]+.submenu {
    display: none;
}

[aria-expanded="true"]+.dropdown,
[aria-expanded="true"]+.submenu {
    display: block;
}

/* Loading State */
[aria-busy="true"] {
    position: relative;
    pointer-events: none;
}

[aria-busy="true"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    border-top-color: var(--white, #fff);
    animation: spin 1s ease-in-out infinite;
}

/* Error States */
[aria-invalid="true"] {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05);
}

.error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Success States */
[aria-invalid="false"] {
    border-color: #10b981 !important;
}

/* Skip Links Enhancement */
.skip-link:focus {
    top: 0;
    z-index: 10000;
    padding: 1rem 2rem;
    background: var(--primary, #004BA0);
    color: white;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Landmark Regions */
[role="navigation"],
[role="main"],
[role="complementary"],
[role="contentinfo"] {
    position: relative;
}

/* Table Accessibility */
table {
    border-collapse: collapse;
}

th {
    text-align: left;
}

th[scope="col"] {
    border-bottom: 2px solid currentColor;
}

th[scope="row"] {
    font-weight: 600;
}

/* Form Accessibility */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[required]+label::after,
select[required]+label::after {
    content: ' *';
    color: #ef4444;
}

/* Button States */
button:disabled,
button[aria-disabled="true"] {
    opacity: 0.6;
    cursor: not-allowed;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

/* Link Accessibility */
a:not([class]) {
    text-decoration: underline;
    text-decoration-skip-ink: auto;
}

a:hover {
    text-decoration-thickness: 2px;
}

/* Image Accessibility */
img:not([alt]) {
    outline: 3px solid #ef4444;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #f3f4f6;
        --bg-color: #111827;
    }
}

/* Print Accessibility */
@media print {

    .skip-link,
    .hamburger,
    [aria-hidden="true"] {
        display: none !important;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}