/* ============================================
   إمكانية الوصول - ذوي الاحتياجات الخاصة
   Accessibility for Screen Readers & Keyboard Users
   ============================================ */

/* 1. رابط التخطي - يظهر عند التركيز بلوحة المفاتيح */
.skip-link {
    position: absolute;
    top: -100px;
    right: 1rem;
    z-index: 10000;
    padding: 0.75rem 1.5rem;
    background: var(--gdrfa-brown, #8B4513);
    color: white !important;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: top 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.skip-link:focus {
    top: 1rem;
    outline: 3px solid var(--gdrfa-gold, #D4AF37);
    outline-offset: 2px;
}

/* 2. مؤشر التركيز الواضح لجميع العناصر التفاعلية */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--gdrfa-gold, #D4AF37) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px white;
}

/* إزالة outline الافتراضي عند النقر بالماوس (التركيز فقط بلوحة المفاتيح) */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
    outline: none;
}

/* 3. دعم تقليل الحركة - للمستخدمين الذين يفضلون تقليل الرسوم المتحركة */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html {
        scroll-behavior: auto;
    }
}

/* 4. تحسين وضوح النص */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 5. نسبة تباين أفضل للروابط */
a {
    text-decoration-skip-ink: auto;
}

/* 6. عناصر النماذج - ربط واضح مع التسميات */
input:focus,
select:focus,
textarea:focus {
    border-color: var(--gdrfa-brown, #8B4513);
}

/* 7. أزرار الأيقونة - مساحة لمس كافية */
.icon-btn,
button[aria-label],
.btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 1rem;
}

/* 8. عناصر القائمة الجانبية - وضوح عند التركيز */
.nav-item:focus-visible,
.candidate-nav-item:focus-visible {
    outline: 3px solid var(--gdrfa-gold, #D4AF37);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.12);
}

/* 9. إخفاء المحتوى المرئي فقط من قارئ الشاشة عند الحاجة */
.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;
}

/* 10. تنبيهات للمستخدم - يقرأها قارئ الشاشة فوراً */
[role="alert"] {
    font-weight: 600;
}

/* ============================================
   11. لوحة إعدادات إمكانية الوصول
   ============================================ */
.a11y-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 30, 0.45);
    z-index: 10050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.a11y-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.a11y-panel {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    width: 360px;
    max-width: 90vw;
    height: 100vh;
    background: #fff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 10060;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    font-family: 'Cairo', 'Dubai', sans-serif;
}
html[dir="rtl"] .a11y-panel { transform: translateX(105%); }
.a11y-panel.is-open { transform: translateX(0); }

.a11y-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #0a2240 0%, #13325a 100%);
    color: #fff;
}
.a11y-panel-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
}
.a11y-panel-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    line-height: 1;
}
.a11y-panel-close:hover { background: rgba(255, 255, 255, 0.15); }

.a11y-panel-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.a11y-group { margin-bottom: 1.5rem; }
.a11y-group-label {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    color: #0a2240;
    margin-bottom: 0.6rem;
}
.a11y-group-actions {
    display: flex;
    gap: 0.5rem;
}
.a11y-btn {
    flex: 1;
    background: #f4f6f8;
    border: 2px solid transparent;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    color: #0a2240;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.a11y-btn:hover { background: #e7ecf3; border-color: #c5a059; }

.a11y-toggles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.a11y-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
    background: #f4f6f8;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    color: #0a2240;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.a11y-toggle i { font-size: 1.15rem; }
.a11y-toggle:hover { background: #e7ecf3; }
.a11y-toggle[aria-pressed="true"] {
    background: #0a2240;
    color: #fff;
    border-color: #c5a059;
}

.a11y-reset {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 2px solid #0a2240;
    color: #0a2240;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    transition: background 0.15s ease, color 0.15s ease;
}
.a11y-reset:hover { background: #0a2240; color: #fff; }

/* Applied modes */
html.a11y-font-larger body { font-size: 112.5% !important; }
html.a11y-font-largest body { font-size: 125% !important; }
html.a11y-font-smaller body { font-size: 90% !important; }

html.a11y-grayscale body {
    filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
}

html.a11y-high-contrast body {
    background: #000 !important;
    color: #fff !important;
}
html.a11y-high-contrast body * {
    background-color: transparent !important;
    color: #fff !important;
    border-color: #fff !important;
}
html.a11y-high-contrast a,
html.a11y-high-contrast a * {
    color: #ffd54a !important;
}
html.a11y-high-contrast img,
html.a11y-high-contrast svg {
    filter: grayscale(100%) contrast(120%);
}

html.a11y-highlight-links a {
    background: #ffef9f !important;
    color: #0a2240 !important;
    text-decoration: underline !important;
    outline: 1px solid #c5a059;
}

html.a11y-readable-font,
html.a11y-readable-font body,
html.a11y-readable-font * {
    font-family: 'Cairo', 'Tahoma', sans-serif !important;
    letter-spacing: 0.01em;
}
