/* ===== MR. CLEAN — PROFESSIONAL OPTIMIZED PRELOADER ===== */

:root {
  --loader-primary: #0188cf;
  --loader-secondary: #3dab45;
  --loader-duration: 0.5s;
}

/* ========================================
   CRITICAL: Hide Content During Load
   ======================================== */
body.loading {
  overflow: hidden !important;
  height: 100vh !important;
}

body.loading > *:not(#preloader) {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ========================================
   PRELOADER OVERLAY
   ======================================== */
#preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  transition: opacity var(--loader-duration) ease-out,
              visibility var(--loader-duration) ease-out;
}

#preloader.fade-out {
  opacity: 0;
  visibility: hidden;
}

/* ========================================
   LOADER ANIMATION - Wave Bars
   ======================================== */
.preloader-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.loader-bar {
  width: 8px;
  height: 50px;
  background: linear-gradient(180deg, var(--loader-primary) 0%, var(--loader-secondary) 100%);
  border-radius: 10px;
  animation: waveAnimation 1.2s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(1, 136, 207, 0.3);
  will-change: transform, opacity;
}

.loader-bar:nth-child(1) {
  animation-delay: 0s;
}

.loader-bar:nth-child(2) {
  animation-delay: 0.1s;
}

.loader-bar:nth-child(3) {
  animation-delay: 0.2s;
}

.loader-bar:nth-child(4) {
  animation-delay: 0.3s;
}

.loader-bar:nth-child(5) {
  animation-delay: 0.4s;
}

@keyframes waveAnimation {
  0%, 100% {
    transform: scaleY(0.4);
    opacity: 0.6;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* ========================================
   CONTENT FADE-IN AFTER LOAD
   ======================================== */
body.loaded > *:not(#preloader) {
  animation: contentFadeIn 0.6s ease-out forwards;
}

@keyframes contentFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
  .loader-bar {
    width: 6px;
    height: 40px;
  }
  
  .preloader-content {
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .loader-bar {
    width: 5px;
    height: 35px;
  }
  
  .preloader-content {
    gap: 6px;
  }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */
#preloader,
.preloader-content,
.loader-bar {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
