/* ============================================
   ACCESSIBILITY ENHANCEMENTS - WCAG 2.1 AA
   ============================================ */

/* Skip Navigation Link */
.skip-to-content {
    position: absolute;
    left: -9999px;
    top: 20px;
    z-index: 999999;
    padding: 12px 24px;
    background: #111827;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.skip-to-content:focus {
    left: 20px;
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Focus Indicators - High Contrast */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus,
[tabindex]:focus {
    outline: 3px solid #667eea !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2) !important;
}

/* Focus visible for keyboard navigation only */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
    outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid #667eea !important;
    outline-offset: 2px !important;
}

/* Enhanced Button Focus */
.theme-btn:focus,
.btn:focus,
button:focus {
    outline: 3px solid #667eea !important;
    outline-offset: 3px !important;
    transform: translateY(-2px);
}

/* Link Focus States */
a:focus {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

/* Form Field Focus */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15) !important;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    body {
        background: #000000;
        color: #ffffff;
    }
    
    a {
        text-decoration: underline;
        color: #00ffff;
    }
    
    button, .theme-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;
    }
    
    .slick-slider .slick-slide {
        transition: none !important;
    }
    
    .wow {
        visibility: visible !important;
        animation: none !important;
    }
}

/* Screen Reader Only Content */
.sr-only,
.visually-hidden {
    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:active,
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Keyboard Navigation Indicator */
body.user-is-tabbing *:focus {
    outline: 3px solid #667eea !important;
    outline-offset: 2px !important;
}

/* Touch Target Size - Minimum 44x44px */
button,
a,
input[type="submit"],
input[type="button"],
input[type="checkbox"],
input[type="radio"],
.clickable {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Exception for inline text links */
p a,
li a,
span a {
    min-width: auto;
    min-height: auto;
    display: inline;
}

/* Ensure sufficient color contrast */
body {
    color: #111827; /* WCAG AAA on white */
}

p, li, span, div {
    color: #374151; /* WCAG AA on white */
}

.text-muted {
    color: #6b7280 !important; /* WCAG AA on white */
}

/* Link Contrast */
a {
    color: #2563eb; /* WCAG AA contrast ratio 4.5:1 */
}

a:hover {
    color: #1e40af;
}

/* Form Labels */
label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    color: #111827;
}

/* Required Field Indicator */
.required::after {
    content: " *";
    color: #dc2626;
    font-weight: bold;
}

/* Error Messages */
.error-message,
.form-error {
    color: #dc2626;
    font-size: 14px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.error-message::before,
.form-error::before {
    content: "⚠";
    font-size: 16px;
}

/* Success Messages */
.success-message {
    color: #059669;
    font-size: 14px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.success-message::before {
    content: "✓";
    font-size: 16px;
    font-weight: bold;
}

/* Landmark Regions */
main {
    min-height: 50vh;
}

header[role="banner"],
nav[role="navigation"],
main[role="main"],
footer[role="contentinfo"] {
    position: relative;
}

/* Tables Accessibility */
table {
    border-collapse: collapse;
    width: 100%;
}

th {
    text-align: left;
    font-weight: 700;
    background: #f9fafb;
    padding: 12px;
    border: 1px solid #e5e7eb;
}

td {
    padding: 12px;
    border: 1px solid #e5e7eb;
}

/* Caption for tables */
caption {
    font-weight: 700;
    text-align: left;
    padding: 12px;
    caption-side: top;
}

/* Image Alt Text Reminder */
img:not([alt]) {
    outline: 3px solid #dc2626;
}

/* Focus Trap for Modals */
.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
}

/* Tooltip Accessibility */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: #111827;
    color: #ffffff;
    font-size: 14px;
    white-space: nowrap;
    border-radius: 6px;
    margin-bottom: 8px;
    z-index: 10000;
}

/* Print Styles */
@media print {
    .no-print,
    header,
    footer,
    nav,
    .cookie-banner,
    .chat-widget {
        display: none !important;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
    }
}

/* Language Selector */
[lang]:not([lang="en"]) {
    font-style: italic;
}

/* Text Resize Support */
html {
    font-size: 16px;
}

@media (min-width: 1920px) {
    html {
        font-size: 18px;
    }
}

/* Ensure text can resize to 200% */
body {
    font-size: 1rem;
    line-height: 1.6;
}

/* Contrast Checker for Disabled Elements */
button:disabled,
input:disabled,
select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f3f4f6;
    color: #6b7280;
}

/* Animated Content Warnings */
.flashing-content {
    animation: none !important; /* Prevent seizure triggers */
}

/* Audio/Video Controls */
video,
audio {
    width: 100%;
    max-width: 100%;
}

video:focus,
audio:focus {
    outline: 3px solid #667eea;
    outline-offset: 3px;
}

/* Custom Checkbox/Radio Accessibility */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    cursor: pointer;
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Breadcrumb Navigation */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 12px 0;
    margin-bottom: 24px;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 8px;
    color: #9ca3af;
}

/* Status Messages */
[role="status"],
[role="alert"] {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 16px 0;
}

[role="alert"] {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    color: #991b1b;
}

[role="status"] {
    background: #f0f9ff;
    border-left: 4px solid #3b82f6;
    color: #1e40af;
}

/* Mobile Accessibility */
@media (max-width: 768px) {
    /* Larger touch targets on mobile */
    button,
    a.theme-btn,
    .mobile-nav a {
        min-height: 48px;
        padding: 12px 20px;
    }
    
    /* Ensure text is readable */
    body {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
    
    input,
    textarea,
    select {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background: #111827;
        color: #f9fafb;
    }
    
    a {
        color: #60a5fa;
    }
    
    .theme-btn {
        background: #1f2937;
        color: #f9fafb;
        border: 1px solid #374151;
    }
}
