/* ==========================================================================
   Accessibility Improvements
   - Mejorando contrastes y la experiencia de usuarios con problemas de accesibilidad
   ========================================================================== */

/* Importar variables globales si no están ya importadas */
@import url('theme-vars.css');

/* Mejora de contraste para enlaces */
a:focus {
  outline: 3px solid var(--clr-accent) !important;
  outline-offset: 2px !important;
  text-decoration: underline !important;
}

/* Skip link para navegación por teclado */
.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  padding: var(--spacing-xs) var(--spacing-sm);
  background-color: var(--clr-accent);
  color: var(--text-light);
  border-bottom-right-radius: var(--border-radius-md);
  font-weight: bold;
  z-index: 9999;
  text-decoration: none;
  transition: background-color var(--transition-normal);
}

/* Estilos para mejorar el contraste en textos y fondos */
.high-contrast {
  background-color: var(--background-light);
  color: var(--text-dark);
  --clr-primary: #d00; /* Rojo más oscuro para mejor contraste */
  --clr-secondary: #003380; /* Azul más oscuro para mejor contraste */
}

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

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

.high-contrast .text-light {
  color: var(--text-dark) !important;
}

/* Mejorar visibilidad de elementos interactivos */
button:focus,
input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 3px var(--clr-accent) !important;
  outline: none !important;
  transition: box-shadow var(--transition-fast);
}

/* Botones y controles más grandes en móvil para mejor "tap target" */
@media (max-width: 768px) {
  button, 
  input[type="button"],
  input[type="submit"],
  .tap-target {
    min-height: 44px;
    min-width: 44px;
    border-radius: var(--border-radius-md);
  }
  
  .navbar-movil a,
  .tap-target {
    padding: var(--spacing-xs);
  }
  
  /* Aumentar espaciado entre elementos interactivos */
  .navbar-movil li {
    margin-bottom: var(--spacing-xs);
  }
  
  /* Mejorar tamaño de texto para legibilidad */
  .navbar-movil a {
    font-size: 1.1rem;
    padding: var(--spacing-sm);
  }
}

/* Soporte para modo dark */
@media (prefers-color-scheme: dark) {
  :root {
    --clr-accent: #ff4b41; /* Rojo más brillante para dark mode */
    --background-light: #ffffff;
    --text-dark: #000000;
    --text-muted: #aaaaaa;
    --clr-dark: #000000;
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  }
  
  body {
    background-color: var(--background-light);
    color: var(--text-dark);
  }
  
  .card, .product-card {
    background-color: #ffffff;
    border-color: #333333;
  }
  
  .highlight-contrast {
    color: #ffffff !important;
    background-color: rgba(0, 0, 0, 0.75) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
  }
  
  /* Asegurar que los textos oscuros sean legibles en modo dark */
  .text-dark {
    color: var(--text-dark) !important;
  }
  
  /* Ajustar el contraste de los botones */
  .btn-outline {
    border-color: var(--clr-accent);
    color: var(--clr-accent);
  }
}

/* Ajustes de tamaño de fuente para diferentes dispositivos */
@media screen and (max-width: 480px) {
  html {
    font-size: 16px; /* Base para móviles */
    --spacing-xs: 0.4rem;
    --spacing-sm: 0.8rem;
    --spacing-md: 1.2rem;
  }
}

@media screen and (min-width: 481px) and (max-width: 768px) {
  html {
    font-size: 17px; /* Base para tablets */
  }
}

@media screen and (min-width: 769px) {
  html {
    font-size: 18px; /* Base para desktop */
  }
}

/* Mejoras para prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0.01ms;
    --transition-normal: 0.01ms;
    --transition-slow: 0.01ms;
  }
  
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  
  /* Eliminar animaciones de hover */
  .btn:hover, .btn-primary:hover, .btn-outline:hover,
  a:hover, .card:hover, .product-card:hover {
    transform: none !important;
    box-shadow: none !important;
  }
}

/* ==========================================================================
   Mejoras de Accesibilidad - WCAG 2.1 AA
   Mejoras específicas para cumplir con las pautas de accesibilidad web
   ========================================================================== */

/* ===== SKIP LINKS Y NAVEGACIÓN ===== */

/* Skip link para saltar al contenido principal */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: bold;
  z-index: 10000;
  border-radius: 0 0 4px 4px;
  transition: top 0.3s ease;
}

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

/* ===== FOCO VISIBLE MEJORADO ===== */

/* Foco visible para todos los elementos interactivos */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.btn:focus-visible,
.faq-question:focus-visible {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
  box-shadow: 0 0 0 1px #fff, 0 0 0 4px #0066cc;
}

/* Foco específico para elementos de navegación */
.navbar a:focus-visible,
.navbar-movil a:focus-visible {
  outline: 3px solid #ffd700;
  outline-offset: 2px;
  background: rgba(255, 215, 0, 0.1);
}

/* ===== CONTRASTE MEJORADO ===== */

/* Asegurar contraste mínimo 4.5:1 para texto normal */
.high-contrast {
  background: #000;
  color: #fff;
}

.high-contrast a {
  color: #87ceeb;
}

.high-contrast a:hover,
.high-contrast a:focus {
  color: #add8e6;
}

/* Texto sobre imágenes con fondo semitransparente */
.text-overlay {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 0.5rem;
  border-radius: 4px;
}

/* ===== ELEMENTOS DE FORMULARIO ACCESIBLES ===== */

/* Labels visualmente ocultos pero accesibles para lectores de pantalla */
.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;
}

/* Mostrar labels ocultos al recibir foco */
.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 0.25rem 0.5rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: #000;
  color: #fff;
  border: 2px solid #ffd700;
}

/* Campos de formulario con mejor contraste */
input,
select,
textarea {
  border: 2px solid #666;
  background: #fff;
  color: #000;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
}

/* Estados de error claramente visibles */
.error {
  border-color: #d32f2f !important;
  background: #fff5f5;
}

.error-message {
  color: #d32f2f;
  font-weight: bold;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-message::before {
  content: "⚠";
  font-size: 1.2em;
}

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

/* Indicadores visuales para navegación por teclado */
.keyboard-navigation .navbar li:focus-within > a,
.keyboard-navigation .menu-item:focus-within {
  background: rgba(0, 102, 204, 0.1);
  outline: 2px solid #0066cc;
}

/* Menús desplegables accesibles por teclado */
.navbar ul ul {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.navbar li:hover > ul,
.navbar li:focus-within > ul {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ===== BOTONES Y ENLACES ACCESIBLES ===== */

/* Área de clic mínima de 44x44px */
.btn,
.btn-cta,
.btn-ver-mas,
button {
  min-height: 44px;
  min-width: 44px;
  padding: 0.75rem 1.5rem;
}

/* Estados de botón claramente diferenciados */
.btn:disabled,
button:disabled {
  background: #ccc;
  color: #666;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn:disabled:focus {
  outline: 3px solid #666;
}

/* ===== CONTENIDO MULTIMEDIA ACCESIBLE ===== */

/* Controles de video/audio accesibles */
.media-controls {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 4px;
}

.media-controls button {
  background: transparent;
  border: 2px solid #fff;
  color: #fff;
  padding: 0.5rem;
  border-radius: 4px;
  min-width: 44px;
  min-height: 44px;
}

.media-controls button:hover,
.media-controls button:focus {
  background: rgba(255, 255, 255, 0.2);
}

/* ===== TABLAS ACCESIBLES ===== */

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border: 1px solid #666;
  padding: 0.75rem;
  text-align: left;
}

th {
  background: #f5f5f5;
  font-weight: bold;
}

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

/* Indicadores visuales para estados (no solo color) */
.status-success::before {
  content: "✓ ";
  color: #4caf50;
  font-weight: bold;
}

.status-error::before {
  content: "✗ ";
  color: #f44336;
  font-weight: bold;
}

.status-warning::before {
  content: "⚠ ";
  color: #ff9800;
  font-weight: bold;
}

/* ===== ANIMACIONES RESPETANDO PREFERENCIAS ===== */

/* Respetar preferencias 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-smooth {
    scroll-behavior: auto !important;
  }
}

/* ===== MEJORAS PARA LECTORES DE PANTALLA ===== */

/* Texto explicativo para iconos */
.icon-text {
  display: inline-block;
  margin-left: 0.25rem;
}

/* Ocultar elementos decorativos de lectores de pantalla */
.decorative {
  aria-hidden: true;
}

/* ===== MODO ALTO CONTRASTE ===== */

/* Modo alto contraste activable */
.high-contrast-mode {
  background: #000 !important;
  color: #fff !important;
}

.high-contrast-mode a {
  color: #00ff00 !important;
}

.high-contrast-mode a:hover,
.high-contrast-mode a:focus {
  color: #ffff00 !important;
}

.high-contrast-mode .btn {
  background: #fff !important;
  color: #000 !important;
  border: 2px solid #fff !important;
}

.high-contrast-mode .btn:hover,
.high-contrast-mode .btn:focus {
  background: #ffff00 !important;
  color: #000 !important;
}

/* ===== RESPONSIVE PARA ACCESIBILIDAD ===== */

@media (max-width: 768px) {
  /* Aumentar áreas de toque en móvil */
  .btn,
  .btn-cta,
  .btn-ver-mas,
  button,
  a {
    min-height: 48px;
    padding: 0.875rem 1rem;
  }
  
  /* Mejorar espaciado para navegación táctil */
  .navbar-movil a {
    padding: 1rem;
    margin: 0.25rem 0;
  }
}

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

.loading {
  position: relative;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #ccc;
  border-top: 2px solid #0066cc;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Texto alternativo para el indicador de carga */
.loading-text {
  position: absolute;
  left: -9999px;
}

/* ===== MEJORAS PARA USUARIOS CON DISCAPACIDADES MOTORAS ===== */

/* Tiempo extendido para hover/focus */
.extended-hover:hover,
.extended-hover:focus {
  transition-delay: 0.5s;
}

/* Botones más grandes para facilitar el clic */
.large-click-area {
  padding: 1rem 2rem;
  min-width: 60px;
  min-height: 60px;
}

/* ===== NOTIFICACIONES ACCESIBLES ===== */

.notification {
  background: #f5f5f5;
  border: 2px solid #0066cc;
  border-radius: 4px;
  padding: 1rem;
  margin: 1rem 0;
  position: relative;
}

.notification.success {
  border-color: #4caf50;
  background: #e8f5e8;
}

.notification.error {
  border-color: #f44336;
  background: #ffeaea;
}

.notification.warning {
  border-color: #ff9800;
  background: #fff3e0;
}

/* ===== TOGGLE PARA MODO ACCESIBLE ===== */

.accessibility-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  background: #0066cc;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.accessibility-toggle:hover,
.accessibility-toggle:focus {
  background: #0052a3;
  outline: 3px solid #ffd700;
}

/* ===== MEJORAS ESPECÍFICAS PARA FAQ ===== */

.faq-question[aria-expanded="true"] {
  background: #e3f2fd;
}

.faq-answer[aria-hidden="true"] {
  display: none;
}

.faq-answer[aria-hidden="false"] {
  display: block;
}

/* ===== BREADCRUMBS ACCESIBLES ===== */

.breadcrumb-nav {
  background: #f8f9fa;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e9ecef;
}

.breadcrumb {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  margin: 0 0.5rem;
  color: #6c757d;
}

.breadcrumb-item.active {
  color: #6c757d;
}

.breadcrumb-item a:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}
