/* ============================================
   LOADING CONTAINER
   ============================================ */
html:has(#phimhay-loader:not(.hidden)) {
  overflow: hidden;
}

/* Loading Container */
.phimhay-loader-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #030306 0%, #0a0a12 50%, #030306 100%);
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease-out, visibility 0.6s ease-out;
}

.phimhay-loader-wrapper.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Hide navbar when loader is active */
#phimhay-loader:not(.hidden) ~ .navbar,
#phimhay-loader:not(.hidden) ~ #m-bottom-nav,
#phimhay-loader:not(.hidden) ~ .m-bottom-nav,
#phimhay-loader:not(.hidden) ~ .m-header,
#phimhay-loader:not(.hidden) ~ main {
  visibility: hidden;
}

/* Also prevent scroll on body */
body:has(#phimhay-loader:not(.hidden)) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Hide bottom nav using class method (more reliable) */
body.phimhay-loading .m-bottom-nav,
.m-bottom-nav.phimhay-nav-hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  z-index: -9999 !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Hide all body content when loader is active */
body:has(#phimhay-loader:not(.hidden)) > *:not(#phimhay-loader):not(.navbar):not(#progress-bar):not(.scroll-top-btn):not(.toast-container):not(.m-bottom-nav):not(.m-header):not(.m-drawer):not(.m-drawer-backdrop) {
  display: none !important;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
}

/* ---- MAIN LOADER ICON ---- */
.loader-icon {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Outer rotating ring */
.loader-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-top-color: var(--gold);
  border-right-color: var(--accent);
  border-radius: 50%;
  animation: spinRing 2s linear infinite;
}

.loader-ring:nth-child(2) {
  width: 80%;
  height: 80%;
  border: 2px solid transparent;
  border-bottom-color: var(--gold);
  border-left-color: var(--accent);
  animation: spinRing 1.5s linear infinite reverse;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.loader-ring:nth-child(3) {
  width: 60%;
  height: 60%;
  border: 2px solid transparent;
  border-top-color: var(--accent-hover);
  border-right-color: var(--gold-light);
  animation: spinRing 1s linear infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Center pulse dot */
.loader-center {
  position: absolute;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  border-radius: 50%;
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(232, 197, 71, 0.3);
  animation: pulseDot 2s ease-in-out infinite;
}

/* Glowing orbits */
.orbit-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 15px var(--gold-glow);
}

.orbit-dot:nth-child(4) {
  animation: orbit 3s linear infinite;
}

.orbit-dot:nth-child(5) {
  animation: orbit 3s linear infinite -1s;
}

.orbit-dot:nth-child(6) {
  animation: orbit 3s linear infinite -2s;
}

/* ---- LOGO SECTION ---- */
.loader-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-logo-img {
  width: min(320px, 72vw);
  height: auto;
  display: block;
  animation: fadeInText 1.2s ease-out;
}

/* ---- TEXT SECTION ---- */
.loader-text {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loader-title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  background: var(--gradient-vip);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
  animation: fadeInText 1.5s ease-out;
}

.loader-subtitle {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
  animation: fadeInText 1.5s ease-out 0.3s both;
}

/* Progress bar under loader */
.loader-progress {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 20px;
}

.loader-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--accent));
  background-size: 200% 100%;
  border-radius: 10px;
  animation: loadingBar 2s ease-in-out infinite;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ---- DECORATIVE ELEMENTS ---- */
.loader-decoration {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0;
  animation: floatParticles 4s ease-in-out infinite;
}

.particle:nth-child(1) {
  left: 20%;
  top: 30%;
  animation-delay: 0s;
}

.particle:nth-child(2) {
  left: 80%;
  top: 70%;
  animation-delay: 1s;
}

.particle:nth-child(3) {
  left: 70%;
  top: 20%;
  animation-delay: 2s;
}

.particle:nth-child(4) {
  left: 10%;
  top: 80%;
  animation-delay: 1.5s;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes spinRing {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulseDot {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(232, 197, 71, 0.3);
  }
  50% {
    transform: scale(1.4);
    box-shadow: 0 0 50px var(--accent-glow), 0 0 100px rgba(232, 197, 71, 0.5);
  }
}

@keyframes orbit {
  from {
    transform: rotate(0deg) translateX(50px);
  }
  to {
    transform: rotate(360deg) translateX(50px);
  }
}

@keyframes fadeInText {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes loadingBar {
  0% {
    width: 0%;
    background-position: 200% 0;
  }
  50% {
    width: 100%;
    background-position: -200% 0;
  }
  100% {
    width: 0%;
    background-position: 200% 0;
  }
}

@keyframes floatParticles {
  0% {
    opacity: 0;
    transform: translate(0, 0);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx, 0), var(--ty, -100px));
  }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .loader-icon {
    width: 80px;
    height: 80px;
  }

  .loader-title {
    font-size: 22px;
  }

  .loader-subtitle {
    font-size: 11px;
  }

  .loader-progress {
    width: 150px;
  }
}

/* ============================================
   AUTH PAGES — DESKTOP SPACING FIX
   ============================================ */
@media (min-width: 769px) {
  main.auth-page {
    padding-top: calc(var(--nav-height) + 60px) !important;
    min-height: 100vh;
    justify-content: flex-start;
  }
}

/* ============================================
   SCROLL-TO-TOP BUTTON
   ============================================ */
.scroll-top-btn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  box-shadow: 0 4px 20px rgba(225, 29, 72, 0.4);
  transform: translateY(10px);
}

.scroll-top-btn:hover {
  transform: translateY(0);
  box-shadow: 0 8px 32px rgba(225, 29, 72, 0.6);
}

.scroll-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 768px) {
  .scroll-top-btn {
    bottom: calc(100px + var(--safe-bottom));
    right: 20px;
    width: 40px;
    height: 40px;
  }

  .scroll-top-btn svg {
    width: 18px;
    height: 18px;
  }
}
