/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   Améliorations pour l'accessibilité WCAG
   ============================================ */

/* Skip to main content link */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary-500, #FF6B35);
  color: white;
  padding: var(--space-2, 0.5rem) var(--space-4, 1rem);
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 var(--radius-md, 0.5rem) 0;
  font-weight: var(--font-semibold, 600);
}

.skip-to-main:focus {
  top: 0;
  outline: 3px solid var(--primary-600, #E84A09);
  outline-offset: 2px;
}

/* Focus visible improvements */
*:focus-visible {
  outline: 3px solid var(--primary-500, #FF6B35);
  outline-offset: 2px;
  border-radius: var(--radius-sm, 0.375rem);
}

/* Remove outline for mouse users but keep for keyboard */
*:focus:not(:focus-visible) {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-primary: #000000;
    --text-primary: #000000;
    --bg-card: #FFFFFF;
  }

  [data-theme="dark"] {
    --border-primary: #FFFFFF;
    --text-primary: #FFFFFF;
    --bg-card: #000000;
  }

  .card,
  .job-card-premium,
  .news-card-premium {
    border-width: 2px;
  }
}

/* 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-fade-in,
  .animate-fade-in-up,
  .animate-slide-in-right,
  .animate-pulse-subtle,
  .animate-blob {
    animation: none !important;
  }
}

/* Screen reader only content */
.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;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ARIA live regions */
[aria-live] {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Links: no underline (site-wide UX choice) */
a:not(.btn):not(.badge) {
  text-decoration: none !important;
}

a:not(.btn):not(.badge):hover {
  text-decoration: none !important;
}

/* Button minimum touch target */
button,
a.btn,
input[type="submit"],
input[type="button"] {
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2, 0.5rem) var(--space-4, 1rem);
}

/* Form labels always visible */
label {
  display: block;
  margin-bottom: var(--space-1, 0.25rem);
  font-weight: var(--font-medium, 500);
  color: var(--text-primary, #1E293B);
}

[data-theme="dark"] label {
  color: var(--text-primary);
}

/* Required field indicator */
label.required::after {
  content: " *";
  color: var(--error, #EF4444);
  font-weight: var(--font-bold, 700);
}

/* Error states for forms */
input.error,
select.error,
textarea.error {
  border-color: var(--error, #EF4444);
  border-width: 2px;
}

.error-message {
  color: var(--error, #EF4444);
  font-size: var(--text-sm, 0.875rem);
  margin-top: var(--space-1, 0.25rem);
  display: flex;
  align-items: center;
  gap: var(--space-1, 0.25rem);
}

.error-message::before {
  content: "⚠";
  font-size: 1rem;
}

/* Success states */
.success-message {
  color: var(--success, #10B981);
  font-size: var(--text-sm, 0.875rem);
  margin-top: var(--space-1, 0.25rem);
  display: flex;
  align-items: center;
  gap: var(--space-1, 0.25rem);
}

.success-message::before {
  content: "✓";
  font-size: 1rem;
}

/* Loading states accessibility */
[aria-busy="true"] {
  cursor: wait;
}

[aria-busy="true"] * {
  pointer-events: none;
}

/* Landmark regions */
main {
  outline: none;
}

main:focus {
  outline: 2px dashed var(--primary-500, #FF6B35);
  outline-offset: 4px;
}

/* Better table accessibility */
table {
  border-collapse: collapse;
}

th {
  text-align: left;
  font-weight: var(--font-semibold, 600);
  padding: var(--space-3, 0.75rem);
}

td {
  padding: var(--space-3, 0.75rem);
}

/* Image alt text fallback */
img[alt=""] {
  border: 2px dashed var(--gray-400, #94A3B8);
}

/* Better color contrast for text on colored backgrounds */
.bg-primary-500,
.bg-primary-600 {
  color: white;
}

.bg-gray-900 {
  color: var(--gray-50, #F8FAFC);
}

/* Icon only buttons need labels */
button[aria-label],
a[aria-label] {
  position: relative;
}

/* Keyboard navigation improvements */
nav a:focus,
nav button:focus {
  background-color: var(--primary-50, #FFF5E6);
  outline: 2px solid var(--primary-500, #FF6B35);
  outline-offset: 2px;
}

[data-theme="dark"] nav a:focus,
[data-theme="dark"] nav button:focus {
  background-color: var(--gray-200, #334155);
}

/* Modal accessibility */
[role="dialog"] {
  outline: none;
}

[role="dialog"]:focus {
  outline: 3px solid var(--primary-500, #FF6B35);
  outline-offset: 2px;
}

/* Better list markers */
ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding-left: 0;
}

/* Ensure sufficient color contrast */
.text-gray-600 {
  color: var(--gray-600, #475569);
}

[data-theme="dark"] .text-gray-600 {
  color: var(--gray-400, #64748B);
}

/* Print styles for accessibility */
@media print {
  .skip-to-main,
  button,
  nav,
  footer {
    display: none;
  }

  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  a[href^="#"]:after {
    content: "";
  }
}
