/**
 * Estilos de accesibilidad avanzada
 * - Alto contraste
 * - Ajuste de fuente
 * - Toast notifications
 */

/* ============================================
   MODO ALTO CONTRASTE
   ============================================ */
.high-contrast {
  --text-primary: #000000 !important;
  --text-secondary: #1a1a1a !important;
  --bg-primary: #ffffff !important;
  --bg-secondary: #f5f5f5 !important;
  --border-color: #000000 !important;
  --link-color: #0000EE !important;
  --focus-color: #ff6600 !important;
}

.high-contrast body {
  background-color: #ffffff !important;
  color: #000000 !important;
}

.high-contrast a {
  color: #0000EE !important;
  text-decoration: underline !important;
}

/* Excepción: enlaces que son botones (tienen bg-primary, bg-blue-*, etc) */
.high-contrast a[class*="bg-primary"],
.high-contrast a[class*="bg-blue"] {
  background-color: #000000 !important;
  color: #ffffff !important;
  text-decoration: none !important;
  border: 3px solid #000000 !important;
}

.high-contrast a:visited {
  color: #551A8B !important;
}

/* Los enlaces botón visitados mantienen el estilo de botón */
.high-contrast a[class*="bg-primary"]:visited,
.high-contrast a[class*="bg-blue"]:visited {
  background-color: #000000 !important;
  color: #ffffff !important;
}

.high-contrast button,
.high-contrast .btn,
.high-contrast .btn-primary,
.high-contrast .btn-secondary,
.high-contrast [type="submit"] {
  border: 3px solid #000000 !important;
  background-color: #000000 !important;
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  padding: 12px 20px !important;
  white-space: normal !important;
  word-wrap: break-word !important;
  min-height: 44px !important;
}

.high-contrast button:hover,
.high-contrast .btn:hover {
  background-color: #333333 !important;
}

.high-contrast input,
.high-contrast textarea,
.high-contrast select {
  border: 2px solid #000000 !important;
  background-color: #ffffff !important;
  color: #000000 !important;
}

.high-contrast input:focus,
.high-contrast textarea:focus,
.high-contrast select:focus {
  outline: 3px solid #ff6600 !important;
  outline-offset: 2px !important;
}

.high-contrast .card,
.high-contrast .rounded-xl,
.high-contrast [class*="border-slate"] {
  border: 2px solid #000000 !important;
}

.high-contrast img {
  filter: contrast(1.2) !important;
}

.high-contrast header,
.high-contrast footer,
.high-contrast nav {
  background-color: #ffffff !important;
  border-color: #000000 !important;
}

.high-contrast .bg-primary,
.high-contrast .bg-blue-600 {
  background-color: #000000 !important;
}

/* ============================================
   AJUSTE DE TAMAÑO DE FUENTE
   ============================================ */
html.font-size-small {
  font-size: 14px !important;
}

html.font-size-normal {
  font-size: 16px !important;
}

html.font-size-large {
  font-size: 18px !important;
}

html.font-size-xlarge {
  font-size: 20px !important;
}

html.font-size-xxlarge {
  font-size: 24px !important;
}

/* ============================================
   CONTROLES DE ACCESIBILIDAD (TOOLBAR)
   ============================================ */
.a11y-toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e5e7eb;
}

.dark .a11y-toolbar {
  background: rgba(30, 41, 59, 0.9);
  border-color: #475569;
}

.high-contrast .a11y-toolbar {
  background: #ffffff !important;
  border: 2px solid #000000 !important;
}

.a11y-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  border: 1px solid currentColor;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.75rem;
  font-weight: 600;
  color: inherit;
}

.a11y-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.dark .a11y-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.a11y-btn:focus {
  outline: 2px solid #3994ef;
  outline-offset: 2px;
}

.a11y-btn:focus-visible {
  outline: 2px solid #3994ef;
  outline-offset: 2px;
}

.a11y-btn.active {
  background: #3994ef;
  color: white;
  border-color: #3994ef;
}

.a11y-separator {
  width: 1px;
  height: 1.25rem;
  background: #e5e7eb;
  margin: 0 0.125rem;
}

.dark .a11y-separator {
  background: #475569;
}

/* ============================================
   TOAST NOTIFICATIONS ACCESIBLES
   ============================================ */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
  pointer-events: none;
}

#toast-container > * {
  pointer-events: auto;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 0.5rem;
  background: white;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border-left: 4px solid;
  animation: toast-slide-in 0.3s ease-out;
  min-width: 280px;
}

.dark .toast {
  background: #1e293b;
  color: #f1f5f9;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-success {
  border-color: #10b981;
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-error {
  border-color: #ef4444;
}

.toast-error .toast-icon {
  color: #ef4444;
}

.toast-warning {
  border-color: #f59e0b;
}

.toast-warning .toast-icon {
  color: #f59e0b;
}

.toast-info {
  border-color: #3b82f6;
}

.toast-info .toast-icon {
  color: #3b82f6;
}

.toast-content {
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.5;
}

.toast-close {
  margin-left: auto;
  padding: 0.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.6;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.toast-close:hover {
  opacity: 1;
}

.toast-close:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  opacity: 1;
}

/* Reducir movimiento si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}

/* ============================================
   FOCUS MEJORADO PARA CALENDARIO
   ============================================ */
.fc-event:focus {
  outline: 3px solid #3994ef !important;
  outline-offset: 2px !important;
  z-index: 100 !important;
}

.fc-event:focus-visible {
  outline: 3px solid #3994ef !important;
  outline-offset: 2px !important;
}

.fc-daygrid-day:focus-within {
  background-color: rgba(57, 148, 239, 0.1) !important;
}

/* Navegación de calendario por teclado */
.fc .fc-button:focus {
  outline: 2px solid #3994ef !important;
  outline-offset: 2px !important;
}

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

.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}
