/* ══════════════════════════════════════════════
   loading.css — RankCore Dashboard Loading Animations
   Injected into every page via <link rel="stylesheet" href="/loading.css">
   ══════════════════════════════════════════════ */

/* ── Keyframes ─────────────────────────────── */
@keyframes spin        { to { transform: rotate(360deg); } }
@keyframes shimmer     { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
@keyframes dotBounce   { 0%,80%,100%{transform:scale(0.6);opacity:0.4} 40%{transform:scale(1);opacity:1} }
@keyframes panelScan   { 0%{transform:translateX(-100%)} 100%{transform:translateX(200%)} }
@keyframes contentShow { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeIn      { from{opacity:0} to{opacity:1} }
@keyframes ldrPulse    { 0%,100%{box-shadow:0 0 0 0 rgba(255,51,51,0)} 50%{box-shadow:0 0 0 8px rgba(255,51,51,0.08)} }
@keyframes ldrSpin     { to{transform:translate(-50%,-50%) rotate(360deg)} }
@keyframes barMove     { 0%{margin-left:-40%} 100%{margin-left:140%} }

/* ── Page loader overlay ───────────────────── */
#nx-loader {
  position: fixed; inset: 0; z-index: 999999;
  background: #07080f;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 24px;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
#nx-loader.nx-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

#nx-loader .nx-ring {
  position: relative; width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
}
#nx-loader .nx-logo {
  width: 50px; height: 50px; border-radius: 14px;
  background: rgba(255,51,51,0.1); border: 1px solid rgba(255,51,51,0.2);
  display: flex; align-items: center; justify-content: center;
  animation: ldrPulse 2s ease-in-out infinite;
}
#nx-loader .nx-logo img { width: 28px; height: 28px; object-fit: contain; }
#nx-loader .nx-spin {
  position: absolute; top: 50%; left: 50%;
  width: 50px; height: 50px; border-radius: 50%;
  border: 3px solid rgba(255,51,51,0.12); border-top-color: #FF3333;
  animation: ldrSpin 0.75s linear infinite;
}

#nx-loader .nx-bar-wrap {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: rgba(255,51,51,0.1);
}
#nx-loader .nx-bar {
  height: 100%; width: 40%;
  background: linear-gradient(90deg, #CC2222, #FF3333, #FF5555);
  animation: barMove 1.4s ease-in-out infinite;
  border-radius: 0 2px 2px 0;
}
#nx-loader .nx-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  color: rgba(255,255,255,0.25);
  display: flex; align-items: center; gap: 3px;
}
#nx-loader .nx-dots span {
  display: inline-block; width: 3px; height: 3px; border-radius: 50%;
  background: rgba(255,255,255,0.25);
  animation: dotBounce 1.2s ease-in-out infinite;
  margin: 0 1px;
}
#nx-loader .nx-dots span:nth-child(2) { animation-delay: 0.15s; }
#nx-loader .nx-dots span:nth-child(3) { animation-delay: 0.30s; }

/* ── Top progress bar ──────────────────────── */
#nx-progress {
  position: fixed; top: 0; left: 0; height: 2px;
  background: linear-gradient(90deg, #CC2222, #FF3333, #FF5555);
  box-shadow: 0 0 10px rgba(255,51,51,0.7);
  z-index: 99998; width: 0%;
  transition: width 0.25s ease, opacity 0.4s ease;
  opacity: 0; pointer-events: none;
}
#nx-progress.nx-running { opacity: 1; }
#nx-progress.nx-done    { width: 100% !important; opacity: 0; transition: width 0.15s ease, opacity 0.5s ease 0.15s; }

/* ── Fetch badge ───────────────────────────── */
#nx-fetch-badge {
  position: fixed; bottom: 18px; right: 18px;
  background: rgba(15,10,10,0.92);
  border: 1px solid rgba(255,51,51,0.25);
  border-radius: 20px; padding: 6px 12px 6px 8px;
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: rgba(255,255,255,0.5);
  backdrop-filter: blur(8px);
  transform: translateY(60px); opacity: 0;
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), opacity 0.3s ease;
  z-index: 9999; pointer-events: none;
  font-family: system-ui, sans-serif;
}
#nx-fetch-badge.nx-visible { transform: translateY(0); opacity: 1; }
#nx-fetch-badge .nx-badge-spin {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid rgba(255,51,51,0.2); border-top-color: #FF3333;
  animation: spin 0.65s linear infinite; flex-shrink: 0;
}

/* ── Spinner ───────────────────────────────── */
.nx-spinner {
  display: inline-block; flex-shrink: 0; border-radius: 50%;
  border: 2px solid rgba(255,51,51,0.15); border-top-color: #FF3333;
  animation: spin 0.65s linear infinite;
  width: 20px; height: 20px;
}
.nx-spinner.sm { width: 14px; height: 14px; border-width: 1.5px; }
.nx-spinner.lg { width: 32px; height: 32px; border-width: 3px; }

/* ── Skeleton shimmer ──────────────────────── */
.nx-skel {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 6px;
}
.nx-skel.text  { height: 12px; margin-bottom: 8px; }
.nx-skel.title { height: 20px; margin-bottom: 12px; }
.nx-skel.btn   { height: 36px; border-radius: 8px; }
.nx-skel.avatar { border-radius: 50% !important; }
.nx-skel.card  { height: 90px; border-radius: 14px; }
.nx-skel.row   { height: 48px; border-radius: 8px; margin-bottom: 8px; }
.nx-skel.w-full { width: 100%; }
.nx-skel.w-3-4  { width: 75%; }
.nx-skel.w-1-2  { width: 50%; }
.nx-skel.w-1-3  { width: 33%; }
.nx-skel.w-1-4  { width: 25%; }

/* ── Stagger delays ────────────────────────── */
.nx-skel:nth-child(1) { animation-delay: 0.00s; }
.nx-skel:nth-child(2) { animation-delay: 0.08s; }
.nx-skel:nth-child(3) { animation-delay: 0.16s; }
.nx-skel:nth-child(4) { animation-delay: 0.24s; }
.nx-skel:nth-child(5) { animation-delay: 0.32s; }
.nx-skel:nth-child(6) { animation-delay: 0.40s; }

/* ── Panel loading scan line ───────────────── */
.nx-panel-loading {
  position: relative; overflow: hidden;
}
.nx-panel-loading::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; z-index: 5;
  background: linear-gradient(90deg, transparent, #FF3333, transparent);
  animation: panelScan 1.5s ease-in-out infinite;
}

/* ── Button loading state ──────────────────── */
.nx-btn-loading {
  position: relative !important;
  pointer-events: none !important;
  color: transparent !important;
}
.nx-btn-loading * { opacity: 0 !important; }
.nx-btn-loading::after {
  content: '';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: white;
  animation: spin 0.65s linear infinite;
}

/* ── Content reveal ────────────────────────── */
.nx-revealed { animation: contentShow 0.4s ease forwards; }

/* ── Dots loader ───────────────────────────── */
.nx-dots {
  display: inline-flex; align-items: center; gap: 4px;
}
.nx-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: #FF3333;
  animation: dotBounce 1.2s ease-in-out infinite;
  display: inline-block;
}
.nx-dots span:nth-child(2) { animation-delay: 0.15s; }
.nx-dots span:nth-child(3) { animation-delay: 0.30s; }

/* ── Image fade-in ─────────────────────────── */
img.nx-img-pending { opacity: 0; transition: opacity 0.3s ease; }
img.nx-img-loaded  { opacity: 1; }

/* ── Inline loading wrap ───────────────────── */
.nx-loading-area {
  position: relative;
  min-height: 60px;
}
.nx-loading-area.nx-loading::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(7,8,15,0.5);
  border-radius: inherit;
  backdrop-filter: blur(2px);
  z-index: 10;
  animation: fadeIn 0.2s ease;
  display: block;
}
