/* ═══════════════════════════════════════════════════════════════════════════
   3D CUBE LOADER - Light Theme
   Positioned within main-container (covers viewer + controls)
   ═══════════════════════════════════════════════════════════════════════════ */

#loader {
  position: absolute !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
  background: #ffffff !important;
  display: flex;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999 !important;
  gap: 40px;
  opacity: 1;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loader.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Hide main loader when build overlay is showing */
body:has(#buildLoadingOverlay.active) #loader {
  display: none !important;
}

#loader[style*="display: none"],
#loader[style*="display:none"] {
  display: none !important;
}

/* ─── 3D Cube ─────────────────────────────────────────────────────────────── */

#loader .cube-container {
  width: 80px;
  height: 80px;
  perspective: 800px;
  position: relative;
}

/* Contact shadow under the cube */
#loader .cube-container::after {
  content: '';
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  height: 60px;
  background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.3) 0%, transparent 70%);
  border-radius: 50%;
  animation: shadow-pulse 2s infinite ease-in-out;
}

@keyframes shadow-pulse {

  0%,
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }

  50% {
    transform: translateX(-50%) scale(0.6);
    opacity: 0.4;
  }
}

#loader .cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: detailed-cube-rotate 4s infinite linear;
}

#loader .cube::before {
  content: '';
  position: absolute;
  inset: 20px;
  background: rgba(139, 92, 246, 0.9);
  box-shadow: 0 0 40px 15px rgba(99, 102, 241, 0.7);
  border-radius: 8px;
  animation: detailed-pulse-core 2s infinite ease-in-out alternate;
}

@keyframes detailed-pulse-core {
  0% {
    transform: scale3d(0.8, 0.8, 0.8) rotateX(0deg) rotateY(0deg);
    opacity: 0.5;
  }

  100% {
    transform: scale3d(1.15, 1.15, 1.15) rotateX(180deg) rotateY(180deg);
    opacity: 1;
  }
}

#loader .cube-face {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 2px solid rgba(99, 102, 241, 0.85);
  background: rgba(99, 102, 241, 0.08);
  backdrop-filter: blur(2px);
  box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.4), 0 0 15px rgba(99, 102, 241, 0.3);
  overflow: hidden;
  border-radius: 4px;
}

#loader .cube-face::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px dashed rgba(139, 92, 246, 0.7);
  border-radius: 2px;
}

#loader .cube-face::after {
  content: '';
  position: absolute;
  top: -100%;
  left: -100%;
  right: -100%;
  bottom: -100%;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.6) 50%, transparent 60%);
  animation: detailed-scanning 2s linear infinite;
  background-size: 200% 200%;
}

@keyframes detailed-scanning {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

#loader .cube-face.front {
  transform: translateZ(40px);
}

#loader .cube-face.back {
  transform: rotateY(180deg) translateZ(40px);
}

#loader .cube-face.right {
  transform: rotateY(90deg) translateZ(40px);
}

#loader .cube-face.left {
  transform: rotateY(-90deg) translateZ(40px);
}

#loader .cube-face.top {
  transform: rotateX(90deg) translateZ(40px);
}

#loader .cube-face.bottom {
  transform: rotateX(-90deg) translateZ(40px);
}

@keyframes detailed-cube-rotate {
  0% {
    transform: rotateX(-20deg) rotateY(0deg);
  }

  50% {
    transform: rotateX(-20deg) rotateY(180deg) scale3d(1.15, 1.15, 1.15);
  }

  100% {
    transform: rotateX(-20deg) rotateY(360deg);
  }
}

/* ─── Progress Bar ────────────────────────────────────────────────────────── */

#loader .progress-bar-container {
  width: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#loader .progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

#loader .progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #a855f7, #6366f1);
  background-size: 200% 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.8), 0 0 5px rgba(99, 102, 241, 0.9);
  animation: detailed-progress-scan 2s linear infinite;
}

@keyframes detailed-progress-scan {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

#loader .loader-text {
  display: flex !important;
  justify-content: space-between !important;
  width: 100% !important;
  position: static !important;
  font-size: 11px !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  color: rgba(99, 102, 241, 0.5) !important;
  text-transform: uppercase;
  letter-spacing: 2px;
  line-height: normal !important;
}

#loader .loader-percentage {
  color: #6366f1 !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  position: static !important;
}

#loader .loader-status {
  color: rgba(99, 102, 241, 0.5) !important;
}