/* Tela de carregamento do System Commerce (identidade Mercom Tecnologia).
   Aparece no lugar da tela branca enquanto o sistema busca os dados da loja,
   e também logo depois de clicar em "Entrar" na tela de login.
   Usada em sistema.html e index.html (o HTML fica no começo do <body>). */

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
  color: #fff;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background:
    radial-gradient(ellipse 60% 50% at 50% 42%, rgba(37, 99, 235, 0.45), transparent 70%),
    linear-gradient(160deg, #0b1f4a 0%, #071537 55%, #040c24 100%);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.app-loader[hidden] { display: none; }
.app-loader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }

/* Rodinha: um anel azul que gira */
.app-loader__ring {
  position: relative;
  width: 56px;
  height: 56px;
}
.app-loader__ring::before,
.app-loader__ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.app-loader__ring::before { border: 3px solid rgba(255, 255, 255, 0.1); }
.app-loader__ring::after {
  border: 3px solid transparent;
  border-top-color: #60a5fa;
  border-right-color: #2563eb;
  animation: app-loader-spin 0.6s linear infinite;
  filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.6));
}

.app-loader__logo { width: 210px; max-width: 70vw; height: auto; display: block; }

.app-loader__text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}
.app-loader__status {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.88);
  transition: opacity 0.25s ease;
}
.app-loader__status.is-changing { opacity: 0; }

/* Barrinha de progresso que corre da esquerda para a direita */
.app-loader__bar {
  width: 220px;
  max-width: 60vw;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}
.app-loader__bar i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  animation: app-loader-bar 1.3s ease-in-out infinite;
}

.app-loader__footer {
  position: absolute;
  bottom: 28px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}
.app-loader__footer strong { color: rgba(255, 255, 255, 0.75); font-weight: 600; }

/* Modo rápido (F5 numa aba em que o sistema já abriu): fundo igual ao da página, sem logo nem frases.
   A rodinha pequena só aparece se o carregamento passar de meio segundo. */
.app-loader.is-quick { background: #f5f7fb; gap: 0; transition: opacity 0.2s ease, visibility 0.2s ease; }
.app-loader.is-quick .app-loader__logo,
.app-loader.is-quick .app-loader__text,
.app-loader.is-quick .app-loader__footer { display: none; }
.app-loader.is-quick .app-loader__ring { width: 36px; height: 36px; opacity: 0; animation: app-loader-show 0.25s ease 0.5s forwards; }
.app-loader.is-quick .app-loader__ring::before { border-color: rgba(37, 99, 235, 0.15); }
.app-loader.is-quick .app-loader__ring::after { border-top-color: #2563eb; border-right-color: #60a5fa; filter: none; }
@keyframes app-loader-show { to { opacity: 1; } }
@keyframes app-loader-spin { to { transform: rotate(360deg); } }
@keyframes app-loader-bar { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }

@media (prefers-reduced-motion: reduce) {
  .app-loader__ring::after { animation-duration: 1.2s; }
  .app-loader__bar i { animation: none; }
}
