@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  --foreground-rgb: 17, 24, 39;
  --background-rgb: 255, 255, 255;
}

body {
  color: rgb(17, 24, 39);
  background: rgb(255, 255, 255);
  min-height: 100vh;
}

/* Input Fields - Comprehensive Fix */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
input[type="time"],
textarea,
select {
  color: #111827 !important;
  background-color: #ffffff !important;
  -webkit-text-fill-color: #111827 !important;
  opacity: 1 !important;
}

/* Input focus states */
input:focus,
textarea:focus,
select:focus {
  color: #111827 !important;
  -webkit-text-fill-color: #111827 !important;
}

/* Placeholder text */
input::placeholder,
textarea::placeholder {
  color: #9CA3AF !important;
  -webkit-text-fill-color: #9CA3AF !important;
  opacity: 1 !important;
}

/* Disabled inputs */
input:disabled,
textarea:disabled,
select:disabled {
  color: #6B7280 !important;
  background-color: #F3F4F6 !important;
  -webkit-text-fill-color: #6B7280 !important;
}

/* Ensure autocomplete doesn't override colors */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: #111827 !important;
  -webkit-box-shadow: 0 0 0 1000px white inset !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* Font Families */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-cairo), sans-serif;
}

p, span, div, a, button, input, textarea, select, label, td, th {
  font-family: var(--font-readex), sans-serif;
}

@layer utilities {
  .text-balance {
    text-wrap: balance;
  }
  
  .font-heading {
    font-family: var(--font-cairo), sans-serif;
  }
  
  .font-body {
    font-family: var(--font-readex), sans-serif;
  }
}

/* RTL Support */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .ml-auto {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .mr-auto {
  margin-right: 0;
  margin-left: auto;
}

/* ==============================================
   ACCESSIBILITY IMPROVEMENTS (WCAG AA)
   ============================================== */

/* Focus Indicators - Visible outline for keyboard navigation */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #3b82f6 !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
}

/* Enhanced focus for interactive elements */
button:focus-visible {
  outline-color: #2563eb;
}

/* Focus for checkboxes and radio buttons */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Remove default focus for mouse users (keep for keyboard) */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  button:focus-visible,
  a:focus-visible,
  input:focus-visible {
    outline-width: 3px !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;
  }
}

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

/* Skip to main content link */
.skip-to-main {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 1rem;
  background-color: #1f2937;
  color: white;
  text-decoration: none;
}

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

/* Ensure sufficient color contrast for links */
a {
  color: #2563eb;
  text-decoration-skip-ink: auto;
}

a:hover {
  color: #1d4ed8;
}

/* Better button states for accessibility */
button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Loading states with aria-busy */
[aria-busy="true"] {
  cursor: wait;
}

/* Error states */
[aria-invalid="true"] {
  border-color: #dc2626 !important;
}

/* Required field indicators */
[aria-required="true"]::after {
  content: " *";
  color: #dc2626;
}

/* Keyboard navigation hints */
[data-keyboard-hint]:focus-visible::after {
  content: attr(data-keyboard-hint);
  position: absolute;
  bottom: -1.5rem;
  left: 0;
  font-size: 0.75rem;
  color: #6b7280;
}

