/* Estilos específicos para el visor unificado */

/* Botón de limpiar cache */
.clear-cache-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #000;
  color: white;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.clear-cache-btn:hover {
  background: #333;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.clear-cache-btn:active {
  transform: scale(0.95);
}

/* Panel lateral con z-index alto */
.visor-unificado .panel {
  position: relative;
  z-index: 10;
}

/* Visor 3D más grande para el visor unificado */
.visor-unificado .stage {
  height: clamp(600px, 85vh, 90vh) !important;
  min-height: 600px;
}

/* Mantener la distribución de dos columnas como el visor original */
.visor-unificado .hero-grid {
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr) !important;
  gap: 16px;
}

@media (max-width: 1024px) {
  .visor-unificado .hero-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Asegurar que el canvas ocupe todo el espacio */
.visor-unificado #viewer {
  width: 100% !important;
  height: 100% !important;
}

.visor-unificado #viewer canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Controles móviles */
.mobile-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.control-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.control-btn:active {
  transform: scale(0.95);
}

/* Controles de zoom en el medio */
.zoom-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zoom-btn {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

/* Botones de rotación a los costados */
.rotate-btn {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

/* Botón de ayuda más pequeño y menos invasivo */
.visor-unificado .help-fab {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  font-size: 14px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  z-index: 15;
  opacity: 0.8;
}

.visor-unificado .help-fab:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.4);
  opacity: 1;
  transform: scale(1.05);
}

.visor-unificado .help-fab:active {
  transform: scale(0.95);
}

/* Tarjeta de ayuda visible por defecto */
.visor-unificado .help-card {
  position: absolute;
  top: 50px;
  right: 12px;
  max-width: 200px;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: white;
  font-size: 12px;
  line-height: 1.4;
  z-index: 16;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: block !important; /* Visible por defecto */
  opacity: 1;
  transform: translateY(0);
  transition: all 0.3s ease;
}

.visor-unificado .help-card.hidden {
  display: none !important;
}

/* Estado inicial visible */
.visor-unificado #helpCard {
  display: block;
  opacity: 1;
  visibility: visible;
}

/* Estado oculto */
.visor-unificado #helpCard.hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Header de la ayuda */
.visor-unificado .help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.visor-unificado .help-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

/* Botón de cerrar */
.visor-unificado .close-help {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.visor-unificado .close-help:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

/* Contenido de la ayuda */
.visor-unificado .help-content {
  padding: 8px 12px 12px 12px;
}

.visor-unificado .help-content p {
  margin: 4px 0;
  font-size: 11px;
}

/* Carruseles del panel lateral */
.panel-carousels {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-carousels h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  opacity: 0.9;
}

/* Mini carrusel de colecciones */
.mini-collection-selector {
  display: flex;
  flex-direction: column;
}

.mini-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.mini-carousel::-webkit-scrollbar {
  display: none;
}

.mini-collection-item {
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.mini-collection-item:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

.mini-collection-item.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.2);
}

/* Carrusel de personajes */
.characters-carousel {
  display: flex;
  flex-direction: column;
}

.characters-carousel .carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.characters-carousel .carousel::-webkit-scrollbar {
  display: none;
}

.character-item {
  flex: 0 0 auto;
  width: 120px;
  height: 80px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.character-item:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.character-item.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.2);
}

.character-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.character-name {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 4px;
  text-align: center;
}

/* Carrusel de variantes */
.variants-carousel {
  display: flex;
  flex-direction: column;
}

.variants-carousel .carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.variants-carousel .carousel::-webkit-scrollbar {
  display: none;
}

.variant-item {
  flex: 0 0 auto;
  width: 80px;
  height: 60px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.variant-item:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.variant-item.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.2);
}

.variant-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.variant-label {
  position: absolute;
  bottom: 2px;
  left: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 2px;
  border-radius: 2px;
  text-align: center;
}

/* Tarjetas de producto mejoradas */
.product-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.product-card:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.product-card .thumb {
  transition: transform 0.3s ease;
}

.product-card:hover .thumb {
  transform: scale(1.05);
}

/* Loader mejorado */
.loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.loader .card {
  background: rgba(255, 255, 255, 0.1);
  padding: 32px;
  border-radius: 16px;
  text-align: center;
  min-width: 280px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.loader .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

.loader .progress {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  margin: 12px 0;
}

.loader .bar {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Help card mejorado */
.help-card {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 16px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 280px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.help-card.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.help-card h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
}

.help-card p {
  margin: 4px 0;
  line-height: 1.4;
}

/* Scroll shield para móviles */
.scroll-shield {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  pointer-events: none;
  background: transparent;
}

/* Responsive para móviles */
@media (max-width: 768px) {
  .mobile-controls {
    bottom: 16px;
    gap: 10px;
  }
  
  .control-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
  
  .zoom-btn {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }
  
  .rotate-btn {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }
  
  /* Asegurar que el canvas no capture eventos en móvil */
  .visor-unificado #viewer canvas {
    pointer-events: none;
  }
  
  .help-card {
    top: 16px;
    right: 16px;
    max-width: 240px;
    font-size: 13px;
  }
  
  .product-card {
    margin-right: 12px;
  }
}

/* Animaciones de entrada */
.product-card {
  animation: fadeInUp 0.6s ease forwards;
  opacity: 0;
  transform: translateY(20px);
}

.product-card:nth-child(1) { animation-delay: 0.1s; }
.product-card:nth-child(2) { animation-delay: 0.2s; }
.product-card:nth-child(3) { animation-delay: 0.3s; }
.product-card:nth-child(4) { animation-delay: 0.4s; }
.product-card:nth-child(5) { animation-delay: 0.5s; }
.product-card:nth-child(6) { animation-delay: 0.6s; }

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

/* Estados de carga */
.loading {
  pointer-events: none;
  opacity: 0.7;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Mejoras para el visor 3D */
#viewer {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

#viewer canvas {
  border-radius: 12px;
}

/* Badges de producto */
.badges {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.badge {
  background: rgba(79, 70, 229, 0.2);
  color: #a5b4fc;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(79, 70, 229, 0.3);
}

/* Chips de categoría */
.chips {
  display: flex;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.chip {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
