/* =============================================
   RUTGON – loading.css
   Global Loading UI: Overlay · Spinner · Skeleton · Button States · Progress Bar
   ============================================= */

/* ── KEYFRAMES ────────────────────────────────── */
@keyframes rg-spin {
  to { transform: rotate(360deg); }
}
@keyframes rg-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes rg-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
@keyframes rg-progress {
  0%   { width: 0%; }
  30%  { width: 45%; }
  60%  { width: 70%; }
  80%  { width: 88%; }
  100% { width: 96%; }
}
@keyframes rg-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes rg-overlay-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes rg-modal-in {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
@keyframes rg-dots {
  0%, 80%, 100% { transform: scale(0.6); opacity: .4; }
  40%           { transform: scale(1);   opacity: 1;  }
}

/* ── TOP PROGRESS BAR ─────────────────────────── */
#rg-progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #06b6d4, #818cf8);
  background-size: 200%;
  z-index: 99999;
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
  transition: opacity 0.3s ease;
  animation: rg-progress 3s cubic-bezier(.4,0,.2,1) forwards;
}
#rg-progress-bar.done {
  width: 100% !important;
  animation: none;
  transition: width 0.2s ease, opacity 0.4s ease 0.3s;
  opacity: 0;
}

/* ── FULLSCREEN LOADING OVERLAY ───────────────── */
#rg-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(10, 14, 26, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: rg-overlay-in 0.2s ease;
  pointer-events: all;
}
[data-theme="light"] #rg-loading-overlay {
  background: rgba(240, 242, 248, 0.78);
}
#rg-loading-overlay.rg-overlay-hide {
  animation: rg-overlay-out 0.3s ease forwards;
  pointer-events: none;
}

/* ── OVERLAY SPINNER CARD ──────────────────────── */
.rg-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: var(--card-bg, rgba(20, 24, 40, 0.92));
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 20px;
  padding: 32px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.04) inset;
  animation: rg-modal-in 0.3s cubic-bezier(.34,1.56,.64,1);
}
[data-theme="light"] .rg-overlay-card {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(99, 102, 241, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}

/* ── RING SPINNER ─────────────────────────────── */
.rg-spinner {
  width: 52px;
  height: 52px;
  position: relative;
  flex-shrink: 0;
}
.rg-spinner::before,
.rg-spinner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
}
.rg-spinner::before {
  border-top-color: #6366f1;
  border-right-color: #06b6d4;
  animation: rg-spin 0.9s linear infinite;
}
.rg-spinner::after {
  inset: 8px;
  border-top-color: rgba(99, 102, 241, 0.3);
  animation: rg-spin 1.4s linear infinite reverse;
}

/* Smaller variant */
.rg-spinner-sm {
  width: 20px;
  height: 20px;
}
.rg-spinner-sm::before { border-width: 2px; }
.rg-spinner-sm::after  { inset: 5px; border-width: 2px; }

/* ── DOTS SPINNER ─────────────────────────────── */
.rg-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rg-dots span {
  display: inline-block;
  width: 8px; height: 8px;
  background: #6366f1;
  border-radius: 50%;
  animation: rg-dots 1.2s ease-in-out infinite;
}
.rg-dots span:nth-child(1) { animation-delay: 0s;    }
.rg-dots span:nth-child(2) { animation-delay: 0.16s; }
.rg-dots span:nth-child(3) { animation-delay: 0.32s; }

/* ── OVERLAY LABEL ────────────────────────────── */
.rg-overlay-label {
  font-size: 14px;
  font-weight: 600;
  color: #c7d2fe;
  letter-spacing: 0.02em;
  text-align: center;
}
[data-theme="light"] .rg-overlay-label {
  color: #4c4f8a;
}
.rg-overlay-sublabel {
  font-size: 12px;
  color: rgba(148, 163, 184, 0.7);
  text-align: center;
  margin-top: -8px;
}

/* ── SKELETON SHIMMER ────────────────────────── */
.rg-skeleton {
  background: linear-gradient(
    90deg,
    var(--skeleton-base, #1e2640) 25%,
    var(--skeleton-shine, #2a3050) 50%,
    var(--skeleton-base, #1e2640) 75%
  );
  background-size: 600px 100%;
  animation: rg-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}
[data-theme="light"] .rg-skeleton {
  --skeleton-base:  #e8ecf4;
  --skeleton-shine: #f4f6fb;
}

/* ── SKELETON LINK CARD ──────────────────────── */
.rg-skel-card {
  background: var(--card-bg-alt, #141828);
  border: 1px solid var(--border-alt, rgba(255,255,255,0.06));
  border-radius: 14px;
  overflow: hidden;
  padding: 14px;
  display: flex;
  gap: 14px;
}
[data-theme="light"] .rg-skel-card {
  background: #fff;
  border-color: #e2e8f0;
}

.rg-skel-thumb {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  flex-shrink: 0;
}
.rg-skel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}
.rg-skel-line {
  height: 12px;
  border-radius: 6px;
}
.rg-skel-line.w-40  { width: 40%; }
.rg-skel-line.w-60  { width: 60%; }
.rg-skel-line.w-75  { width: 75%; }
.rg-skel-line.w-90  { width: 90%; }
.rg-skel-line.w-full{ width: 100%; }
.rg-skel-line.h-8   { height: 8px; }
.rg-skel-line.h-16  { height: 16px; }

/* ── SKELETON STAT CARD ──────────────────────── */
.rg-skel-stat {
  background: var(--card-bg-alt, #141828);
  border: 1px solid var(--border-alt, rgba(255,255,255,0.06));
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
[data-theme="light"] .rg-skel-stat {
  background: #fff;
  border-color: #e2e8f0;
}

/* ── BUTTON LOADING STATE ─────────────────────── */
.rg-btn-loading {
  position: relative;
  pointer-events: none;
  cursor: not-allowed;
}
.rg-btn-loading .rg-btn-text { opacity: 0; }
.rg-btn-loading::after {
  content: '';
  position: absolute;
  inset: 50% 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rg-spin 0.7s linear infinite;
}
/* Dark text variant */
.rg-btn-loading.dark-spin::after {
  border-color: rgba(99,102,241,0.3);
  border-top-color: #6366f1;
}

/* ── INLINE SPINNER (inside element) ──────────── */
.rg-inline-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(99,102,241,0.25);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: rg-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
}

/* ── PULSE BADGE ─────────────────────────────── */
.rg-pulse-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.25);
  font-size: 12px;
  font-weight: 600;
  color: #a5b4fc;
  animation: rg-pulse 1.5s ease-in-out infinite;
}
.rg-pulse-badge::before {
  content: '';
  width: 7px; height: 7px;
  background: #6366f1;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── FADE-IN REVEAL HELPER ─────────────────────── */
.rg-fade-in {
  animation: rg-overlay-in 0.3s ease both;
}
