/* ============================================================
   Login (views/login.ejs). Prefixo: lg-
   Base em /css/automation-ui.css (céu com nebulosas, luz girando no contorno, botão de
   estrelas). Aqui: o cartão no centro, com entrada em camadas; campos com rótulo que flutua,
   linha de foco e conferência do e-mail; aviso de erro que desce; tremida no erro; estados do
   botão (entrando, deu certo); e a transição de saída (hiperespaço + clarão), desenhada pelo
   /js/login.js.
   ============================================================ */

@keyframes lgEnter {
  0%   { opacity: 0; transform: translateY(36px) scale(0.9); filter: blur(12px); }
  60%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes lgIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes lgFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes lgGlow {
  0%, 100% { filter: drop-shadow(0 0 14px rgba(67, 210, 208, 0.25)) drop-shadow(0 0 30px rgba(94, 57, 188, 0.15)); }
  50%      { filter: drop-shadow(0 0 22px rgba(67, 210, 208, 0.45)) drop-shadow(0 0 44px rgba(94, 57, 188, 0.3)); }
}
@keyframes lgHalo { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes lgShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-9px); }
  40%, 60% { transform: translateX(9px); }
}
@keyframes lgPulseRed { 0% { box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.9), 0 0 0 0 rgba(248, 113, 113, 0.45); } 100% { box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.75), 0 0 0 10px rgba(248, 113, 113, 0); } }
@keyframes lgPop { 0% { opacity: 0; transform: translateY(-50%) scale(0.3); } 70% { transform: translateY(-50%) scale(1.15); } 100% { opacity: 1; transform: translateY(-50%) scale(1); } }
@keyframes lgPopIn { 0% { opacity: 0; transform: scale(0.3); } 70% { transform: scale(1.2); } 100% { opacity: 1; transform: scale(1); } }
@keyframes lgSpin { to { transform: rotate(360deg); } }
@keyframes lgShine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes lgHint { 0%, 100% { color: rgba(255, 255, 255, 0.45); } 50% { color: #fff; text-shadow: 0 0 12px rgba(67, 210, 208, 0.6); } }

/* ── Página ── */
body.lg-body { min-height: 100dvh; margin: 0; overflow-x: hidden; background: #03011f; font-family: 'Space Grotesk', system-ui, sans-serif; }
body.lg-body .nebula-sky-layers { z-index: 1; }
/* O halo é mais largo que o cartão: recortado aqui para o celular não montar a página mais larga que a tela */
.lg { position: relative; z-index: 2; display: grid; place-items: center; min-height: 100dvh; padding: 32px 16px; overflow-x: hidden; overflow-x: clip; }
.lg-stage { position: relative; width: min(430px, 100%); }

/* Halo girando atrás do cartão */
.lg-halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(67, 210, 208, 0.22), rgba(70, 164, 242, 0.05) 25%, rgba(94, 57, 188, 0.25) 50%, rgba(167, 139, 250, 0.05) 75%, rgba(67, 210, 208, 0.22));
  filter: blur(60px);
  opacity: 0.85;
  transform: translate(-50%, -50%);
  animation: lgHalo 40s linear infinite;
  pointer-events: none;
  transition: opacity 0.6s ease, filter 0.6s ease;
}

/* ── Cartão ── */
.lg-card {
  position: relative;
  padding: 30px 30px 24px;
  border-radius: 26px;
  color: rgba(255, 255, 255, 0.88);
  background: linear-gradient(165deg, rgba(94, 57, 188, 0.16), rgba(6, 3, 38, 0.72) 55%, rgba(6, 3, 38, 0.82));
  border: 1px solid rgba(94, 57, 188, 0.35);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 60px rgba(94, 57, 188, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  animation: lgEnter 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* Luz girando no contorno (a mesma dos painéis) */
.lg-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(from var(--au-angle), transparent 0deg, rgba(67, 210, 208, 0.95) 50deg, rgba(70, 164, 242, 0.85) 95deg, rgba(94, 57, 188, 0.95) 140deg, transparent 200deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  opacity: 0.8;
  animation: auEdge 7s linear infinite;
}
.lg-card-aurora { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.lg-card-aurora::before {
  content: '';
  position: absolute;
  inset: -40% -20% 40%;
  background:
    radial-gradient(40% 50% at 20% 40%, rgba(67, 210, 208, 0.18), transparent 70%),
    radial-gradient(35% 45% at 75% 30%, rgba(94, 57, 188, 0.3), transparent 70%);
  filter: blur(14px);
  animation: auAurora 14s ease-in-out infinite alternate;
}
.lg-card > :not(.lg-card-aurora) { position: relative; z-index: 1; }

/* Entrada em camadas: cada parte sobe na sua vez (--d) */
.lg-in { animation: lgIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(0.35s + var(--d, 0) * 0.08s); }

/* ── Cabeçalho ── */
.lg-head { display: flex; flex-direction: column; align-items: center; text-align: center; }
.lg-logo { display: block; height: 128px; width: auto; margin-bottom: 14px; animation: lgIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.35s both, lgFloat 6s ease-in-out 1.1s infinite, lgGlow 4s ease-in-out infinite; }
.lg-title { margin: 0; font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; background: linear-gradient(90deg, #fff 0%, #c9f5f4 45%, #b9a4f5 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lg-sub { margin: 6px 0 0; font-size: 0.86rem; color: rgba(255, 255, 255, 0.55); }

/* ── Aviso de erro (desce e sobe; vermelho para e-mail/senha, âmbar para o resto) ── */
.lg-alert { display: grid; grid-template-rows: 0fr; margin-top: 0; opacity: 0; transition: grid-template-rows 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease, margin-top 0.4s ease; }
.lg-alert.is-shown { grid-template-rows: 1fr; margin-top: 18px; opacity: 1; }
.lg-alert-inner { display: flex; align-items: flex-start; gap: 10px; min-height: 0; overflow: hidden; padding: 0 14px; border-radius: 14px; font-size: 0.84rem; line-height: 1.5; color: #fecaca; background: rgba(239, 68, 68, 0.1); box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.38); transition: padding 0.4s ease; }
.lg-alert.is-shown .lg-alert-inner { padding: 11px 14px; }
.lg-alert-icon { flex-shrink: 0; margin-top: 2px; color: #f87171; }
.lg-alert.is-shown .lg-alert-icon { animation: lgPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both; }
.lg-alert:not([data-kind="credentials"]):not([data-kind=""]) .lg-alert-inner { color: #fde68a; background: rgba(251, 191, 36, 0.08); box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.35); }
.lg-alert:not([data-kind="credentials"]):not([data-kind=""]) .lg-alert-icon { color: #fbbf24; }

/* ── Formulário ── */
.lg-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.lg-field { position: relative; height: 58px; border-radius: 15px; background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.11); transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease; }
.lg-field:hover { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22); }
.lg-field:focus-within { background: rgba(67, 210, 208, 0.05); box-shadow: inset 0 0 0 1px var(--nebula-teal), 0 0 0 4px rgba(67, 210, 208, 0.12), 0 10px 30px rgba(67, 210, 208, 0.12); transform: translateY(-1px); }
.lg-field input {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 22px 46px 6px 46px;
  border: 0;
  border-radius: inherit;
  font: inherit;
  font-size: 0.95rem;
  color: #fff;
  background: transparent;
  outline: none;
  color-scheme: dark;
}
.lg-field input:-webkit-autofill { -webkit-text-fill-color: #fff; transition: background-color 9999s ease-in-out 0s; caret-color: #fff; }
.lg-field label {
  position: absolute;
  top: 50%;
  left: 46px;
  margin: 0;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.5);
  transform: translateY(-50%);
  transform-origin: 0 50%;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), color 0.25s ease, top 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
/* O rótulo sobe quando o campo tem foco ou texto (inclusive preenchido pelo navegador) */
.lg-field input:focus + label,
.lg-field input:not(:placeholder-shown) + label,
.lg-field input:-webkit-autofill + label { top: 16px; transform: translateY(-50%) scale(0.76); color: var(--nebula-teal); }
.lg-field input:not(:focus):not(:placeholder-shown) + label { color: rgba(255, 255, 255, 0.55); }
.lg-field-icon { position: absolute; top: 50%; left: 16px; font-size: 1.05rem; color: rgba(255, 255, 255, 0.45); transform: translateY(-50%); transition: color 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.lg-field:focus-within .lg-field-icon { color: var(--nebula-teal); transform: translateY(-50%) scale(1.15) rotate(-8deg); }
/* Linha que acende do centro para as pontas no foco */
.lg-field-line { position: absolute; left: 16px; right: 16px; bottom: 0; height: 2px; border-radius: 2px; background: var(--nebula-gradient); transform: scaleX(0); transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
.lg-field:focus-within .lg-field-line { transform: scaleX(1); }
/* E-mail com formato certo: um visto aparece */
.lg-field-ok { position: absolute; top: 50%; right: 16px; color: #34d399; opacity: 0; transform: translateY(-50%) scale(0.3); pointer-events: none; }
#email:valid:not(:placeholder-shown) ~ .lg-field-ok { animation: lgPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.lg-field.is-invalid #email ~ .lg-field-ok { display: none; }

/* Campo com erro */
.lg-field.is-invalid { background: rgba(239, 68, 68, 0.06); animation: lgPulseRed 0.9s ease-out both; box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.75); }
.lg-field.is-invalid label,
.lg-field.is-invalid .lg-field-icon { color: #f87171; }
.lg-field.is-invalid .lg-field-line { background: linear-gradient(90deg, #f87171, #fb7185); transform: scaleX(1); }

/* Mostrar/ocultar a senha */
.lg-eye { position: absolute; top: 50%; right: 8px; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; font-size: 1.05rem; color: rgba(255, 255, 255, 0.5); background: transparent; transform: translateY(-50%); cursor: pointer; transition: color 0.2s ease, background 0.2s ease; }
.lg-eye:hover { color: #fff; background: rgba(67, 210, 208, 0.1); }
.lg-eye:focus-visible { outline: 2px solid var(--nebula-teal); outline-offset: 1px; }
.lg-eye .bi { transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.lg-eye[aria-pressed="true"] { color: var(--nebula-teal); }
.lg-eye.is-flip .bi { transform: rotateY(180deg) scale(1.15); }

/* Caps Lock */
.lg-caps { display: flex; align-items: center; gap: 7px; height: 0; margin: -6px 0 0; overflow: hidden; font-size: 0.76rem; font-weight: 600; color: #fde68a; opacity: 0; transform: translateY(-4px); transition: height 0.3s ease, opacity 0.3s ease, transform 0.3s ease, margin 0.3s ease; }
.lg-caps.is-on { height: 20px; margin: -4px 0 0; opacity: 1; transform: none; }

/* ── Botão Entrar (o de estrelas do hub) ── */
.lg-submit { width: 100%; height: 52px; margin-top: 6px; font-size: 0.98rem; overflow: visible; }
.lg-submit-label { gap: 10px; }
.lg-submit-arrow { transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.lg-submit:hover:not(:disabled) .lg-submit-arrow { transform: translateX(5px); }
.lg-submit-spin,
.lg-submit-ok { display: none; }
.lg-submit-spin { width: 17px; height: 17px; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%; animation: lgSpin 0.75s linear infinite; }
/* Entrando: brilho passando no botão e o spinner no lugar da seta */
.lg-card.is-loading .lg-submit { cursor: progress; background: linear-gradient(110deg, #43D2D0 0%, #46A4F2 30%, #c9f5f4 45%, #5E39BC 60%, #46A4F2 80%, #43D2D0 100%); background-size: 200% 100%; animation: lgShine 1.4s linear infinite; opacity: 1; }
.lg-card.is-loading .lg-submit-spin { display: inline-block; }
.lg-card.is-loading .lg-submit-arrow { display: none; }
/* Deu certo: verde com o visto */
.lg-card.is-success .lg-submit { background: linear-gradient(135deg, #10b981, #34d399 50%, #43D2D0); box-shadow: 0 0 30px rgba(52, 211, 153, 0.5); opacity: 1; }
.lg-card.is-success .lg-submit-ok { display: inline-block; font-size: 1.2rem; animation: lgPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.lg-card.is-success .lg-submit-arrow,
.lg-card.is-success .lg-submit-spin { display: none; }
.lg-card.is-loading .lg-submit::before,
.lg-card.is-success .lg-submit::before { opacity: 0 !important; }

/* Ajuda (pisca depois de errar a senha mais de uma vez) */
.lg-help { margin: 20px 0 0; font-size: 0.78rem; line-height: 1.55; text-align: center; color: rgba(255, 255, 255, 0.45); }
.lg-help a { color: var(--nebula-teal); text-decoration: none; }
.lg-help a:hover { text-decoration: underline; }
.lg-help.is-hint { animation: lgHint 1.6s ease-in-out 2; }

/* Tremida no erro */
.lg-card.is-shaking { animation: lgShake 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

/* ── Saída: o cartão vai ao fundo enquanto as estrelas viram riscos (hiperespaço) ── */
.lg-warp { position: fixed; inset: 0; z-index: 5; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity 0.35s ease; }
.lg-flash { position: fixed; inset: 0; z-index: 6; pointer-events: none; opacity: 0; background: radial-gradient(circle at var(--fx, 50%) var(--fy, 50%), #ffffff 0%, rgba(201, 245, 244, 0.95) 16%, rgba(67, 210, 208, 0.62) 34%, rgba(94, 57, 188, 0.62) 58%, #03011f 90%); transition: opacity 0.45s ease; }
body.lg-leaving .lg-warp { opacity: 1; }
body.lg-leaving .lg-card { animation: none; transform: scale(0.82); opacity: 0; filter: blur(8px); transition: transform 0.9s cubic-bezier(0.55, 0, 0.75, 0.25), opacity 0.7s ease 0.15s, filter 0.7s ease; }
body.lg-leaving .lg-halo { opacity: 0; filter: blur(90px); }
body.lg-leaving .nebula-sky-layers,
body.lg-leaving .au-sky { opacity: 0; transition: opacity 0.8s ease; }
body.lg-flashing .lg-flash { opacity: 1; }
/* Fim: tudo no fundo escuro da Home, para a chegada parecer contínua */
.lg-flash::after { content: ''; position: absolute; inset: 0; background: #03011f; opacity: 0; transition: opacity 0.35s ease; }
body.lg-done .lg-flash::after { opacity: 1; }

/* ── Telas pequenas ── */
@media (max-width: 480px) {
  .lg-card { padding: 24px 18px 20px; border-radius: 22px; }
  .lg-logo { height: 104px; }
  .lg-title { font-size: 1.35rem; }
}

/* ── Menos movimento ── */
@media (prefers-reduced-motion: reduce) {
  .lg-card,
  .lg-in,
  .lg-logo,
  .lg-halo,
  .lg-card::before,
  .lg-card-aurora::before,
  .lg-card.is-shaking,
  .lg-field.is-invalid,
  .lg-help.is-hint { animation: none !important; }
  .lg-field,
  .lg-field label,
  .lg-alert { transition-duration: 0.01ms !important; }
}
