/* ============================================================
   LOADING & PROGRESS FEEDBACK (Neumorphic)
   ============================================================ */

/* ---------- Shared animation ---------- */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Moving Dots ("m...") ---------- */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
}

.loading-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  animation: dotPulse 1.2s infinite ease-in-out;
}

.loading-dots .dot:nth-child(1) { animation-delay: 0s; }
.loading-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* ---------- Button Loading State ---------- */
.btn.loading {
  pointer-events: none;
  opacity: 0.8;
  position: relative;
  color: transparent !important;  /* hide original text */
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 3px solid var(--nm-dark);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Alternative: dots inside button */
.btn.loading-dots {
  color: var(--text) !important;
  pointer-events: none;
}

.btn.loading-dots .btn-text {
  display: none;
}

.btn.loading-dots .loading-dots {
  display: inline-flex;
}

/* ---------- Skeleton Loader ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--nm-light) 50%, var(--surface-alt) 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-btn);
  margin-bottom: 8px;
}

.skeleton-text {
  height: 1em;
  width: 80%;
  margin-bottom: 0.5em;
}

.skeleton-text.short { width: 50%; }

.skeleton-image {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-table-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
}

.skeleton-table-row .skeleton-cell {
  flex: 1;
  height: 1.2em;
  background: inherit;
  border-radius: 6px;
}

/* Overlay for section loading */
.section-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-card);
  backdrop-filter: blur(2px);
}

.dark-mode .section-loader {
  background: rgba(0,0,0,0.4);
}

.section-loader .loading-dots .dot {
  background: var(--primary);
  width: 12px;
  height: 12px;
}

/* ---------- Top-Bar Page Loader ---------- */
.top-bar-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 200;
  background: transparent;
  overflow: hidden;
}

.top-bar-loader::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: var(--primary);
  animation: pageLoader 1.2s ease-in-out infinite;
  border-radius: 0 0 2px 2px;
}

@keyframes pageLoader {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* ---------- Background Status (non-blocking) ---------- */
.status-bar {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  padding: 8px 20px;
  border-radius: 40px;
  box-shadow: var(--nm-shadow-elevated);
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.status-bar.visible {
  opacity: 1;
  pointer-events: auto;
}

.status-bar .status-icon {
  width: 16px;
  height: 16px;
}

/* Spinner for status bar */
.status-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--nm-dark);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}