/* =====================================
   ACCESIBILIDAD.CSS - Elementos de accesibilidad unificados
   ===================================== */

/* ============================
   ELEMENTOS OCULTOS PARA LECTORES DE PANTALLA
   ============================ */

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sr-only:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: inherit !important;
  margin: inherit !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: inherit !important;
}

/* ============================
   SKIP LINKS - ENLACE DE SALTO
   ============================ */

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
  z-index: 1000;
  border-radius: 0 0 4px 4px;
  transition: top 0.2s ease;
  font-weight: bold;
}

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

/* ============================
   INDICADORES DE FOCO MEJORADOS
   ============================ */

/* Foco general mejorado */
*:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--focus-outline, #4a90e2);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Foco específico para botones */
button:focus,
.boton-1:focus,
.menu-toggle:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.25);
}

/* Foco para elementos interactivos del navbar */
.nav-buttons a:focus,
.nav-buttons button:focus {
  background: var(--hover-bg);
  color: var(--link-hover-fg);
  outline: 3px solid var(--focus-outline);
  outline-offset: 2px;
}

/* Foco para buscador */
.search-toggle-btn:focus {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
  border-radius: 4px;
}

.search-input:focus {
  border-color: var(--focus-outline);
  outline: 2px solid var(--focus-outline);
  outline-offset: -2px;
}

/* Foco mejorado para carrusel */
.carrusel-btn:focus-visible {
  outline: 3px solid #f89b29;
  outline-offset: 3px;
}

.carrusel-wrapper .carrusel-indicators .carrusel-indicator:focus-visible,
.carrusel-indicators .carrusel-indicator:focus-visible,
#indicators .carrusel-indicator:focus-visible,
button.carrusel-indicator:focus-visible {
  outline: 2px solid #f89b29 !important;
  outline-offset: 4px !important;
}

/* ============================
   FOCO EN MODO OSCURO
   ============================ */

[data-bs-theme="oscuro"] *:focus {
  outline-color: #66b3ff;
}

[data-bs-theme="oscuro"] button:focus,
[data-bs-theme="oscuro"] .boton-1:focus,
[data-bs-theme="oscuro"] .menu-toggle:focus {
  outline-color: #66b3ff;
  box-shadow: 0 0 0 4px rgba(102, 179, 255, 0.25);
}

[data-bs-theme="oscuro"] .nav-buttons a:focus,
[data-bs-theme="oscuro"] .nav-buttons button:focus {
  outline-color: var(--focus-outline);
}

/* ============================
   HAMBURGUESA - ACCESIBILIDAD
   ============================ */

.menu-toggle:focus {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
  border-radius: 4px;
}

.menu-toggle[aria-expanded="true"]::after {
  content: "";
  position: absolute;
  inset: -10px;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.3s ease;
}

.menu-toggle[aria-expanded="true"]:focus::after {
  border-color: var(--focus-outline);
}

/* ============================
   ELEMENTOS INTERACTIVOS - TAMAÑO MÍNIMO
   ============================ */

button,
[role="button"],
input,
select,
textarea {
  min-height: 44px; /* Tamaño mínimo táctil recomendado */
  min-width: 44px;
}

/* ============================
   ELEMENTOS EXPANDIBLES - ARIA
   ============================ */

[aria-expanded="true"]::after {
  content: " (expandido)";
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ============================
   CONTENIDO PRINCIPAL - FOCO
   ============================ */

main[tabindex="-1"]:focus {
  outline: none;
}

/* ============================
   INDICADORES DE CARGA ACCESIBLES
   ============================ */

.preloader[role="status"] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.search-loading {
  display: none;
  color: #666;
  font-style: italic;
  padding: 10px 16px;
}

/* ============================
   ENLACES MEJORADOS
   ============================ */

a {
  text-decoration: underline;
}

a:hover,
a:focus {
  text-decoration: none;
  background-color: rgba(0, 102, 204, 0.1);
  border-radius: 2px;
}

/* ============================
   ELEMENTOS DE BÚSQUEDA ACTIVOS
   ============================ */

.elemento-de-busqueda.activo {
  background-color: var(--hover-bg);
  color: var(--link-hover-fg);
  border-left: 3px solid var(--focus-outline);
}

/* ============================
   CONTRASTE Y ESTADOS VISUALES
   ============================ */

.nav-buttons.loading {
  opacity: 0.6;
  pointer-events: none;
}

.slide.error img {
  filter: grayscale(100%);
  opacity: 0.5;
}

/* ============================
   ANIMACIONES Y MOVIMIENTO REDUCIDO
   ============================ */

/* Preferencia de movimiento reducido */
@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;
  }
  
  /* Mantener funcionalidad esencial */
  .preloader,
  .carrusel-track {
    transition-duration: 0.3s !important;
  }

  /* Desactivar animaciones específicas */
  .menu-toggle,
  .hamburger-line,
  .nav-buttons,
  .dropdown-menu {
    transition: none !important;
    animation: none !important;
  }
  
  .nav-buttons.show li {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .titulo-acordeon,
  .bloque,
  .contenido-acordeon a {
    transition: none !important;
  }
  
  .titulo-acordeon:hover {
    transform: none !important;
  }
  
  .contenido-acordeon a:hover {
    transform: none !important;
  }

  /* Keyframes para movimiento reducido */
  @keyframes slideDown {
    from, to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes fadeInUp {
    from, to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* ============================
   NAVEGACIÓN POR TECLADO MEJORADA
   ============================ */

/* Estados de navegación para dropdown */
.dropdown-menu {
  transition: all 0.3s ease;
}

/* Focus trap helper */
.focus-trap {
  outline: none;
}

/* ============================
   INDICADORES DE ESTADO VISUAL
   ============================ */

/* Estados de carga */
.carrusel-slides.loading {
  opacity: 0.6;
}

/* Estados de error */
.no-results {
  display: none;
  color: #999;
  padding: 10px;
  text-align: center;
}

/* ============================
   MEJORAS DE CONTRASTE
   ============================ */

/* Asegurar contraste en enlaces del footer */
footer p a {
  text-decoration: underline;
}

/* Contraste mejorado para tooltips */
.wrapper .tooltip {
  box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1);
  font-weight: 500;
}

/* ============================
   ÁREA TÁCTIL AMPLIADA
   ============================ */

/* Área táctil para indicadores del carrusel */
.carrusel-wrapper .carrusel-indicators .carrusel-indicator::before,
.carrusel-indicators .carrusel-indicator::before,
#indicators .carrusel-indicator::before,
button.carrusel-indicator::before {
  content: '' !important;
  position: absolute !important;
  top: -20px !important;
  left: -20px !important;
  right: -20px !important;
  bottom: -20px !important;
  border-radius: 50% !important;
  z-index: 1 !important;
}

/* Área táctil para desktop */
@media (min-width: 769px) {
  .carrusel-wrapper .carrusel-indicators .carrusel-indicator::before,
  .carrusel-indicators .carrusel-indicator::before,
  #indicators .carrusel-indicator::before,
  button.carrusel-indicator::before {
    top: -1vw !important;
    left: -1vw !important;
    right: -1vw !important;
    bottom: -1vw !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }
}

/* ============================
   SCROLL BEHAVIOR MEJORADO
   ============================ */

.search-results-list {
  scroll-behavior: smooth;
}

/* ============================
   ESTADOS DE INTERACCIÓN VISUAL
   ============================ */

/* Feedback visual para elementos activos */
.slide:active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

/* Estados activos mejorados */
.menu-toggle:active {
  transform: translateY(-50%) scale(0.95);
}

/* ============================
   ARIA LABELS Y LIVE REGIONS
   ============================ */

/* Preparar para live regions */
[aria-live] {
  position: relative;
}

/* Preparar para aria-describedby */
[aria-describedby] {
  position: relative;
}

/* ============================
   COLOR SCHEME SUPPORT
   ============================ */

html {
  color-scheme: light dark;
}
/* ============================
   FALLBACK GOOGLE MAPS - NAVEGADORES CON BLOQUEO
   ============================ */

.map-fallback {
    width: 100%;
    min-height: 450px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.map-fallback-content {
    text-align: center;
    max-width: 600px;
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.map-fallback-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    color: #f89b29;
    display: block;
}

.map-fallback-content h3 {
    color: #333;
    font-size: 1.75rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.map-fallback-content p {
    color: #555;
    margin: 0.75rem 0;
    font-size: 1rem;
    line-height: 1.6;
}

.map-fallback-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.map-fallback-button {
    display: inline-block;
    padding: 0.875rem 1.75rem;
    background: #f89b29;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 44px;
    line-height: 1.5;
}

.map-fallback-button:hover,
.map-fallback-button:focus {
    background: #e08515;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(248, 155, 41, 0.3);
    text-decoration: none;
}

.map-fallback-button.secondary {
    background: #6c757d;
}

.map-fallback-button.secondary:hover,
.map-fallback-button.secondary:focus {
    background: #5a6268;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.map-fallback-notice {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #dee2e6;
}

.map-fallback-notice small {
    color: #6c757d;
    font-size: 0.875rem;
    font-style: italic;
}

/* Modo oscuro para fallback */
[data-bs-theme="oscuro"] .map-fallback {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
}

[data-bs-theme="oscuro"] .map-fallback-content {
    background: #1e2a38;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="oscuro"] .map-fallback-content h3 {
    color: #e0e0e0;
}

[data-bs-theme="oscuro"] .map-fallback-content p {
    color: #b0b0b0;
}

[data-bs-theme="oscuro"] .map-fallback-notice small {
    color: #8a8a8a;
}

/* Responsive para fallback */
@media (max-width: 768px) {
    .map-fallback {
        min-height: 400px;
        padding: 1rem;
    }
    
    .map-fallback-content {
        padding: 1.5rem;
    }
    
    .map-fallback-icon {
        width: 48px;
        height: 48px;
    }
    
    .map-fallback-content h3 {
        font-size: 1.5rem;
    }
    
    .map-fallback-actions {
        flex-direction: column;
    }
    
    .map-fallback-button {
        width: 100%;
    }
}

/* Animación de entrada */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.map-fallback-content {
    animation: fadeInScale 0.4s ease-out;
}

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .map-fallback-content {
        animation: none;
    }
    
    .map-fallback-button:hover,
    .map-fallback-button:focus {
        transform: none;
    }
}
/* ============================
   CORRECCIONES DE COMPATIBILIDAD CROSS-BROWSER
   ============================ */

/* Fix para backdrop-filter en navegadores sin soporte */
@supports not (backdrop-filter: blur(10px)) {
  .curso-card,
  .program-card,
  .gallery-frame,
  .sidebar-navigation,
  .search-results-list {
    background: rgba(255, 255, 255, 0.95) !important;
  }
  
  [data-bs-theme="oscuro"] .curso-card,
  [data-bs-theme="oscuro"] .program-card,
  [data-bs-theme="oscuro"] .gallery-frame,
  [data-bs-theme="oscuro"] .sidebar-navigation,
  [data-bs-theme="oscuro"] .search-results-list {
    background: rgba(15, 23, 42, 0.95) !important;
  }
}

/* Fix para transform en Samsung Internet */
.samsung-internet * {
  -webkit-backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  -webkit-perspective: 1000;
}

/* Fix para sticky en UC Browser */
.uc-browser [style*="position: sticky"],
.uc-browser [style*="position:sticky"] {
  position: relative !important;
}

/* Fix para flexbox en IE11 */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  .nav-buttons,
  .cursos-container,
  .programs-grid,
  .card-tags {
    display: -ms-flexbox;
  }
}

/* Fix para grid en navegadores antiguos */
@supports not (display: grid) {
  .cursos-container,
  .programs-grid,
  .virtual-gallery {
    display: flex;
    flex-wrap: wrap;
  }
  
  .curso-card,
  .program-card,
  .gallery-frame {
    flex: 1 1 300px;
    margin: 1rem;
  }
}

/* Fix para object-fit en IE11 y Edge antiguo */
@supports not (object-fit: cover) {
  .logo,
  .hero-illustration,
  .card-illustration img {
    width: 100%;
    height: auto;
  }
}

/* Fix para smooth scroll en navegadores sin soporte */
@supports not (scroll-behavior: smooth) {
  html {
    scroll-behavior: auto !important;
  }
}

/* Fix para CSS custom properties en IE11 */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  :root {
    --office-primary: #2563eb;
    --office-secondary: #3b82f6;
    --sidebar-bg: #ffffff;
    --text-primary: #1a1a1a;
  }
  
  body {
    color: #1a1a1a;
  }
  
  .sidebar-navigation {
    background-color: #ffffff;
  }
}

/* ============================
   CORRECCIONES DE ACCESIBILIDAD ADICIONALES
   ============================ */

/* Asegurar contraste mínimo 4.5:1 en todos los estados */
[data-bs-theme="oscuro"] .nav-buttons a,
[data-bs-theme="oscuro"] .nav-buttons button {
  color: #F8FAFC !important;
  font-weight: 500;
}

[data-bs-theme="oscuro"] .dropdown-menu li a,
[data-bs-theme="oscuro"] .dropdown-menu li button {
  color: #F8FAFC !important;
}

[data-bs-theme="oscuro"] .sidebar-nav-link,
[data-bs-theme="oscuro"] .sidebar-submenu-link {
  color: #F8FAFC !important;
}

/* Asegurar área táctil mínima de 44x44px */
.nav-buttons a,
.nav-buttons button,
.dropdown-menu li a,
.dropdown-menu li button,
.sidebar-nav-link,
.sidebar-submenu-link,
.search-toggle-btn,
.search-submit-btn,
.theme-toggle {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Focus visible mejorado para todos los elementos interactivos */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid var(--focus-outline, #60A5FA) !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}

[data-bs-theme="oscuro"] button:focus-visible,
[data-bs-theme="oscuro"] a:focus-visible,
[data-bs-theme="oscuro"] input:focus-visible,
[data-bs-theme="oscuro"] select:focus-visible,
[data-bs-theme="oscuro"] textarea:focus-visible,
[data-bs-theme="oscuro"] [role="button"]:focus-visible {
  outline-color: #93C5FD !important;
}

/* ============================
   FALLBACK PARA ANIMACIONES EN NAVEGADORES ANTIGUOS
   ============================ */

@supports not (animation: fadeIn 0.3s ease) {
  .curso-card,
  .program-card,
  .slide {
    opacity: 1 !important;
    transform: none !important;
  }
}