#loading-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #0f0f0f 100%);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;

  opacity: 1;
  visibility: visible;
  pointer-events: all;

  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, visibility;
}

/* Animated background grid */
#loading-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
      90deg,
      rgba(59, 130, 246, 0.05) 1px,
      transparent 1px
    ),
    linear-gradient(rgba(59, 130, 246, 0.05) 1px, transparent 1px);
  background-size: 50px 50px;
  animation: grid-flow 20s linear infinite;
  opacity: 0.3;
}

@keyframes grid-flow {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(50px, 50px);
  }
}

.loader-container {
  position: relative;
  z-index: 1;
}

/* Orbital rings around the dots */
.orbit-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 50%;
  animation: orbit-pulse 2s ease-in-out infinite;
}

.orbit-ring:nth-child(1) {
  width: 100px;
  height: 100px;
  animation-delay: 0s;
}

.orbit-ring:nth-child(2) {
  width: 140px;
  height: 140px;
  animation-delay: 0.3s;
}

.orbit-ring:nth-child(3) {
  width: 180px;
  height: 180px;
  animation-delay: 0.6s;
}

@keyframes orbit-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 0.4;
  }
}

/* --- Enhanced Dot Animation --- */
.dot-loader {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  position: relative;
  z-index: 2;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position: relative;
  animation: enhanced-bounce 1.4s infinite cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 8px currentColor);
  will-change: transform, opacity;
}

.dot::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: inherit;
  opacity: 0;
  animation: pulse-ring 1.4s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.dot.red {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ef4444;
  animation-delay: 0s;
}

.dot.red::before {
  animation-delay: 0s;
}

.dot.green {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #22c55e;
  animation-delay: 0.2s;
}

.dot.green::before {
  animation-delay: 0.2s;
}

.dot.blue {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #3b82f6;
  animation-delay: 0.4s;
}

.dot.blue::before {
  animation-delay: 0.4s;
}

@keyframes enhanced-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.6) translateY(0);
    opacity: 0.6;
  }
  40% {
    transform: scale(1.3) translateY(-20px);
    opacity: 1;
  }
}

@keyframes pulse-ring {
  0%,
  80%,
  100% {
    transform: scale(1);
    opacity: 0;
  }
  40% {
    transform: scale(2);
    opacity: 0.4;
  }
}

.loading-text-container {
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.5),
    0 0 20px rgba(59, 130, 246, 0.3), 0 0 30px rgba(59, 130, 246, 0.2);
  animation: glow-pulse 2s ease-in-out infinite;
}

.loading-text {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 3px;
  color: #ffffff;
  position: relative;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.loading-text::before {
  content: "Loading";
  position: absolute;
  left: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(59, 130, 246, 1) 50%,
    rgba(255, 255, 255, 0.4) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.loading-dots {
  display: inline-block;
  margin-left: 2px;
}

.loading-dots span {
  animation: blink 1.4s infinite;
  font-size: 20px;
  color: #3b82f6;
}

.loading-dots span:nth-child(1) {
  animation-delay: 0s;
}
.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
.loading-dots span:nth-child(4) {
  animation-delay: 0.6s;
}
.loading-dots span:nth-child(5) {
  animation-delay: 0.8s;
}
.loading-dots span:nth-child(6) {
  animation-delay: 1s;
}

@keyframes blink {
  0%,
  20%,
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

@keyframes glow-pulse {
  0%,
  100% {
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5),
      0 0 20px rgba(59, 130, 246, 0.3), 0 0 30px rgba(59, 130, 246, 0.2);
  }
  50% {
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.8),
      0 0 30px rgba(59, 130, 246, 0.5), 0 0 45px rgba(59, 130, 246, 0.3);
  }
}

/*
Progress bar
.progress-container {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 24px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #22c55e, #3b82f6);
  background-size: 200% 100%;
  border-radius: 10px;
  animation: progress 2s ease-in-out infinite, gradient-shift 3s ease infinite;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

@keyframes progress {
  0% {
    width: 20%;
    margin-left: 0;
  }
  50% {
    width: 60%;
    margin-left: 20%;
  }
  100% {
    width: 20%;
    margin-left: 80%;
  }
}

@keyframes gradient-shift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}
  */

/* --- When fading out --- */
#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#loading-overlay.hidden .dot {
  animation: fadeout-dot 0.6s forwards ease-in;
}

#loading-overlay.hidden .orbit-ring {
  animation: fadeout-ring 0.6s forwards ease-in;
}

@keyframes fadeout-dot {
  to {
    transform: scale(0) translateY(-30px);
    opacity: 0;
  }
}

@keyframes fadeout-ring {
  to {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}
