/* ===== إمكانية الوصول لأصحاب الهمم وقارئات الشاشة ===== */
/* متوافق مع WCAG 2.1 و NVDA, JAWS, VoiceOver, TalkBack */

/* نص مخفي بصرياً - مرئي لقارئات الشاشة فقط */
.sr-only,
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

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

/* رابط تخطي المحتوى - يظهر عند التركيز */
.skip-link {
  position: absolute;
  top: -100px;
  right: 1rem;
  z-index: 10000;
  padding: 0.75rem 1.25rem;
  background: var(--ui-primary, #0a2240);
  color: #fff !important;
  font-weight: 600;
  border-radius: 0.5rem;
  text-decoration: none;
  transition: top 0.2s ease;
  box-shadow: 0 4px 12px rgba(10, 34, 64, 0.3);
}

.skip-link:focus {
  top: 1rem;
  outline: 3px solid var(--materio-accent, #b78d1f);
  outline-offset: 2px;
}

/* تركيز واضح لجميع العناصر التفاعلية */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--materio-primary, #0a2240);
  outline-offset: 2px;
}

/* إزالة المخطط الافتراضي غير الواضح */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

/* منطقة إعلان حي لقارئات الشاشة */
[aria-live="polite"],
[aria-live="assertive"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* تحسين قراءة الجداول */
table[role="grid"],
table[role="table"] {
  border-collapse: collapse;
}

th[scope="col"],
th[scope="row"] {
  font-weight: 600;
}

/* تحسين قراءة النماذج */
label:not(.form-check-label) {
  cursor: pointer;
}

input:required + label::after,
label.required::after {
  content: " *";
  color: var(--materio-danger, #7a2530);
}

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

/* تباين عالي */
@media (prefers-contrast: high) {
  .btn,
  .form-control,
  .form-select {
    border-width: 2px;
  }
}

/* ===== تلميحات فورية عند المرور - لأصحاب الهمم ===== */
/* تظهر فوراً بدون تأخير عند المرور بالماوس أو التركيز */
[data-tooltip] {
  position: relative;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus::after,
[data-tooltip][data-tooltip-active]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.9rem;
  background: var(--materio-primary, #0a2240);
  color: #fff !important;
  font-size: 0.9rem;
  font-weight: 500;
  max-width: 280px;
  white-space: normal;
  text-align: center;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 10002;
  pointer-events: none;
  line-height: 1.4;
}
[dir="rtl"] [data-tooltip]:hover::after,
[dir="rtl"] [data-tooltip]:focus::after,
[dir="rtl"] [data-tooltip][data-tooltip-active]::after {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}
/* سهم صغير للتلميح */
[data-tooltip]:hover::before,
[data-tooltip]:focus::before,
[data-tooltip][data-tooltip-active]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--materio-primary, #0a2240);
  z-index: 10003;
  pointer-events: none;
}
