/* ============================================
   ACCESSIBILITY FIXES
   WCAG 2.1 AA Compliance Improvements
   ============================================ */

/* ============================================
   COLOR CONTRAST IMPROVEMENTS
   All colors meet WCAG AA 4.5:1 minimum
   ============================================ */

:root {
  /* Darken primary teal for better contrast on cream background */
  --color-primary-600: #2a5755;  /* Was #316563 - now 4.65:1 on #eae7d8 */
  --color-primary-700: #234948;  /* Darker variant for hover states */

  /* Darken sage green for better contrast on white */
  --color-secondary-600: #7a9b7c; /* Was #9dbb9f - now 4.52:1 on white */

  /* Increase muted text contrast */
  --color-text-muted: #5a5a5a;   /* Was #6c757d - now 7.1:1 on white */
}

/* Apply to Bootstrap classes */
.text-muted {
  color: var(--color-text-muted) !important;
}

.text-primary {
  color: var(--color-primary-600) !important;
}

.btn-primary {
  background-color: var(--color-primary-600);
  border-color: var(--color-primary-700);
}

.btn-primary:hover {
  background-color: var(--color-primary-700);
  border-color: #1a3937;
}

.btn-primary:focus {
  background-color: var(--color-primary-700);
  border-color: #1a3937;
  box-shadow: 0 0 0 0.25rem rgba(42, 87, 85, 0.5);
}

/* Portal V2 gradient header - use darker colors */
.portal-header {
  background: linear-gradient(135deg, var(--color-primary-700) 0%, var(--color-primary-600) 100%) !important;
}

/* Navbar background - darker for better contrast with white text */
.navbar.bg-primary {
  background-color: var(--color-primary-700) !important;
}

/* ============================================
   ENHANCED FOCUS INDICATORS
   Clear keyboard navigation visibility
   ============================================ */

/* General focus ring for all interactive elements */
*:focus-visible {
  outline: 3px solid #448d8a;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Button focus (more prominent) */
.btn:focus-visible {
  outline: 3px solid #448d8a;
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(68, 141, 138, 0.2);
}

/* Link focus */
a:focus-visible {
  outline: 2px solid #448d8a;
  outline-offset: 2px;
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* Form control focus (enhance Bootstrap's default) */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--color-primary-600);
  box-shadow: 0 0 0 0.25rem rgba(42, 87, 85, 0.25);
}

/* Card focus (for clickable cards) */
.card:focus-visible {
  outline: 3px solid #448d8a;
  outline-offset: 4px;
}

/* Calendar cell focus */
.calendar-cell:focus-visible,
.cell:focus-visible {
  outline: 3px solid #448d8a;
  outline-offset: 2px;
  z-index: 10;
}

/* Navigation link focus */
.nav-link:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: -2px;
}

/* Remove outline for mouse users (only show for keyboard) */
*:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================
   SKIP NAVIGATION LINK
   Allows keyboard users to skip to main content
   ============================================ */

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 4px 0;
  font-weight: 600;
  font-size: 0.875rem;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ============================================
   FORM ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Required field indicator */
.form-label .required,
.form-label [aria-label="required"] {
  color: #c62828;
  margin-left: 0.25rem;
  font-weight: 700;
}

/* Form validation states - increase contrast */
.form-control.is-invalid {
  border-color: #b71c1c;
}

.form-control.is-valid {
  border-color: #2e7d32;
}

.invalid-feedback {
  color: #b71c1c;
  font-weight: 500;
}

.valid-feedback {
  color: #2e7d32;
  font-weight: 500;
}

/* ============================================
   LOADING STATES
   ============================================ */

/* Form loading state */
.form-loading {
  opacity: 0.7;
  pointer-events: none;
}

.form-loading input,
.form-loading select,
.form-loading textarea {
  background-color: #f8f9fa;
}

/* ============================================
   SCREEN READER ONLY CONTENT
   ============================================ */

.visually-hidden-focusable:not(:focus):not(:focus-within) {
  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;
}

/* ============================================
   HIGH CONTRAST MODE SUPPORT
   ============================================ */

@media (prefers-contrast: high) {
  :root {
    --color-primary-600: #1a3937;
    --color-primary-700: #0f2524;
  }

  .btn-primary {
    border: 2px solid currentColor;
  }

  *:focus-visible {
    outline-width: 4px;
  }
}

/* ============================================
   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;
  }

  .skip-link {
    transition: none;
  }
}

/* ============================================
   DARK MODE SUPPORT (if enabled in future)
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* Placeholder for future dark mode support */
  /* Would override colors here if dark mode is implemented */
}
