/**
 * FastBridge Accessibility Styles
 * WCAG 2.1 AA Compliance
 */

/* Screen reader only text - WCAG 2.1 Success Criterion 1.3.1 */
.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 to main content link - WCAG 2.1 Success Criterion 2.4.1 */
.skip-to-main {
  position: absolute;
  left: -9999px;
  z-index: 9999;
  padding: 1em 1.5em;
  background-color: #228383;
  color: white;
  text-decoration: none;
  font-weight: 600;
  border-radius: 4px;
}

.skip-to-main:focus {
  left: 50%;
  transform: translateX(-50%);
  top: 10px;
}

/* Focus visible styles - WCAG 2.1 Success Criterion 2.4.7 */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
  outline: 3px solid #22b3b3;
  outline-offset: 2px;
}

/* High contrast focus for elements on dark backgrounds */
.dark-bg a:focus,
.dark-bg button:focus,
.navbar a:focus,
.navbar button:focus {
  outline: 3px solid #22b3b3;
  outline-offset: 2px;
}

/* Ensure minimum touch target size - WCAG 2.1 Success Criterion 2.5.5 */
/* Note: For checkboxes and radios, the clickable area includes the label, so we don't enforce size on the input itself */
button:not(.btn-sm):not(.close),
a.btn:not(.btn-sm) {
  min-height: 44px;
  min-width: 44px;
}

/* ARIA live region styles - WCAG 2.1 Success Criterion 4.1.3 */
.aria-live-region {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.aria-live-region.visible {
  position: relative;
  left: auto;
  width: auto;
  height: auto;
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 6px;
  font-weight: 500;
}

.aria-live-region.success {
  background-color: #22b373;
  color: #fff;
}

.aria-live-region.error {
  background-color: #dc3545;
  color: #fff;
}

.aria-live-region.info {
  background-color: #22b3b3;
  color: #fff;
}

/* Required field indicator */
.required-indicator {
  color: #dc3545;
  font-weight: bold;
  margin-left: 2px;
}

/* Error message styles */
.error-message {
  color: #c92a2a;
  font-size: 0.875rem;
  margin-top: 4px;
  display: none;
}

.error-message:not(:empty) {
  display: block;
}

/* Invalid field styling */
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: #dc3545;
  border-width: 2px;
}

/* Sort indicator for accessible tables */
.sort-button {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
  width: 100%;
  text-align: left;
}

.sort-indicator {
  margin-left: 8px;
  font-size: 0.8em;
}

/* Loading state - WCAG 2.1 Success Criterion 4.1.3 */
[aria-busy="true"] {
  opacity: 0.7;
  pointer-events: none;
}

/* Visually hidden but available to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  a:focus,
  button:focus,
  input:focus,
  select:focus,
  textarea:focus {
    outline: 4px solid;
    outline-offset: 2px;
  }
}

/* Reduced motion support - WCAG 2.1 Success Criterion 2.3.3 */
@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;
  }
}
