/* CSVLOD-AI Framework - WCAG 2.1 AA Accessibility CSS */
/* Version: 3.1.0 - Production Optimized */

/* Skip Links - WCAG 2.1 AA Requirement */
.skip-link {
  position: absolute;
  top: -50px;
  left: 8px;
  background: #2563eb;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  z-index: 9999;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 8px;
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

.skip-link:hover {
  background: #1d4ed8;
  text-decoration: underline;
}

/* Enhanced Focus Indicators - WCAG 2.1 AA */
*:focus {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}

.btn:focus,
.nav-link:focus,
.footer-link:focus {
  outline: 3px solid #fbbf24;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.2);
}

/* High Contrast Focus for Interactive Elements */
input:focus,
textarea:focus,
select:focus,
button:focus {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb, 0 0 0 4px rgba(37, 99, 235, 0.1);
}

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

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 0.5rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: #2563eb;
  color: #ffffff;
  border-radius: 4px;
}

/* Reduced Motion Support - WCAG 2.1 AA */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Colors - WCAG 2.1 AA 7:1 Ratio */
.high-contrast {
  --text-primary: #000000;
  --text-secondary: #1a1a1a;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --link-color: #0d47a1;
  --link-hover: #001970;
  --border-color: #333333;
}

/* Color Contrast Improvements */
.text-muted {
  color: #495057 !important; /* 7:1 contrast ratio */
}

.text-secondary {
  color: #343a40 !important; /* 7:1 contrast ratio */
}

/* Focus Visible Polyfill Support */
.js-focus-visible :focus:not(.focus-visible) {
  outline: none;
}

/* Keyboard Navigation Enhancements */
.nav-link[tabindex="-1"] {
  pointer-events: none;
}

/* Mobile Touch Target Size - WCAG 2.1 AA */
@media (max-width: 768px) {
  .btn,
  .nav-link,
  .footer-link,
  input,
  button,
  [role="button"],
  [tabindex="0"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }
}

/* Error and Status Messages */
.error-message {
  color: #dc3545;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  padding: 12px;
  border-radius: 4px;
  margin: 8px 0;
}

.success-message {
  color: #155724;
  background: #d4edda;
  border: 1px solid #c3e6cb;
  padding: 12px;
  border-radius: 4px;
  margin: 8px 0;
}

/* Form Accessibility */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #212529;
}

.form-control {
  border: 2px solid #ced4da;
  border-radius: 4px;
  padding: 12px;
  font-size: 16px;
  line-height: 1.5;
}

.form-control:invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control:valid {
  border-color: #28a745;
}

/* Required Field Indicators */
.required::after {
  content: " *";
  color: #dc3545;
  font-weight: bold;
}

/* Link Accessibility */
a:not([class]) {
  color: #0d47a1;
  text-decoration: underline;
}

a:not([class]):hover,
a:not([class]):focus {
  color: #001970;
  text-decoration: underline;
}

/* Table Accessibility */
.table {
  border-collapse: collapse;
  width: 100%;
}

.table th,
.table td {
  border: 1px solid #dee2e6;
  padding: 12px;
  text-align: left;
}

.table th {
  background: #f8f9fa;
  font-weight: 600;
}

/* Loading and Status Indicators */
.loading {
  position: relative;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Print Accessibility */
@media print {
  .skip-link,
  .nav-container,
  .footer {
    display: none;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
    color: #666;
    font-size: 0.8em;
  }
}

/* Dark Mode Accessibility */
@media (prefers-color-scheme: dark) {
  .auto-dark {
    --text-primary: #ffffff;
    --text-secondary: #e5e7eb;
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --link-color: #60a5fa;
    --link-hover: #93c5fd;
    --border-color: #374151;
  }
}

/* Language Direction Support */
[dir="rtl"] .skip-link {
  left: auto;
  right: 8px;
}

[dir="rtl"] .nav-container {
  direction: rtl;
}

/* ARIA Live Regions */
.live-region {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Custom Properties for Consistency */
:root {
  --focus-color: #fbbf24;
  --focus-offset: 2px;
  --focus-width: 3px;
  --touch-target: 44px;
  --text-contrast: #000000;
  --bg-contrast: #ffffff;
}