/* Light, minimal Preloader matching the new theme - FASTER VERSION */
#preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  transition: opacity 0.3s ease, visibility 0.3s ease; /* Reduced from 0.6s */
  overflow: hidden;
}

#preloader::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 80%, rgba(96, 165, 250, 0.18) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(244, 114, 182, 0.14) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(167, 139, 250, 0.10) 0%, transparent 50%);
  animation: backgroundShift 2s ease-in-out infinite; /* Reduced from 8s */
}

@keyframes backgroundShift {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

/* Original Loader Box */
.loader-box {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 15;
  animation: loaderBoxFade 0.5s ease-in-out forwards; /* Reduced from 2.1s */
}

.loader-circle {
  position: relative;
  width: 64px; /* Reduced from 96px */
  height: 64px; /* Reduced from 96px */
  border: 2px solid rgba(2, 6, 23, 0.08); /* Reduced from 3px */
  border-radius: 50%;
  margin-bottom: 12px; /* Reduced from 16px */
  animation: loaderSpin 0.8s linear infinite; /* Reduced from 2.4s */
  background: #ffffff;
}

.spin-element {
  position: absolute;
  width: 6px; /* Reduced from 8px */
  height: 6px; /* Reduced from 8px */
  background: #60a5fa;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px rgba(15, 23, 42, 0.12); /* Reduced from 6px */
  animation: spinElementGlow 0.6s ease-in-out infinite alternate; /* Reduced from 1.8s */
}

.loader-box h2 {
  color: #0f172a;
  font-size: 1rem; /* Reduced from 1.2rem */
  font-weight: 600;
  margin-bottom: 8px; /* Reduced from 10px */
  text-shadow: none;
  animation: textPulse 0.7s ease-in-out infinite; /* Reduced from 2.2s */
}

.progress-bar {
  width: 160px; /* Reduced from 220px */
  height: 3px; /* Reduced from 4px */
  background: rgba(2, 6, 23, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px; /* Reduced from 8px */
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #f472b6);
  border-radius: 2px;
  animation: progressFill 0.4s ease-in-out forwards; /* Reduced from 2s */
  transform: translateX(-100%);
}

.loader-box .loading-text {
  color: #475569;
  font-size: 0.8rem; /* Reduced from 0.9rem */
  margin-bottom: 3px; /* Reduced from 4px */
  opacity: 0.95;
}

.loader-box .ai-status {
  color: #64748b;
  font-size: 0.75rem; /* Reduced from 0.85rem */
  opacity: 0.9;
}

/* Main pet image container */
.pet-image-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  animation: petContainerAppear 0.5s ease-in-out forwards; /* Reduced from 2.1s */
}

/* Pet image with zoom and fade effect */
.pet-image {
  width: 40px; /* Reduced from 56px */
  height: 40px; /* Reduced from 56px */
  /* background-image: url('image 1 (1).png'); */ /* Remove external image dependency */
  background-color: #60a5fa; /* Use solid color instead */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08); /* Reduced from 20px */
  animation: petZoomFade 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards; /* Reduced from 1.8s */
  border: 1px solid rgba(2, 6, 23, 0.08); /* Reduced from 2px */
}

/* Outer rings (toned down) */
.pet-image::before {
  content: '';
  position: absolute;
  top: -10px; /* Reduced from -16px */
  left: -10px; /* Reduced from -16px */
  width: calc(100% + 20px); /* Reduced from 32px */
  height: calc(100% + 20px); /* Reduced from 32px */
  border-radius: 50%;
  border: 1px solid transparent; /* Reduced from 2px */
  border-top: 1px solid #60a5fa;
  border-right: 1px solid rgba(96, 165, 250, 0.25);
  animation: spin 0.6s linear infinite, ringFade 0.4s ease-in-out forwards; /* Reduced from 2s/1.8s */
  box-shadow: none;
}

.pet-image::after {
  content: '';
  position: absolute;
  top: -16px; /* Reduced from -28px */
  left: -16px; /* Reduced from -28px */
  width: calc(100% + 32px); /* Reduced from 56px */
  height: calc(100% + 32px); /* Reduced from 56px */
  border-radius: 50%;
  border: 1px solid transparent; /* Reduced from 1px */
  border-bottom: 1px solid #f472b6;
  border-left: 1px solid rgba(244, 114, 182, 0.25);
  animation: spinReverse 0.8s linear infinite, ringFade 0.4s ease-in-out forwards; /* Reduced from 2.4s/1.8s */
  box-shadow: none;
}

/* Floating particles around the image (subtle) */
.particles {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 2px; /* Reduced from 4px */
  height: 2px; /* Reduced from 4px */
  background: #60a5fa;
  border-radius: 50%;
  animation: floatParticle 2s ease-in-out infinite; /* Reduced from 7s */
  box-shadow: none;
}

.particle:nth-child(1) { top: 20%; left: 10%; animation-delay: 0s; background: #60a5fa; }
.particle:nth-child(2) { top: 60%; left: 80%; animation-delay: 0.2s; background: #f472b6; } /* Reduced from 1s */
.particle:nth-child(3) { top: 80%; left: 20%; animation-delay: 0.4s; background: #a78bfa; } /* Reduced from 2s */
.particle:nth-child(4) { top: 30%; left: 70%; animation-delay: 0.3s; background: #60a5fa; } /* Reduced from 1.5s */
.particle:nth-child(5) { top: 70%; left: 30%; animation-delay: 0.1s; background: #f472b6; } /* Reduced from 0.5s */
.particle:nth-child(6) { top: 40%; left: 90%; animation-delay: 0.5s; background: #a78bfa; } /* Reduced from 2.5s */

/* Animations (kept names; visuals toned down) */
@keyframes petZoomFade {
  0% { transform: scale(0.1); opacity: 0; filter: blur(4px); } /* Reduced from 8px */
  50% { transform: scale(0.8); opacity: 0.7; filter: blur(1px); } /* Reduced from 0.6/3px */
  100% { transform: scale(1.0); opacity: 1; } /* Reduced from 1.1 */
}

@keyframes ringFade {
  0% { opacity: 0; transform: scale(0.2); } /* Reduced from 0.4 */
  50% { opacity: 0.6; transform: scale(1.4); } /* Reduced from 2.2 */
  100% { opacity: 0; transform: scale(2.0); } /* Reduced from 3.4 */
}

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

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

@keyframes floatParticle {
  0%, 100% {
    transform: translateY(0px) translateX(0px) scale(0.6); /* Reduced from 0.8 */
    opacity: 0;
  }
  25% {
    transform: translateY(-10px) translateX(6px) scale(0.8); /* Reduced from 18px/10px/1 */
    opacity: 0.8; /* Reduced from 1 */
  }
  75% {
    transform: translateY(-20px) translateX(-8px) scale(0.7); /* Reduced from 40px/12px/0.9 */
    opacity: 0.3; /* Reduced from 0.4 */
  }
}

/* Original Loader Animations (timing preserved) */
@keyframes loaderBoxFade {
  0% { opacity: 1; }
  70% { opacity: 1; } /* Reduced from 14.3% */
  80% { opacity: 0; } /* Reduced from 19% */
  100% { opacity: 0; }
}

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

@keyframes spinElementGlow {
  0% { box-shadow: 0 0 4px rgba(15, 23, 42, 0.12); background: #60a5fa; } /* Reduced from 6px */
  100% { box-shadow: 0 0 4px rgba(15, 23, 42, 0.10); background: #f472b6; } /* Reduced from 6px */
}

@keyframes textPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; } /* Reduced from 0.75 */
}

@keyframes progressFill {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(0%); }
}

@keyframes petContainerAppear {
  0% { opacity: 0; }
  70% { opacity: 0; } /* Reduced from 14.3% */
  80% { opacity: 1; } /* Reduced from 19% */
  100% { opacity: 1; }
}

/* Preloader fade out */
#preloader.fade-out {
  opacity: 0;
  visibility: hidden;
}

/* Responsive design */
@media (max-width: 768px) {
  .pet-image { width: 32px; height: 32px; } /* Reduced from 44px */
  .particle { width: 1px; height: 1px; } /* Reduced from 3px */
}

@media (max-width: 480px) {
  .pet-image { width: 28px; height: 28px; } /* Reduced from 38px */
  .particle { width: 1px; height: 1px; } /* Reduced from 2px */
}