/* Accessibility Styles for School Bench Pro */

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 1rem;
    background-color: #2563eb;
    color: white;
    text-decoration: none;
    border-radius: 0 0 0.5rem 0;
}

.skip-to-main:focus {
    left: 0;
    top: 0;
}

/* Focus Indicators */
*:focus {
    outline: none;
}

/* Custom focus styles for better visibility */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus,
[tabindex]:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Dark mode focus styles */
.dark a:focus,
.dark button:focus,
.dark input:focus,
.dark textarea:focus,
.dark select:focus,
.dark [tabindex]:focus {
    outline-color: #60a5fa;
}

/* Focus visible only for keyboard navigation */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

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

/* Make sr-only focusable when focused */
.sr-only-focusable:focus {
    position: absolute;
    width: auto;
    height: auto;
    padding: 0.5rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background-color: #1f2937;
    color: white;
    z-index: 9999;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    * {
        border-color: transparent !important;
    }
    
    a, button {
        text-decoration: underline !important;
    }
    
    .glass-effect {
        background: rgba(255, 255, 255, 0.95) !important;
        border: 2px solid #000 !important;
    }
    
    .dark .glass-effect {
        background: rgba(0, 0, 0, 0.95) !important;
        border: 2px solid #fff !important;
    }
}

/* 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;
    }
    
    .animate-fadeInUp,
    .animate-fadeInDown,
    .animate-scaleIn,
    .reveal {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Button States for Better Accessibility */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Ensure interactive elements are large enough */
button,
a,
input[type="checkbox"],
input[type="radio"],
select {
    min-height: 44px;
    min-width: 44px;
}

/* Error States */
.error,
[aria-invalid="true"] {
    border-color: #dc2626 !important;
}

.error-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Success States */
.success,
[aria-invalid="false"] {
    border-color: #10b981 !important;
}

.success-message {
    color: #10b981;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Loading States */
[aria-busy="true"] {
    cursor: wait;
}

.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

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

/* Keyboard Navigation Indicators */
.keyboard-navigating *:focus {
    outline: 3px solid #3b82f6 !important;
    outline-offset: 2px !important;
}

/* ARIA Live Regions */
[role="status"],
[role="alert"],
[aria-live] {
    position: relative;
}

/* Tooltip Accessibility */
[role="tooltip"] {
    position: absolute;
    z-index: 9999;
    pointer-events: none;
}

/* Form Labels */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    cursor: pointer;
}

label.required::after {
    content: " *";
    color: #dc2626;
}

/* Table Accessibility */
table {
    border-collapse: collapse;
    width: 100%;
}

table caption {
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
}

/* Ensure proper color contrast */
.text-low-contrast {
    color: #6b7280;
}

.dark .text-low-contrast {
    color: #9ca3af;
}

/* Icon-only buttons need labels */
.icon-button {
    position: relative;
}

.icon-button .tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-0.5rem);
    background: #1f2937;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.icon-button:hover .tooltip,
.icon-button:focus .tooltip {
    opacity: 1;
}

/* Language selector accessibility */
[role="menu"] {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.dark [role="menu"] {
    background: #1f2937;
    border-color: #374151;
}

[role="menuitem"] {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

[role="menuitem"]:hover,
[role="menuitem"]:focus {
    background-color: #f3f4f6;
}

.dark [role="menuitem"]:hover,
.dark [role="menuitem"]:focus {
    background-color: #374151;
}

/* Progress indicators */
[role="progressbar"] {
    position: relative;
    background-color: #e5e7eb;
    border-radius: 0.25rem;
    overflow: hidden;
}

[role="progressbar"]::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: #3b82f6;
    transition: width 0.3s;
}

/* Ensure sufficient contrast for placeholder text */
::placeholder {
    color: #6b7280;
    opacity: 1;
}

.dark ::placeholder {
    color: #9ca3af;
}

/* Make focus order logical with tabindex */
[tabindex="-1"]:focus {
    outline: none;
}

/* Announcement for screen readers */
.announcement {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Print styles for better accessibility */
@media print {
    .no-print,
    nav,
    footer {
        display: none !important;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
    }
    
    abbr[title]::after {
        content: " (" attr(title) ")";
    }
}