/*!
 * Accessibility Styles for MOTA Tickets System
 * WCAG 2.1 Level AA Compliance
 */

/* Screen Reader Only - Hide visually but keep for screen readers */
.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;
}

/* Skip Link */
.a11y-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    font-size: 16px;
    z-index: 100000;
    border-radius: 0 0 4px 0;
}

.a11y-skip-link:focus {
    top: 0;
}

/* Accessibility Toolbar - BOTTOM LEFT ALWAYS */
#a11y-toolbar {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999999999; /* On top of EVERYTHING */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#a11y-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #6d66c8;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.35);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

#a11y-toggle:hover {
    background: #6d66c8;
    transform: scale(1) rotate(10deg);
    box-shadow: 0 12px 48px rgba(102, 126, 234, 0.7);
    border-color: rgba(255, 255, 255, 0.6);
    width: 60px;
    height: 60px;
    font-size: 28px;
}

#a11y-toggle:focus {
    outline: 4px solid #FFD700;
    outline-offset: 3px;
}

/* No tooltip - removed as per user request */

/* Accessibility Panel - BEAUTIFUL & STICKY AT BOTTOM LEFT */
#a11y-panel {
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 360px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.1);
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    z-index: 999999998;
}

#a11y-panel.a11y-hidden {
    display: none;
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    pointer-events: none;
}

/* Custom Scrollbar for Panel */
#a11y-panel::-webkit-scrollbar {
    width: 8px;
}

#a11y-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

#a11y-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

#a11y-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

#a11y-panel h2 {
    margin: 0 0 20px 0;
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding-bottom: 15px;
    border-bottom: 3px solid transparent;
    border-image: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-image-slice: 1;
}

#a11y-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(102, 126, 234, 0.1);
    border: none;
    font-size: 24px;
    color: #667eea;
    cursor: pointer;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-weight: bold;
}

#a11y-close:hover {
    background: rgba(102, 126, 234, 0.2);
    color: #764ba2;
    transform: rotate(90deg);
}

#a11y-close:focus {
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}

.a11y-section {
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.a11y-section h3 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.a11y-buttons {
    display: flex;
    gap: 10px;
}

.a11y-buttons button {
    flex: 1;
    padding: 12px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    background: linear-gradient(to bottom, #ffffff 0%, #f7fafc 100%);
    cursor: pointer;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.a11y-buttons button:hover {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.a11y-buttons button:focus {
    border-color: #FFD700;
    outline: 2px solid #FFD700;
    outline-offset: 2px;
}

.a11y-buttons button.a11y-large {
    font-size: 18px;
}

.a11y-buttons button.a11y-xlarge {
    font-size: 22px;
}

.a11y-section label {
    display: flex;
    align-items: center;
    margin: 10px 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.a11y-section label:hover {
    background: rgba(102, 126, 234, 0.05);
}

.a11y-section input[type="checkbox"] {
    margin-right: 12px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    accent-color: #667eea;
}

html[lang="ar"] .a11y-section input[type="checkbox"] {
    margin-right: 0;
    margin-left: 12px;
}

.a11y-reset-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.a11y-reset-btn:hover {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.4);
}

.a11y-reset-btn:focus {
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}

/* Font Size Adjustments - FIXED TO WORK PROPERLY */
html.a11y-font-normal,
html.a11y-font-normal body {
    font-size: 100% !important;
}

html.a11y-font-large,
html.a11y-font-large body {
    font-size: 120% !important;
}

html.a11y-font-xlarge,
html.a11y-font-xlarge body {
    font-size: 150% !important;
}

/* Apply font size to all text elements */
.a11y-font-large * {
    font-size: inherit !important;
}

.a11y-font-xlarge * {
    font-size: inherit !important;
}

/* Special case: Cart notification badge - keep visible when font increases */
html.a11y-font-large .links ul li .no,
body.a11y-font-large .links ul li .no {
    background-color: #F37B01 !important;
    width: 29px !important;
    height: 30px !important;
    line-height: 28px !important;
    color: #ffffff !important;
    font-size: 22px !important;
    font-weight: 600 !important;
    text-align: center !important;
    top: -23px !important;
    right: -20px !important;
    position: absolute !important;
    border-radius: 100% !important;
    -moz-border-radius: 100% !important;
    -webkit-border-radius: 100% !important;
}

html.a11y-font-xlarge .links ul li .no,
body.a11y-font-xlarge .links ul li .no {
    background-color: #F37B01 !important;
    width: 40px !important;
    height: 39px !important;
    line-height: 36px !important;
    color: #ffffff !important;
    font-size: 34px !important;
    font-weight: 600 !important;
    text-align: center !important;
    top: -23px !important;
    right: -20px !important;
    position: absolute !important;
    border-radius: 100% !important;
    -moz-border-radius: 100% !important;
    -webkit-border-radius: 100% !important;
}

/* High Contrast Mode - IMPROVED */
body.a11y-contrast-high {
    background: #ffffff !important;
    color: #000000 !important;
}

body.a11y-contrast-high * {
    border-color: #000000 !important;
}

body.a11y-contrast-high a {
    color: #0000EE !important;
    text-decoration: underline !important;
    font-weight: bold !important;
}

body.a11y-contrast-high button {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #000000 !important;
    font-weight: bold !important;
}

/* Inverted/Dark Mode - BEAUTIFUL DARK MODE */
body.a11y-contrast-inverted {
    background: #1a202c !important;
    color: #e2e8f0 !important;
}

    body.a11y-contrast-inverted * {
        background-color: #5961745e !important;
    }

body.a11y-contrast-inverted #a11y-toolbar,
body.a11y-contrast-inverted #a11y-panel {
    background: #2d3748 !important;
    color: #e2e8f0 !important;
    border-color: #4a5568 !important;
}

body.a11y-contrast-inverted a {
    color: #63b3ed !important;
}

body.a11y-contrast-inverted button {
    background: #4a5568 !important;
    color: #e2e8f0 !important;
    border-color: #718096 !important;
}

body.a11y-contrast-inverted img,
body.a11y-contrast-inverted video {
    opacity: 0.85;
    filter: brightness(0.9);
}

/* Don't invert accessibility toolbar in dark mode */
body.a11y-contrast-inverted #a11y-toggle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
}

body.a11y-contrast-inverted #a11y-panel {
    background: linear-gradient(to bottom, #2d3748 0%, #1a202c 100%) !important;
}

/* Highlight Headings */
.a11y-highlight-headings h1,
.a11y-highlight-headings h2,
.a11y-highlight-headings h3,
.a11y-highlight-headings h4,
.a11y-highlight-headings h5,
.a11y-highlight-headings h6 {
    background: #FFE4B5 !important;
    padding: 8px !important;
    border-left: 4px solid #FF8C00 !important;
}

html[lang="ar"] .a11y-highlight-headings h1,
html[lang="ar"] .a11y-highlight-headings h2,
html[lang="ar"] .a11y-highlight-headings h3,
html[lang="ar"] .a11y-highlight-headings h4,
html[lang="ar"] .a11y-highlight-headings h5,
html[lang="ar"] .a11y-highlight-headings h6 {
    border-left: none !important;
    border-right: 4px solid #FF8C00 !important;
}

/* Text Spacing - Dyslexia-Friendly */
.a11y-text-spacing,
.a11y-text-spacing * {
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
    line-height: 1.8 !important;
}

.a11y-text-spacing p,
.a11y-text-spacing li,
.a11y-text-spacing span {
    margin-bottom: 0.5em !important;
}

/* Big Cursor */
.a11y-big-cursor,
.a11y-big-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="white" stroke="black" stroke-width="2" d="M5,3 L5,27 L12,20 L16,28 L19,27 L15,19 L23,19 Z"/></svg>') 0 0, auto !important;
}

.a11y-big-cursor a,
.a11y-big-cursor button {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="yellow" stroke="black" stroke-width="2" d="M16,3 L16,13 L21,13 L16,19 L16,29 L11,29 L11,19 L6,19 L11,13 L11,3 Z"/></svg>') 0 0, pointer !important;
}

/* Readable Font */
.a11y-readable-font,
.a11y-readable-font * {
    font-family: 'Arial', 'Helvetica', sans-serif !important;
    line-height: 1.8 !important;
    letter-spacing: 0.05em !important;
}

/* Remove Animations */
.a11y-no-animations,
.a11y-no-animations * {
    animation: none !important;
    transition: none !important;
}

/* Focus Indicators */
*:focus,
.a11y-focused {
    outline: 3px solid #FFD700 !important;
    outline-offset: 2px !important;
}

a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.5) !important;
}

/* Improved Focus for Keyboard Navigation */
.a11y-keyboard-nav *:focus {
    outline: 3px solid #FFD700 !important;
    outline-offset: 3px !important;
}

/* Live Region for Screen Readers */
#a11y-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Responsive Design - IMPROVED */
@media (max-width: 768px) {
    #a11y-toolbar {
        bottom: 10px;
        left: 10px;
    }
    
    #a11y-toggle {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    #a11y-toggle:hover {
        width: 56px;
        height: 56px;
        font-size: 26px;
    }
    
    #a11y-panel {
        position: fixed !important;
        bottom: 70px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 90px);
        padding: 20px;
        font-size: 14px;
    }
    
    .a11y-section {
        padding: 12px;
    }
    
    .a11y-buttons {
        gap: 8px;
    }
    
    .a11y-buttons button {
        padding: 10px;
        font-size: 13px;
    }
}

/* Ensure Toolbar Stays on Top While Scrolling */
body {
    scroll-behavior: smooth;
}

#a11y-toolbar,
#a11y-panel {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
}

/* Smooth Animations - Slide from Bottom */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 12px 48px rgba(102, 126, 234, 0.6);
    }
}

#a11y-panel:not(.a11y-hidden) {
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#a11y-toggle {
    animation: pulse 3s ease-in-out infinite;
}

/* Print Styles - Hide Accessibility Toolbar */
@media print {
    #a11y-toolbar,
    .a11y-skip-link,
    #a11y-panel {
        display: none !important;
    }
}

/* High Contrast Mode Detection (Windows) */
@media (prefers-contrast: high) {
    body {
        border: 2px solid currentColor;
    }
    
    a {
        text-decoration: underline;
    }
}

/* Reduced Motion Preference Detection */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* System Dark Mode Support */
@media (prefers-color-scheme: dark) {
    #a11y-panel {
        background: linear-gradient(to bottom, #2d3748 0%, #1a202c 100%);
        color: #e2e8f0;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    }
    
    #a11y-panel h2 {
        color: #e2e8f0;
        -webkit-text-fill-color: #e2e8f0;
    }
    
    #a11y-panel h3 {
        color: #cbd5e0;
    }
    
    .a11y-section {
        background: rgba(45, 55, 72, 0.7);
        border-color: rgba(102, 126, 234, 0.3);
    }
    
    .a11y-section label {
        color: #cbd5e0;
    }
    
    .a11y-section label:hover {
        background: rgba(102, 126, 234, 0.15);
    }
    
    .a11y-buttons button {
        background: linear-gradient(to bottom, #2d3748 0%, #1a202c 100%);
        color: #e2e8f0;
        border-color: rgba(102, 126, 234, 0.4);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    .a11y-buttons button:hover {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
    }
    
    #a11y-close {
        background: rgba(102, 126, 234, 0.2);
        color: #e2e8f0;
    }
    
    #a11y-close:hover {
        background: rgba(102, 126, 234, 0.3);
    }
}

/* Ensure Good Color Contrast */
.a11y-ensure-contrast {
    color: #000;
    background: #fff;
}

.a11y-ensure-contrast a {
    color: #0066CC;
}

.a11y-ensure-contrast a:visited {
    color: #6B4C9A;
}

.a11y-ensure-contrast a:hover,
.a11y-ensure-contrast a:focus {
    color: #003D7A;
}

/* Accessible Form Elements */
input:invalid,
select:invalid,
textarea:invalid {
    border-color: #E74C3C !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2) !important;
}

input:valid,
select:valid,
textarea:valid {
    border-color: #27AE60 !important;
}

/* Accessible Error Messages */
.a11y-error {
    color: #E74C3C;
    background: #FADBD8;
    padding: 8px 12px;
    border-left: 4px solid #E74C3C;
    margin: 8px 0;
    border-radius: 4px;
}

html[lang="ar"] .a11y-error {
    border-left: none;
    border-right: 4px solid #E74C3C;
}

/* Accessible Success Messages */
.a11y-success {
    color: #27AE60;
    background: #D4EDDA;
    padding: 8px 12px;
    border-left: 4px solid #27AE60;
    margin: 8px 0;
    border-radius: 4px;
}

html[lang="ar"] .a11y-success {
    border-left: none;
    border-right: 4px solid #27AE60;
}

/* Accessible Tooltips */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[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: #333;
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

/* Accessible Tables */
table {
    border-collapse: collapse;
    width: 100%;
}

th {
    background: #4A90E2;
    color: white;
    font-weight: bold;
    text-align: left;
    padding: 12px;
}

html[lang="ar"] th {
    text-align: right;
}

td {
    padding: 12px;
    border-bottom: 1px solid #ddd;
}

tr:hover {
    background: #F5F5F5;
}

/* Ensure minimum touch target size (44x44px for WCAG) */
a, button, input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width: 44px;
}

