/* Accessibility and Performance Fixes for Hubomoto HRMS */

/* Color Contrast Fixes */
:root {
  --primary-color: #1e40af;
  --primary-dark: #1e3a8a;
  --secondary-color: #f59e0b;
  --text-color: #1f2937;
  --text-muted: #6b7280;
  --background: #ffffff;
  --border-color: #e5e7eb;
  --success-color: #059669;
  --warning-color: #d97706;
  --error-color: #dc2626;
  --info-color: #0284c7;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000080;
    --text-color: #000000;
    --text-muted: #333333;
    --border-color: #000000;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: #3b82f6;
    --text-color: #f9fafb;
    --text-muted: #d1d5db;
    --background: #111827;
    --border-color: #374151;
  }
}

/* Focus indicators for better accessibility */
*:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Skip links for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-color);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 10000;
}

.skip-link:focus {
  top: 6px;
}

/* Button accessibility improvements */
.btn {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}

/* Form accessibility improvements */
.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.form-label {
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 8px;
}

/* Table accessibility improvements */
.table {
  border-collapse: collapse;
}

.table th {
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  padding: 12px;
  text-align: left;
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
  background-color: rgba(59, 130, 246, 0.05);
}

/* Navigation accessibility improvements */
.navbar-nav .nav-link {
  padding: 12px 16px;
  color: var(--text-color);
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--primary-color);
}

.navbar-nav .nav-link.active {
  background-color: var(--primary-color);
  color: white;
}

/* Card accessibility improvements */
.card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-header {
  background-color: var(--background);
  border-bottom: 1px solid var(--border-color);
  padding: 16px;
  font-weight: 600;
}

.card-body {
  padding: 16px;
}

/* Modal accessibility improvements */
.modal-content {
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 20px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 20px;
}

/* Alert accessibility improvements */
.alert {
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
  border-left: 4px solid;
}

.alert-success {
  background-color: #f0fdf4;
  border-left-color: var(--success-color);
  color: #166534;
}

.alert-warning {
  background-color: #fffbeb;
  border-left-color: var(--warning-color);
  color: #92400e;
}

.alert-error {
  background-color: #fef2f2;
  border-left-color: var(--error-color);
  color: #991b1b;
}

.alert-info {
  background-color: #eff6ff;
  border-left-color: var(--info-color);
  color: #1e40af;
}

/* Loading states for better UX */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

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

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

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  .print-break {
    page-break-before: always;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
}

/* Performance optimizations */
* {
  box-sizing: border-box;
}

img {
  max-width: 100%;
  height: auto;
}

/* Lazy loading support */
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
  opacity: 1;
}

/* Critical CSS for above-the-fold content */
.above-fold {
  contain: layout style paint;
}

/* Optimize font loading - removed conflicting @font-face declaration */

/* Improve text readability */
body {
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background);
}

/* Heading hierarchy improvements */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-color);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 16px;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 24px;
}

h2 {
  font-size: 2rem;
  margin-bottom: 20px;
}

h3 {
  font-size: 1.5rem;
  margin-bottom: 16px;
}

h4 {
  font-size: 1.25rem;
  margin-bottom: 12px;
}

h5 {
  font-size: 1.125rem;
  margin-bottom: 8px;
}

h6 {
  font-size: 1rem;
  margin-bottom: 8px;
}

/* Link accessibility improvements */
a {
  color: var(--primary-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover,
a:focus {
  color: var(--primary-dark);
  text-decoration-thickness: 2px;
}

a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

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

/* Ensure focus is visible for keyboard users */
a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
