/* Global Loader */
#globalLoader {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 99999;
  background: rgba(248, 251, 255, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.loader-active {
  cursor: progress;
}

#globalLoader .loader-content {
  width: min(360px, 92vw);
  background: #ffffff;
  border: 1px solid #d9e2ef;
  border-radius: 14px;
  padding: 20px 18px;
  text-align: center;
  box-shadow: 0 18px 42px rgba(8, 32, 66, 0.16);
}

#globalLoader .loader-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

#globalLoader .loader-brand img {
  width: min(220px, 64vw);
  height: auto;
}

#globalLoader .loading-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #0f2f57;
}

#globalLoader .loader-subtext {
  margin: 6px 0 0;
  min-height: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #3f5f87;
}

#globalLoader .loading-dots::after {
  content: "";
  animation: loaderDots 1.4s steps(4, end) infinite;
}

#globalLoader .loader-skeleton {
  display: grid;
  gap: 8px;
  margin: 14px auto 0;
}

#globalLoader .loader-skeleton-line {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(189, 205, 226, 0.55) 20%,
    rgba(232, 240, 251, 0.95) 50%,
    rgba(189, 205, 226, 0.55) 80%
  );
  background-size: 220% 100%;
  animation: loaderShimmer 1.1s ease-in-out infinite;
}

#globalLoader .loader-skeleton-line:nth-child(1) {
  width: 100%;
}

#globalLoader .loader-skeleton-line:nth-child(2) {
  width: 86%;
}

#globalLoader .loader-skeleton-line:nth-child(3) {
  width: 72%;
}

/* Generic Spinner Helpers */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #111827;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

button.loading {
  pointer-events: none;
  opacity: 0.75;
}

button .spinner {
  display: none;
}

button.loading .spinner {
  display: inline-block;
}

.inline-loader {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
}

.inline-loader .spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.18em;
}

/* Skeleton Utilities */
.skeleton-loader {
  display: grid;
  gap: 10px;
}

.skeleton-line {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, #ebf0f6 25%, #dfe6ef 50%, #ebf0f6 75%);
  background-size: 220% 100%;
  animation: loaderShimmer 1.2s ease-in-out infinite;
}

.skeleton-line:nth-child(1) {
  width: 100%;
}

.skeleton-line:nth-child(2) {
  width: 84%;
}

.skeleton-line:nth-child(3) {
  width: 68%;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loaderShimmer {
  0% {
    background-position: 190% 0;
  }
  100% {
    background-position: -40% 0;
  }
}

@keyframes loaderDots {
  0%,
  20% {
    content: "";
  }
  40% {
    content: ".";
  }
  60% {
    content: "..";
  }
  80%,
  100% {
    content: "...";
  }
}

@media (max-width: 640px) {
  #globalLoader .loader-content {
    width: min(320px, 94vw);
    padding: 16px 14px;
  }

  #globalLoader .loader-brand img {
    width: min(180px, 62vw);
  }

  #globalLoader .loading-text {
    font-size: 0.92rem;
  }

  #globalLoader .loader-subtext {
    font-size: 0.8rem;
  }
}
