/* =============================================
   RUHUNA TECMART — PRELOADER
   Premium loading screen with logo animation
   ============================================= */

body.preloading {
  overflow: hidden !important;
  height: 100vh !important;
  touch-action: none;
}

.preloader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.45s;
}

.preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Background subtle particles */
.preloader::before {
  content: '';
  position: absolute;
  width: 350px;
  height: 350px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.08) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: preloaderGlow 3s ease-in-out infinite;
}

@keyframes preloaderGlow {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
}

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
  z-index: 1;
}

/* Logo with shine effect */
.preloader-logo-wrapper {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preloader-logo-clip {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.preloader-logo {
  width: 140px;
  height: 140px;
  object-fit: contain;
  border-radius: 50%;
  animation: preloaderLogoFadeIn 0.5s ease-out forwards;
  opacity: 0;
}

@keyframes preloaderLogoFadeIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

/* Spinning ring around logo */
.preloader-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #1D4ED8;
  border-right-color: #2563EB;
  animation: preloaderSpin 1.5s linear infinite;
  z-index: 1;
}

.preloader-ring::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-bottom-color: #38BDF8;
  border-left-color: #7DD3FC;
  animation: preloaderSpin 2s linear infinite reverse;
}

@keyframes preloaderSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Shine sweep effect over logo */
.preloader-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 25%,
    rgba(255,255,255,0.25) 50%,
    rgba(255,255,255,0.08) 75%,
    transparent 100%
  );
  z-index: 3;
  border-radius: 50%;
  animation: shineSwipe 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shineSwipe {
  0% { transform: translateX(-100%); left: 0; opacity: 0; }
  10% { opacity: 1; }
  45% { transform: translateX(100%); left: 0; opacity: 1; }
  46%, 100% { transform: translateX(100%); left: 0; opacity: 0; }
}

/* Brand text */
.preloader-brand {
  text-align: center;
  opacity: 0;
  animation: preloaderTextFadeIn 0.5s ease-out 0.25s forwards;
}

@keyframes preloaderTextFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.preloader-brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, #1D4ED8, #2563EB, #38BDF8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.preloader-tagline {
  font-size: 0.8rem;
  color: #64748B;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 600;
}

/* Trust badges */
.preloader-trust {
  display: flex;
  gap: 24px;
  opacity: 0;
  animation: preloaderTextFadeIn 0.5s ease-out 0.45s forwards;
}

.preloader-trust-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: #475569;
  font-weight: 500;
}

.preloader-trust-icon {
  font-size: 1rem;
  animation: preloaderIconPulse 2s ease-in-out infinite;
}

.preloader-trust-item:nth-child(2) .preloader-trust-icon {
  animation-delay: 0.3s;
}

.preloader-trust-item:nth-child(3) .preloader-trust-icon {
  animation-delay: 0.6s;
}

@keyframes preloaderIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Loading dots */
.preloader-dots {
  display: flex;
  gap: 8px;
  opacity: 0;
  animation: preloaderTextFadeIn 0.5s ease-out 0.6s forwards;
}

.preloader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2563EB;
  animation: preloaderDotBounce 1.4s ease-in-out infinite;
}

.preloader-dot:nth-child(1) { animation-delay: 0s; }
.preloader-dot:nth-child(2) { animation-delay: 0.2s; }
.preloader-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes preloaderDotBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
    background: #1565c0;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
    background: #2196f3;
  }
}

/* Loading progress bar */
.preloader-progress {
  width: 220px;
  height: 3px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
  opacity: 0;
  animation: preloaderTextFadeIn 0.5s ease-out 0.6s forwards;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.preloader-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1D4ED8 0%, #2563EB 50%, #38BDF8 100%);
  border-radius: 999px;
  width: 0%;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

.preloader-status-hint {
  font-size: 0.74rem;
  color: #64748B;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-top: -12px;
  text-align: center;
  opacity: 0;
  animation: preloaderTextFadeIn 0.5s ease-out 0.65s forwards;
  transition: opacity 0.25s ease, color 0.25s ease;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .preloader-logo-wrapper {
    width: 130px;
    height: 130px;
  }

  .preloader-logo {
    width: 110px;
    height: 110px;
  }

  .preloader-brand-name {
    font-size: 1.3rem;
  }

  .preloader-trust {
    flex-direction: column;
    gap: 12px;
    align-items: center;
  }

  .preloader-progress {
    width: 160px;
  }
}
