/* Performance-optimized splash screen with proper alignment */

/* Apply overflow hidden only when splash screen is present */
body.splash-screen-active {
  overflow: hidden !important;
  margin: 0;
  padding: 0;
}

.splash-screen {
  position: fixed; /* Use fixed instead of absolute for better positioning */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f2f3f8;
  color: #5E6278;
  line-height: 1.5;
  font-size: 14px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.splash-screen span {
  color: #5E6278;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: fadeInText 0.4s ease-in 0.3s forwards;
}

/* Spinner container with perfect centering */
.spinner-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

/* Logo container - perfectly centered */
.logo-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

/* Logo image with smooth fade-in */
.spinner-logo {
  width: 60px !important;
  height: 60px !important;
  max-width: 60px;
  max-height: 60px;
  object-fit: contain;
  margin: 0 !important;
  padding: 0;
  animation: fadeInLogo 0.5s ease-out;
}

/* Animated spinner ring */
.spinner-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 4px solid rgba(54, 153, 255, 0.1);
  border-top-color: #3699ff;
  border-right-color: #3699ff;
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
  box-sizing: border-box;
  will-change: transform;
}

/* Optimized animations with GPU acceleration */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeInLogo {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeInText {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dark theme support */
[data-bs-theme="dark"] .splash-screen {
  background-color: #151521;
  color: #92929F;
}

[data-bs-theme="dark"] .splash-screen span {
  color: #92929F;
}

[data-bs-theme="dark"] .spinner-ring {
  border-color: rgba(54, 153, 255, 0.15);
  border-top-color: #3699ff;
  border-right-color: #3699ff;
}

/* Smooth fade-out when app loads */
.splash-screen.splash-screen-hidden {
  opacity: 0;
  transition: opacity 0.3s ease-out;
  pointer-events: none;
}

/* Root element transition */
#root {
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .spinner-wrapper {
    width: 100px;
    height: 100px;
  }
  
  .spinner-logo {
    width: 50px !important;
    height: 50px !important;
    max-width: 50px;
    max-height: 50px;
  }
  
  .splash-screen span {
    font-size: 0.8125rem;
  }
}
