/*
 * Estilos mejorados para BCN Document History
 * Con mejoras de accesibilidad y mejores prácticas CSS
 */

/* Clase para elementos visibles solo por lectores de pantalla */
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.bcn-historic-toggle {
  position: relative;
  margin: 0;
  padding: 0;
  text-align: left;
}

/* Estilo para el botón */
.bcn-toggle-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  background-color: white;
  color: #e74c3c;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Raveo Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  line-height: 1.5;
}
  
  /* Icono del botón (flecha) */
  .bcn-toggle-btn::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid currentColor;
    margin-left: 8px;
    transition: transform 0.3s ease;
  }
  
  /* Cuando el contenedor está abierto, rotamos la flecha */
  .bcn-historic-toggle.is-open .bcn-toggle-btn::after {
    transform: rotate(180deg);
  }
  
/* Efectos hover para el botón */
.bcn-toggle-btn:hover {
  background-color: #e74c3c;
  color: white;
}

/* Estados de focus mejorados para accesibilidad */
.bcn-toggle-btn:focus {
  background-color: #e74c3c;
  color: white;
  outline: 3px solid #e74c3c;
  outline-offset: 2px;
  border-color: transparent;
}

/* Eliminar outline en navegadores que soportan :focus-visible */
.bcn-toggle-btn:focus:not(:focus-visible) {
  outline: none;
}

/* Estado deshabilitado */
.bcn-toggle-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
  
  /* Contenedor de documentos históricos */
  .bcn-historic-container {
    margin-top: 12px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #e74c3c;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: left;
  }
  
  /* Estilo para la lista de documentos */
  .bcn-historic-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  /* Cada elemento de la lista */
  .bcn-historic-item {
    margin-bottom: 10px;
    position: relative;
    padding-left: 24px;
  }
  
  .bcn-historic-item:last-child {
    margin-bottom: 0;
  }
  
  /* Icono para cada elemento (usando pseudo-elemento) */
  .bcn-historic-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23e74c3c'%3E%3Cpath d='M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
  }
  
/* Enlaces a documentos históricos */
.bcn-historic-link {
  color: #333;
  text-decoration: none;
  font-family: 'Raveo Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  transition: color 0.2s ease;
  display: block;
  padding: 4px 0;
  border-radius: 2px;
}

.bcn-historic-link:hover {
  color: #e74c3c;
  text-decoration: underline;
}

/* Focus visible para enlaces (accesibilidad de teclado) */
.bcn-historic-link:focus {
  color: #e74c3c;
  outline: 2px solid #e74c3c;
  outline-offset: 2px;
  text-decoration: underline;
}

.bcn-historic-link:focus:not(:focus-visible) {
  outline: none;
}
  
/* Etiqueta de "Històric" */
.bcn-historic-toggle::before {
  content: 'Històric';
  position: absolute;
  top: 40px;
  left: 0;
  background-color: #000;
  color: #FFF;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
  font-family: 'Geist Mono', 'Courier New', monospace;
  pointer-events: none; /* No interferir con clics */
}

/* Mostrar etiqueta cuando el toggle está abierto */
.bcn-historic-toggle.is-open::before {
  opacity: 1;
}
  
/* Mensaje de carga y errores */
.bcn-historic-container p {
  color: #666;
  font-style: italic;
  margin: 0;
  padding: 0;
}

/* Mejoras de contraste para accesibilidad (WCAG AA) */
@media (prefers-contrast: high) {
  .bcn-toggle-btn {
    border-width: 2px;
    border-color: currentColor;
  }

  .bcn-historic-link:focus {
    outline-width: 3px;
  }
}

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .bcn-toggle-btn,
  .bcn-historic-link,
  .bcn-toggle-btn::after,
  .bcn-historic-toggle::before {
    transition: none;
    animation: none;
  }
}

/* Adaptaciones responsivas */
@media (max-width: 768px) {
  .bcn-historic-toggle {
    text-align: left;
  }

  .bcn-toggle-btn {
    width: 100%;
    justify-content: space-between;
    font-size: 16px; /* Prevenir zoom en iOS */
  }

  .bcn-historic-toggle::before {
    right: auto;
    left: 15px;
  }

  .bcn-historic-container {
    padding: 12px;
  }
}

/* Soporte para modo oscuro */
@media (prefers-color-scheme: dark) {
  .bcn-historic-container {
    background-color: #2a2a2a;
    color: #e0e0e0;
  }

  .bcn-historic-link {
    color: #e0e0e0;
  }

  .bcn-historic-link:hover,
  .bcn-historic-link:focus {
    color: #ff6b5a;
  }

  .bcn-historic-container p {
    color: #aaa;
  }
}
