/* TEKlaB - Accessibility Enhancements
 * WCAG 2.1 AA Compliance Improvements
 */

/* ========================================
   1. SKIP LINKS
   ======================================== */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: #002678;
    color: #fff;
    padding: 12px 24px;
    z-index: 100000;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 8px 0;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #21cdad;
    outline-offset: 2px;
}

/* ========================================
   2. FOCUS STATES - Enhanced Visibility
   ======================================== */
*:focus {
    outline: 3px solid #21cdad;
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid #21cdad;
    outline-offset: 2px;
}

/* Specific focus states for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #21cdad;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(33, 205, 173, 0.2);
}

.btn:focus-visible {
    outline: 3px solid #002678;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(0, 38, 120, 0.2);
}

.nav-item-link:focus-visible {
    outline: 3px solid #21cdad;
    background: rgba(33, 205, 173, 0.1);
    border-radius: 4px;
}

/* ========================================
   3. SCREEN READER ONLY UTILITIES
   ======================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ========================================
   4. HIGH CONTRAST MODE SUPPORT
   ======================================== */
@media (prefers-contrast: high) {
    body {
        background: #fff;
        color: #000;
    }

    .btn-primary {
        background: #000;
        border-color: #000;
        color: #fff;
    }

    .btn-secondary {
        background: #000;
        border-color: #000;
        color: #fff;
    }

    a {
        color: #0000EE;
        text-decoration: underline;
    }

    .navbar {
        border-bottom: 2px solid #000;
    }

    .footer {
        border-top: 2px solid #000;
    }
}

/* ========================================
   5. REDUCED MOTION
   ======================================== */
@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;
    }

    .preloader {
        display: none !important;
    }

    .slick-carousel {
        animation: none !important;
    }

    .slick-slide {
        transition: none !important;
    }
}

/* ========================================
   6. TEXT SIZING & READABILITY
   ======================================== */
html {
    font-size: 100%; /* Respect user font size preferences */
}

body {
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* Minimum touch target size (44x44px) */
button,
a.btn,
.nav-item-link,
input[type="submit"],
input[type="button"],
.social-icons a {
    min-height: 44px;
    min-width: 44px;
}

/* Link underlines for better visibility */
.content-box a,
.heading-desc a,
p a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.content-box a:hover,
.heading-desc a:hover,
p a:hover {
    text-decoration-thickness: 2px;
}

/* ========================================
   7. FORM ACCESSIBILITY
   ======================================== */
label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

input,
select,
textarea {
    font-size: 16px; /* Prevents zoom on iOS */
}

input:invalid,
select:invalid,
textarea:invalid {
    border-color: #dc3545;
}

input:invalid:focus,
select:invalid:focus,
textarea:invalid:focus {
    outline-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

/* Required field indicator */
label[for] .required,
.required-indicator {
    color: #dc3545;
    margin-left: 4px;
}

/* Error messages */
.error-message,
.form-error {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
}

.error-message::before,
.form-error::before {
    content: "\f071";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 6px;
}

/* Success messages */
.success-message {
    color: #28a745;
    font-size: 0.875rem;
    margin-top: 4px;
}

/* ========================================
   8. TABLE ACCESSIBILITY
   ======================================== */
table {
    border-collapse: collapse;
    width: 100%;
}

th {
    text-align: left;
    background: #f8f9fa;
    font-weight: 600;
}

th, td {
    padding: 12px;
    border: 1px solid #dee2e6;
}

caption {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    text-align: left;
}

/* ========================================
   9. IMAGE ACCESSIBILITY
   ======================================== */
img {
    max-width: 100%;
    height: auto;
}

img:not([alt]) {
    outline: 3px dashed #dc3545;
}

/* ========================================
   10. NAVIGATION ACCESSIBILITY
   ======================================== */
nav[aria-label] {
    position: relative;
}

/* Breadcrumb accessibility */
.breadcrumb {
    padding: 10px 0;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 8px;
}

.breadcrumb-item.active {
    font-weight: 600;
}

/* ========================================
   11. MODAL/DIALOG ACCESSIBILITY
   ======================================== */
[role="dialog"] {
    position: fixed;
    z-index: 10000;
}

[role="dialog"][aria-hidden="true"] {
    display: none;
}

/* Focus trap indicator */
.focus-trap-active {
    overflow: hidden;
}

/* ========================================
   12. LOADING STATES
   ======================================== */
[aria-busy="true"] {
    cursor: wait;
}

.loading-indicator {
    display: inline-flex;
    align-items: center;
}

.loading-indicator::after {
    content: "";
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid #21cdad;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   13. COLOR CONTRAST FIXES
   ======================================== */
/* Ensure sufficient contrast ratios (4.5:1 for normal text, 3:1 for large text) */
.text-muted {
    color: #5a6268 !important; /* Darker than default for better contrast */
}

.color-primary {
    color: #1a9c84; /* Darker shade for better contrast */
}

.bg-gray .heading-title,
.bg-gray .heading-subtitle {
    color: #002678;
}

/* ========================================
   14. PRINT STYLES FOR ACCESSIBILITY
   ======================================== */
@media print {
    * {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a,
    a:visited {
        text-decoration: underline;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }

    a[href^="#"]::after,
    a[href^="javascript:"]::after {
        content: "";
    }

    abbr[title]::after {
        content: " (" attr(title) ")";
    }

    thead {
        display: table-header-group;
    }

    tr,
    img {
        page-break-inside: avoid;
    }

    p,
    h2,
    h3 {
        orphans: 3;
        widows: 3;
    }

    h2,
    h3 {
        page-break-after: avoid;
    }

    .no-print,
    .preloader,
    nav,
    .social-icons,
    #scrollTopBtn {
        display: none !important;
    }
}

/* ========================================
   15. DARK MODE SUPPORT
   ======================================== */
@media (prefers-color-scheme: dark) {
    /* Only apply if user hasn't explicitly chosen light mode */
    :root:not([data-theme="light"]) {
        /* Note: Full dark mode implementation would require more extensive changes */
        /* This is a placeholder for future dark mode support */
    }
}

/* ========================================
   16. LANGUAGE-SPECIFIC ACCESSIBILITY
   ======================================== */
/* RTL language support improvements */
[dir="rtl"] .skip-link {
    left: auto;
    right: 0;
    border-radius: 0 0 0 8px;
}

[dir="rtl"] .error-message::before,
[dir="rtl"] .form-error::before {
    margin-right: 0;
    margin-left: 6px;
}

/* ========================================
   17. COMPONENT-SPECIFIC ACCESSIBILITY
   ======================================== */
/* Accordion accessibility */
.accordion-button[aria-expanded="true"] {
    background: rgba(33, 205, 173, 0.1);
}

.accordion-button:focus {
    z-index: 3;
}

/* Tab accessibility */
[role="tablist"] {
    display: flex;
    gap: 4px;
}

[role="tab"] {
    cursor: pointer;
    padding: 12px 24px;
}

[role="tab"][aria-selected="true"] {
    background: #21cdad;
    color: #fff;
}

[role="tabpanel"][aria-hidden="true"] {
    display: none;
}

/* Carousel accessibility */
.slick-dots button {
    font-size: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
    border: none;
}

.slick-dots .slick-active button {
    background: #21cdad;
}

.slick-prev,
.slick-next {
    font-size: 0;
    width: 44px;
    height: 44px;
}

/* ========================================
   18. NOTIFICATION/ALERT ACCESSIBILITY
   ======================================== */
[role="alert"] {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

[role="alert"].alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

[role="alert"].alert-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

[role="alert"].alert-warning {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

[role="alert"].alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}
