/* Global full-screen loading overlay */

:root {
  --app-loading-primary: var(--primary, #3b82f6);
  --app-loading-primary-light: #60a5fa;
  --app-loading-z: 10050;
}

/* Block interaction while loader is active */
body.app-global-loader-open {
  overflow: hidden;
  touch-action: none;
}

body.app-global-loader-open .app-shell,
body.app-global-loader-open .app-content,
body.app-global-loader-open .app-auth-page,
body.app-global-loader-open .pdf-editor-app {
  pointer-events: none;
  user-select: none;
}

/* Full-screen overlay */
.app-global-loader {
  position: fixed;
  inset: 0;
  z-index: var(--app-loading-z);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  pointer-events: none;
}

.app-global-loader.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-global-loader-card {
  width: min(100%, 360px);
  padding: 2rem 2rem 1.75rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 24px 64px rgba(15, 23, 42, 0.28);
  animation: app-global-loader-card-in 0.28s ease;
}

@keyframes app-global-loader-card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Modern spinning wheel */
.app-global-loader-wheel {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
  border: 4px solid rgba(59, 130, 246, 0.15);
  border-top-color: var(--app-loading-primary);
  border-right-color: var(--app-loading-primary-light);
  animation: app-global-loader-spin 0.75s linear infinite;
}

@keyframes app-global-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

.app-global-loader-message {
  margin: 1.15rem 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.45;
}

.app-global-loader-hint {
  margin: 0.45rem 0 0;
  font-size: 0.8125rem;
  font-weight: 400;
  color: #64748b;
  line-height: 1.4;
}

/* Legacy alias — same overlay */
.app-page-loading-overlay {
  /* merged into .app-global-loader */
}

/* Inline button spinner (supplementary) */
.loading-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.125em;
  animation: app-spinner-rotate 0.65s linear infinite;
  flex-shrink: 0;
}

.loading-spinner--sm {
  width: 0.9em;
  height: 0.9em;
  border-width: 1.5px;
}

@keyframes app-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.btn-loading,
button.btn-loading,
input.btn-loading,
a.btn-loading {
  pointer-events: none;
  cursor: wait;
  opacity: 0.92;
}

.btn-loading > .btn-loading-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

/* PDF workspace local loader (initial PDF fetch only) */
.section-loading {
  position: relative;
  min-height: 120px;
}

.section-loading.is-busy {
  pointer-events: none;
}

.section-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(52, 56, 59, 0.72);
  backdrop-filter: blur(3px);
  border-radius: inherit;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.section-loading-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.section-loading-overlay .app-global-loader-wheel {
  width: 44px;
  height: 44px;
  border-width: 3px;
}

.section-loading-overlay span {
  font-size: 0.875rem;
  font-weight: 600;
  color: #f8fafc;
}

.app-sr-loading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a.is-download-loading {
  pointer-events: none;
  opacity: 0.75;
}
