/* =========================
   SISTEMA DE LOADING
   ========================= */

/* Loader Global (Full Screen) */
.global-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.global-loader.active {
  opacity: 1;
  pointer-events: all;
}

.loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
}

.loader-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: white;
}

.loader-spinner {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary, #06b6d4);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-message {
  font-size: 1.125rem;
  font-weight: 500;
  margin: 0;
  color: white;
}

/* Loader en Elemento */
.element-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  z-index: 100;
  border-radius: var(--radius, 8px);
  gap: var(--space-md, 1rem);
}

.loader-spinner-small {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-secondary, #f1f5f9);
  border-top-color: var(--primary, #06b6d4);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-text {
  font-size: 0.875rem;
  color: var(--text-secondary, #64748b);
  font-weight: 500;
}

/* Loader en Botón */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}

.btn-spinner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
  vertical-align: middle;
}

.spinner-dot {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite both;
}

.spinner-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.spinner-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.spinner-dot:nth-child(3) {
  animation-delay: 0s;
}

/* Loader Inline (para tablas, listas) */
.inline-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl, 3rem);
  color: var(--text-secondary, #64748b);
  gap: var(--space-md, 1rem);
}

.inline-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-secondary, #f1f5f9);
  border-top-color: var(--primary, #06b6d4);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Skeleton Loader (para contenido que se está cargando) */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary, #f1f5f9) 0%,
    rgba(255, 255, 255, 0.5) 50%,
    var(--bg-secondary, #f1f5f9) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius, 8px);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5rem;
}

.skeleton-title {
  height: 1.5em;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-image {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius, 8px);
}

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

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Loader para formularios */
.form-loading {
  position: relative;
  pointer-events: none;
}

.form-loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-lg, 12px);
}

/* Loader para cards */
.card-loading {
  position: relative;
  min-height: 200px;
}

.card-loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-secondary, #f1f5f9);
  border-top-color: var(--primary, #06b6d4);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 1;
}

/* Responsive */
@media (max-width: 640px) {
  .loader-spinner {
    width: 48px;
    height: 48px;
  }

  .loader-message {
    font-size: 1rem;
  }

  .loader-spinner-small {
    width: 32px;
    height: 32px;
  }
}

