/**
 * LUMAVINE.AI - ACCESSIBILITY FIXES
 * Critical accessibility improvements for WCAG 2.1 AA compliance
 * Version: 1.0.0
 */

/* ============================================
   1. TOUCH TARGET FIXES (44x44px minimum)
   ============================================ */

/* Ensure all interactive elements meet 44x44px minimum touch target */
.btn,
button,
a.btn,
input[type="submit"],
input[type="button"],
input[type="reset"],
.nav-link,
.platform-btn,
.btn-icon {
  min-width: 44px;
  min-height: 44px;
  /* Ensure proper spacing between touch targets */
  margin: 2px;
}

/* Small buttons need explicit sizing */
.btn-sm {
  min-width: 44px;
  min-height: 44px;
  padding: 0.625rem 1rem;
}

/* Icon-only buttons */
.btn-icon,
button[aria-label]:not([class*="btn-"]) {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Navigation links */
.nav-link {
  min-height: 44px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
}

/* Quick prompt buttons */
.quick-btn,
.quick-prompt,
.prompt-card,
.mode-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 16px;
}

/* Platform switching buttons */
.platform-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 12px;
}

/* Form controls */
input[type="checkbox"],
input[type="radio"] {
  width: 24px;
  height: 24px;
  /* Add padding area for easier clicking */
  padding: 10px;
  margin: 2px;
}

/* Clickable cards */
.card[onclick],
.card[role="button"],
.glass-card[onclick] {
  min-height: 44px;
}

/* Mobile menu button */
#mobileMenuBtn,
.mobile-menu-btn {
  min-width: 44px;
  min-height: 44px;
}

/* Sidebar toggle */
#sidebarToggle {
  min-width: 44px;
  min-height: 44px;
}

/* Close buttons */
.close-btn,
.modal-close,
[aria-label*="close" i],
[aria-label*="dismiss" i] {
  min-width: 44px;
  min-height: 44px;
}

/* Ensure spacing between adjacent touch targets (8px minimum) */
.btn + .btn,
button + button,
.nav-link + .nav-link {
  margin-left: 8px;
}

.btn-group > .btn,
.btn-group > button {
  margin: 0 4px;
}

/* ============================================
   2. COLOR CONTRAST FIXES
   ============================================ */

/* Quick prompts - improve contrast */
.quick-btn,
.quick-prompt {
  background: var(--surface-mid);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}

.quick-btn:hover,
.quick-prompt:hover {
  background: var(--surface-light);
  color: var(--text-primary);
  border-color: var(--border-active);
}

/* Ensure text on colored backgrounds meets contrast */
.badge {
  font-weight: 600;
  color: var(--text-primary);
}

/* Badge contrast fixes */
.badge-primary {
  background: rgba(124, 58, 237, 0.3);
  color: #E9D5FF;
  border: 1px solid var(--lumavine-secondary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.3);
  color: #A7F3D0;
  border: 1px solid var(--hope-green);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.3);
  color: #FDE68A;
  border: 1px solid var(--warning-amber);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.3);
  color: #FECACA;
  border: 1px solid var(--alert-red);
}

.badge-info {
  background: rgba(0, 212, 255, 0.3);
  color: #A5F3FC;
  border: 1px solid var(--cyan);
}

/* Secondary text on dark backgrounds */
.text-secondary {
  color: #C4D4E8;
}

.text-muted {
  color: #9BADC2;
}

/* Link contrast */
a {
  color: #67D4FF;
}

a:hover {
  color: #9FE5FF;
}

/* Navigation links */
.nav-link {
  color: #C4D4E8;
}

.nav-link:hover,
.nav-link.active {
  color: #FFFFFF;
}

/* Disabled state must still be perceivable */
.btn:disabled,
button:disabled,
[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  color: #9BADC2;
  border-color: rgba(255, 255, 255, 0.2);
}

/* ============================================
   3. FOCUS INDICATORS
   ============================================ */

/* Enhanced focus visible indicators */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--lumavine-secondary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* High contrast focus for buttons */
.btn:focus-visible,
button:focus-visible {
  outline: 3px solid #A855F7;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(168, 85, 247, 0.2);
}

/* Focus for interactive cards */
.card:focus-visible,
.glass-card:focus-visible {
  outline: 3px solid var(--lumavine-secondary);
  outline-offset: 4px;
}

/* Form controls focus */
.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: 3px solid var(--lumavine-secondary);
  outline-offset: 0;
  border-color: var(--lumavine-primary);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
}

/* Checkbox and radio focus */
.checkbox:focus-visible,
.radio:focus-visible {
  outline: 3px solid var(--lumavine-secondary);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.2);
}

/* Link focus */
a:focus-visible {
  outline: 3px solid var(--lumavine-secondary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Navigation links focus */
.nav-link:focus-visible {
  outline: 3px solid var(--lumavine-secondary);
  outline-offset: -3px;
  background: rgba(168, 85, 247, 0.1);
}

/* ============================================
   4. SKIP LINKS
   ============================================ */

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 10000;
  padding: 12px 24px;
  background: var(--lumavine-primary);
  color: white;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 8px 0;
  box-shadow: var(--shadow-lg);
}

.skip-link:focus {
  top: 0;
  outline: 3px solid white;
  outline-offset: -3px;
}

/* ============================================
   5. MODAL ACCESSIBILITY
   ============================================ */

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay[aria-hidden="true"] {
  display: none;
}

/* Modal container */
.modal {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--surface-mid);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-medium);
  padding: var(--space-xl);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  overflow: auto;
}

.modal:focus {
  outline: none;
}

/* Modal close button */
.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: var(--surface-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.modal-close:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* ============================================
   6. ARIA LIVE REGIONS
   ============================================ */

.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;
}

/* Toast notification improvements */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-tooltip);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 400px;
}

.toast {
  background: var(--surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: 44px;
}

.toast-close {
  min-width: 32px;
  min-height: 32px;
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

/* ============================================
   7. LOADING STATES
   ============================================ */

[aria-busy="true"] {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

[aria-busy="true"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--lumavine-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================
   8. RESPONSIVE TOUCH TARGETS
   ============================================ */

@media (max-width: 768px) {
  /* Increase touch targets on mobile */
  .btn,
  button,
  .nav-link,
  a.btn {
    min-height: 48px;
    padding: 12px 20px;
  }

  .btn-icon {
    width: 48px;
    height: 48px;
  }

  /* Increase spacing on mobile */
  .btn + .btn,
  button + button {
    margin-left: 12px;
  }
}

/* ============================================
   9. HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  .btn,
  button,
  .card,
  .glass-card {
    border-width: 2px;
  }

  *:focus-visible {
    outline-width: 4px;
  }

  .text-secondary {
    color: #E5E7EB;
  }
}

/* ============================================
   10. PRINT ACCESSIBILITY
   ============================================ */

@media print {
  .skip-link,
  [aria-hidden="true"],
  .modal-overlay {
    display: none !important;
  }

  *:focus-visible {
    outline: 2px solid black;
  }
}
