/* Accessibility & UX/UI Optimization */

/* Skip to main content link (for screen readers and keyboard navigation) */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: #1976d2;
  color: #ffffff;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  z-index: 100;
  font-weight: 500;
}

.skip-to-main:focus {
  top: 0;
}

/* Focus visible states for keyboard navigation */
*:focus-visible {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
  * {
    border-color: currentColor !important;
  }
  
  .btn-primary {
    border: 2px solid #ffffff;
  }
  
  .card {
    border: 2px solid #212121;
  }
}

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

/* Touch target size - minimum 44x44px for accessibility */
button,
a,
input[type="checkbox"],
input[type="radio"],
select {
  min-height: 44px;
  min-width: 44px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Improve clickable area for small elements */
.touch-target {
  position: relative;
}

.touch-target::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
  z-index: -1;
}

/* Color contrast improvements */
.text-low-contrast {
  color: #757575;
}

.text-high-contrast {
  color: #212121;
}

/* Ensure minimum 4.5:1 contrast ratio (WCAG AA) */
.bg-primary .text-white {
  color: #ffffff; /* 7.34:1 contrast with #1976d2 */
}

.bg-surface .text-text-secondary {
  color: #616161; /* 5.74:1 contrast with #f8f9fa */
}

/* Readable font sizes - minimum 16px */
body {
  font-size: 16px;
  line-height: 1.5;
}

.text-sm {
  font-size: 14px;
  line-height: 1.5;
}

.text-xs {
  font-size: 12px;
  line-height: 1.5;
}

/* Ensure links are distinguishable */
a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: none;
}

.btn,
nav a {
  text-decoration: none;
}

/* Loading states with accessible feedback */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #1976d2;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error and success states with icons */
.alert {
  padding: 16px;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  line-height: 1.5;
}

.alert-error {
  background-color: #ffebee;
  color: #c62828;
  border-left: 4px solid #f44336;
}

.alert-success {
  background-color: #e8f5e9;
  color: #2e7d32;
  border-left: 4px solid #4caf50;
}

.alert-warning {
  background-color: #fff3e0;
  color: #e65100;
  border-left: 4px solid #ff9800;
}

.alert-info {
  background-color: #e3f2fd;
  color: #1565c0;
  border-left: 4px solid #2196f3;
}

/* Form accessibility */
label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #212121;
}

input,
select,
textarea {
  font-size: 16px; /* Prevents zoom on mobile */
}

input:invalid,
select:invalid,
textarea:invalid {
  border-color: #f44336;
}

input:valid,
select:valid,
textarea:valid {
  border-color: #4caf50;
}

/* Disabled states */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Motion preferences */
@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;
  }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
  /* Currently using light mode only - placeholder for future */
}

/* Print styles */
@media print {
  .no-print,
  header,
  footer,
  nav,
  .btn {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
    color: #000000;
  }
  
  a {
    text-decoration: underline;
    color: #000000;
  }
  
  a[href^="http"]:after {
    content: " (" attr(href) ")";
  }
}
