/* Screen Reader Only Utility */
.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;
}

/* Enhanced Focus Indicators */
*:focus-visible {
  outline: 2px solid theme('colors.blue.600');
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* Skip to Main Content Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: theme('colors.blue.600');
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  * {
    border-width: 2px !important;
  }

  .text-gray-600 {
    color: theme('colors.gray.900') !important;
  }
}

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

/* Touch Target Sizing (minimum 44x44px for mobile) */
@media (max-width: 768px) {
  button,
  a,
  input[type="checkbox"],
  input[type="radio"],
  select {
    min-height: 44px;
    min-width: 44px;
  }

  /* Ensure interactive elements have adequate spacing */
  .btn,
  .link {
    padding: 12px 16px;
  }
}

/* Loading States */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Error States with Icons */
.error-message {
  display: flex;
  align-items: start;
  gap: 0.5rem;
}

.error-message::before {
  content: "⚠";
  font-size: 1.25rem;
  color: theme('colors.red.600');
}

/* Success States */
.success-message {
  display: flex;
  align-items: start;
  gap: 0.5rem;
}

.success-message::before {
  content: "✓";
  font-size: 1.25rem;
  color: theme('colors.green.600');
}

/* Form Field Base Styles */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
textarea,
select {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid theme('colors.gray.300');
  background-color: white;
  color: theme('colors.gray.900');
  font-size: 1rem;
  line-height: 1.5;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Larger padding for textareas */
textarea {
  padding: 0.75rem;
  min-height: 100px;
}

/* Select fields need consistent sizing */
select {
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  appearance: none;
}

/* Form Field Focus States */
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid theme('colors.blue.600');
  outline-offset: 0;
  border-color: theme('colors.blue.600');
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Invalid Form Fields */
input:invalid:not(:focus),
textarea:invalid:not(:focus),
select:invalid:not(:focus) {
  border-color: theme('colors.red.500');
}

input:invalid:not(:focus):not(:placeholder-shown),
textarea:invalid:not(:focus):not(:placeholder-shown) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%23EF4444'%3E%3Cpath fill-rule='evenodd' d='M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

/* Mobile Navigation Enhancements */
@media (max-width: 768px) {
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid theme('colors.gray.200');
    padding: 0.5rem;
    z-index: 50;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    min-width: 60px;
    text-align: center;
    font-size: 0.75rem;
  }

  /* Add padding to body to account for fixed bottom nav */
  body.has-mobile-nav {
    padding-bottom: 70px;
  }
}

/* Print Styles */
@media print {
  .no-print {
    display: none !important;
  }

  a[href]:after {
    content: " (" attr(href) ")";
  }

  /* Optimize for printing */
  body {
    background: white !important;
    color: black !important;
  }

  /* Remove box shadows and unnecessary decorations */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }
}

/* Dark Mode Support - Reserved for future implementation */
/* Uncomment when dark mode styles are ready
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}
*/
