/* ==========================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================== */

/* Focus Indicators */
*:focus {
    outline: 2px solid var(--primary-color, #4361ee);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--primary-color, #4361ee);
    outline-offset: 2px;
}

/* Skip Links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color, #4361ee);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
}

.skip-link:focus {
    top: 0;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* 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;
    }
}

/* Screen Reader Only */
.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;
}

.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Touch Target Sizes */
button,
a,
input,
select,
textarea,
[role="button"] {
    min-height: 44px;
    min-width: 44px;
}

/* Improved Link Contrast */
a {
    text-decoration: underline;
}

a:hover,
a:focus {
    text-decoration-thickness: 2px;
}

/* Form Labels */
label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: block;
}

label.required::after {
    content: " *";
    color: var(--danger-color, #e63946);
}

/* Form Errors */
.form-error {
    color: var(--danger-color, #e63946);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.form-control.is-invalid {
    border-color: var(--danger-color, #e63946);
}

.form-control.is-invalid:focus {
    border-color: var(--danger-color, #e63946);
    box-shadow: 0 0 0 0.2rem rgba(230, 57, 70, 0.25);
}

/* ARIA Live Regions */
[aria-live] {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Keyboard Navigation */
.keyboard-nav:focus {
    outline: 2px solid var(--primary-color, #4361ee);
    outline-offset: 2px;
}

/* Modal Accessibility */
.modal {
    outline: none;
}

.modal:focus {
    outline: none;
}

.modal-backdrop {
    opacity: 0.5;
}

/* Loading States for Screen Readers */
[aria-busy="true"] {
    position: relative;
}

[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

[aria-busy="true"]::before {
    content: "Loading...";
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Better Button Accessibility */
button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Image Alt Text Support */
img {
    max-width: 100%;
    height: auto;
}

img[alt=""] {
    border: 2px dashed #ccc;
}

/* Color Contrast Improvements */
.text-muted {
    color: #6b7280 !important; /* WCAG AA compliant */
}

/* Responsive Touch Targets */
@media (max-width: 768px) {
    button,
    a,
    input,
    select,
    textarea,
    [role="button"] {
        min-height: 48px;
        min-width: 48px;
    }
    
    .btn {
        padding: 0.75rem 1.5rem;
    }
}

/* Focus Trap for Modals */
.modal[aria-hidden="false"] {
    /* Focus trap will be handled by JavaScript */
}

/* Landmark Regions */
main {
    outline: none;
}

main:focus {
    outline: none;
}

/* Headings Hierarchy */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

/* Table Accessibility */
table {
    border-collapse: collapse;
}

th {
    font-weight: 600;
    text-align: left;
}

/* List Accessibility */
ul, ol {
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Error States */
.error-message {
    color: var(--danger-color, #e63946);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-message::before {
    content: "⚠";
    font-size: 1rem;
}

/* Success States */
.success-message {
    color: var(--success-color, #2ec4b6);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.success-message::before {
    content: "✓";
    font-size: 1rem;
}

