/* Overlay de carga global para OAuth que persiste durante reloads */
#oauth-global-loading {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  isolation: isolate;
  /* Por defecto INVISIBLE - controlado solo por clase .active */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  /* Transición instantánea para aparecer, suave para desaparecer */
  transition: opacity 0.3s ease-out 0s, visibility 0s 0.3s;
}

#oauth-global-loading.active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  /* Sin delay al aparecer */
  transition: opacity 0s, visibility 0s;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  #oauth-global-loading {
    background: #111827;
  }
}

/* Contenedor principal del contenido */
#oauth-global-loading > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Fijar dimensiones para evitar saltos al cambiar texto */
  min-width: 500px;
  min-height: 300px;
}

/* Loading spinner */
.oauth-loading-spinner {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}

.oauth-loading-spinner::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 4px solid rgba(59, 130, 246, 0.2);
  border-top-color: rgb(59, 130, 246);
  border-radius: 50%;
  animation: oauth-spin 2s linear infinite;
}

.oauth-loading-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: auto;
  background: linear-gradient(to bottom right, rgb(59, 130, 246), rgb(37, 99, 235));
  border-radius: 50%;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.oauth-loading-icon svg {
  width: 32px;
  height: 32px;
  color: white;
}

.oauth-loading-text {
  text-align: center;
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Fijar ancho para evitar saltos cuando cambia el texto */
  min-width: 400px;
  max-width: 500px;
}

.oauth-loading-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #111827;
  margin: 0 0 0.75rem 0;
  /* Fijar altura para evitar saltos */
  min-height: 2rem;
  line-height: 2rem;
  /* Transición suave si cambia el texto */
  transition: opacity 0.2s ease;
}

.oauth-loading-subtitle {
  color: #6b7280;
  margin: 0 0 1.5rem 0;
  max-width: 28rem;
  /* Fijar altura para evitar saltos */
  min-height: 1.5rem;
  line-height: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  .oauth-loading-title {
    color: white;
  }
  .oauth-loading-subtitle {
    color: #9ca3af;
  }
}

.oauth-loading-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.oauth-loading-dot {
  width: 8px;
  height: 8px;
  background: rgb(59, 130, 246);
  border-radius: 50%;
  animation: oauth-pulse 1.5s ease-in-out infinite;
}

.oauth-loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.oauth-loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

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

@keyframes oauth-pulse {
  0%, 100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}
