/* ================================
   Viewer 3D pour le Moodbag
   ================================ */

.viewer-3d {
  width: 100%;
  height: 100%;
  min-height: 500px;
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.viewer-3d canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
}

/* Loader du modèle 3D */
.model-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  z-index: 10;
  transition: opacity 0.3s ease;
}

.loader-content {
  text-align: center;
  padding: 2rem;
}

.spinner {
  width: 60px;
  height: 60px;
  margin: 0 auto 1.5rem;
  border: 4px solid var(--glass-border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loader-text {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.progress-bar {
  width: 200px;
  height: 6px;
  background: var(--glass-border);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  transition: width 0.3s ease;
  width: 0%;
}

/* Contrôles du viewer */
.viewer-controls {
  margin-top: var(--spacing-sm);
  padding: var(--spacing-sm);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  justify-content: center;
}

.control-btn {
  padding: 0.5rem 1rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-btn:hover {
  background: var(--glass-border);
  transform: translateY(-2px);
}

.control-btn:active {
  transform: translateY(0);
}

.control-hint {
  flex: 1 1 100%;
  text-align: center;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
}

/* Sélecteur de couleurs amélioré */
.color-selector {
  position: relative;
}

.color-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: var(--spacing-sm);
}

.color-option {
  width: 100%;
  height: 60px;
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.color-option::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  transition: transform var(--transition-fast);
}

.color-option:hover::before {
  transform: scale(1.1);
}

.color-option:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.color-option.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--glass-bg), 0 8px 20px rgba(0, 0, 0, 0.2);
}

.color-check {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.color-option.active .color-check {
  opacity: 1;
}

/* Message d'erreur */
.model-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
}

/* Animation du viewer au chargement */
.main-image {
  animation: fadeInScale 0.6s ease-out;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Badge "3D interactif" */
.viewer-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: var(--gradient-primary);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 968px) {
  .viewer-3d {
    min-height: 400px;
  }

  .color-options {
    grid-template-columns: repeat(3, 1fr);
  }

  .viewer-controls {
    flex-direction: column;
  }

  .control-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .viewer-3d {
    min-height: 350px;
  }

  .color-option {
    height: 50px;
  }
}

/* Optimisation pour les performances */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }

  .color-option::before {
    transition: none;
  }
}

/* ================================
   Viewer 3D pour page d'accueil
   ================================ */

.viewer-3d-home {
  width: 100%;
  height: 100%;
  min-height: 400px;
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.viewer-3d-home canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  cursor: grab;
}

.viewer-3d-home canvas:active {
  cursor: grabbing;
}

/* Loader pour page d'accueil (simplifié) */
#model-loader-home {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  z-index: 10;
  transition: opacity 0.3s ease;
}

#model-loader-home .loader-content {
  text-align: center;
}

#model-loader-home .spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 1rem;
}

/* Adapter le hero-image pour le 3D */
.hero-image .product-preview {
  position: relative;
  height: 100%;
  min-height: 450px;
}

/* Responsive pour page d'accueil */
@media (max-width: 968px) {
  .viewer-3d-home {
    min-height: 350px;
  }

  .hero-image .product-preview {
    min-height: 350px;
  }
}

@media (max-width: 640px) {
  .viewer-3d-home {
    min-height: 300px;
  }

  .hero-image .product-preview {
    min-height: 300px;
  }
}

