/* Tela de login: camada visual e de movimento. Carregada só pelo index.html,
   depois de login-next e centtrallis-brand-v5. Não altera o fluxo do login. */

:root {
  --lm-blue: #2563eb;
  --lm-blue-2: #3b82f6;
  --lm-cyan: #22d3ee;
  --lm-pink: #f472b6;
  --lm-ink: #0b1220;
  --lm-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Painel da história (esquerda) ---------- */

.login-story {
  isolation: isolate;
  background:
    radial-gradient(120% 80% at 100% 0%, rgb(34 211 238 / 0.14), transparent 55%),
    radial-gradient(90% 70% at 0% 100%, rgb(37 99 235 / 0.2), transparent 60%),
    linear-gradient(150deg, #050b17 0%, #0a1830 55%, #0b2533 100%);
}
.login-story::before,
.login-story::after {
  z-index: 0;
}
.login-story::before {
  animation: lm-spin 90s linear infinite;
}

.story-constellation {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  animation: lm-fade 1.6s 0.3s var(--lm-ease) forwards;
  pointer-events: none;
}

.story-aurora {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  translate: calc(var(--lm-px, 0) * -18px) calc(var(--lm-py, 0) * -14px);
  transition: translate 0.9s var(--lm-ease);
}
.story-aurora i {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  mix-blend-mode: screen;
}
.story-aurora i:nth-child(1) {
  top: -12%;
  right: -8%;
  width: 46vmax;
  height: 46vmax;
  max-width: 620px;
  max-height: 620px;
  background: radial-gradient(circle, rgb(34 211 238 / 0.55), transparent 65%);
  animation: lm-drift-a 22s ease-in-out infinite alternate;
}
.story-aurora i:nth-child(2) {
  bottom: -18%;
  left: -12%;
  width: 52vmax;
  height: 52vmax;
  max-width: 700px;
  max-height: 700px;
  background: radial-gradient(circle, rgb(37 99 235 / 0.6), transparent 65%);
  animation: lm-drift-b 26s ease-in-out infinite alternate;
}
.story-aurora i:nth-child(3) {
  top: 38%;
  left: 38%;
  width: 30vmax;
  height: 30vmax;
  max-width: 420px;
  max-height: 420px;
  background: radial-gradient(circle, rgb(236 72 153 / 0.28), transparent 65%);
  animation: lm-drift-c 30s ease-in-out infinite alternate;
}

.story-orbit {
  position: absolute;
  top: 50%;
  right: -120px;
  z-index: 0;
  width: 460px;
  height: 460px;
  margin-top: -300px;
  pointer-events: none;
  translate: calc(var(--lm-px, 0) * 22px) calc(var(--lm-py, 0) * 18px);
  transition: translate 0.9s var(--lm-ease);
}
.story-orbit span {
  position: absolute;
  inset: 0;
  border: 1px solid rgb(148 197 255 / 0.1);
  border-radius: 50%;
  animation: lm-spin 38s linear infinite;
}
.story-orbit span:nth-child(2) {
  inset: 70px;
  border-color: rgb(34 211 238 / 0.14);
  animation-duration: 26s;
  animation-direction: reverse;
}
.story-orbit span:nth-child(3) {
  inset: 140px;
  border-color: rgb(148 197 255 / 0.12);
  animation-duration: 18s;
}
.story-orbit span::before {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--lm-cyan);
  box-shadow:
    0 0 12px 2px rgb(34 211 238 / 0.8),
    0 0 30px 6px rgb(34 211 238 / 0.25);
  content: '';
}
.story-orbit span:nth-child(2)::before {
  background: #93c5fd;
  box-shadow: 0 0 12px 2px rgb(147 197 253 / 0.8);
}
.story-orbit span:nth-child(3)::before {
  width: 6px;
  height: 6px;
  background: var(--lm-pink);
  box-shadow: 0 0 12px 2px rgb(244 114 182 / 0.8);
}

/* Entrada dos elementos */
.story-brand,
.story-copy > span,
.story-copy h2 .line,
.story-copy p,
.story-pulse,
.story-agents article,
.story-footer {
  /* backwards: o estado inicial vale durante o atraso e, no fim, o elemento
     volta aos próprios estilos — assim o hover ainda consegue usar translate. */
  animation: lm-rise 0.9s var(--lm-ease) backwards;
}
.story-brand {
  animation-delay: 0.05s;
}
.story-copy > span {
  animation-delay: 0.2s;
}
.story-copy h2 .line:nth-child(1) {
  animation-delay: 0.32s;
}
.story-copy h2 .line:nth-child(2) {
  animation-delay: 0.46s;
}
.story-copy p {
  animation-delay: 0.62s;
}
.story-pulse {
  animation-delay: 0.74s;
}
.story-agents article:nth-child(1) {
  animation-delay: 0.86s;
}
.story-agents article:nth-child(2) {
  animation-delay: 0.98s;
}
.story-footer {
  animation-delay: 1.1s;
}

.story-brand::before {
  animation: lm-logo-glow 4.5s ease-in-out infinite;
}

.story-copy > span {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 10px;
  border: 1px solid rgb(103 232 249 / 0.22);
  border-radius: 999px;
  background: rgb(103 232 249 / 0.06);
  backdrop-filter: blur(6px);
}
.live-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 10px rgb(74 222 128 / 0.8);
}
.live-dot::after {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #4ade80;
  animation: lm-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  content: '';
}

.story-copy h2 .line {
  display: block;
}
.story-copy h2 .accent {
  padding-bottom: 0.06em;
  background: linear-gradient(100deg, #ffffff 0%, #93c5fd 30%, #67e8f9 50%, #93c5fd 70%, #ffffff 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation:
    lm-rise 0.9s 0.46s var(--lm-ease) backwards,
    lm-sheen 7s 1.4s ease-in-out infinite;
}

.story-pulse {
  position: relative;
  width: min(100%, 560px);
  height: 46px;
  margin-top: 30px;
}
.story-pulse svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.pulse-track {
  fill: none;
  stroke: rgb(148 197 255 / 0.12);
  stroke-width: 1.5;
}
.pulse-line {
  fill: none;
  stroke: url(#pulseGradient);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 180 900;
  stroke-dashoffset: 180;
  filter: drop-shadow(0 0 6px rgb(34 211 238 / 0.7));
  animation: lm-pulse-run 3.6s 1s linear infinite;
}

.story-agents article {
  position: relative;
  overflow: hidden;
  transition:
    translate 0.35s var(--lm-ease),
    border-color 0.35s ease,
    background-color 0.35s ease,
    box-shadow 0.35s ease;
}
.story-agents article::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.07) 50%, transparent 65%);
  translate: -120% 0;
  content: '';
  animation: lm-card-sweep 6s 2.2s ease-in-out infinite;
}
.story-agents article:nth-child(2)::after {
  animation-delay: 3.4s;
}
.story-agents article:hover {
  border-color: rgb(147 197 253 / 0.3);
  background: rgb(255 255 255 / 0.075);
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.25);
  translate: 0 -3px;
}
.story-agents i {
  animation: lm-float 5s ease-in-out infinite;
}
.story-agents article:nth-child(2) i {
  animation-delay: -2.5s;
}
.agent-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.agent-status b {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
}
.agent-status b::after {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #4ade80;
  animation: lm-ping 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
  content: '';
}
.story-agents article:nth-child(2) .agent-status b::after {
  animation-delay: 1.1s;
}

/* ---------- Lado do formulário (direita) ---------- */

.login-side {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 32px 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(60% 50% at 80% 10%, rgb(59 130 246 / 0.1), transparent 70%),
    radial-gradient(50% 45% at 10% 95%, rgb(34 211 238 / 0.1), transparent 70%),
    #f3f6fb;
}
.side-grid {
  position: absolute;
  inset: -40px;
  z-index: -1;
  background-image: radial-gradient(rgb(37 99 235 / 0.16) 1px, transparent 1.2px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 20%, transparent 75%);
  animation: lm-grid-drift 40s linear infinite;
}
.side-glow {
  position: absolute;
  z-index: -1;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  pointer-events: none;
}
.side-glow.one {
  top: 8%;
  right: 6%;
  background: radial-gradient(circle, rgb(96 165 250 / 0.55), transparent 70%);
  animation: lm-drift-a 18s ease-in-out infinite alternate;
}
.side-glow.two {
  bottom: 4%;
  left: 4%;
  background: radial-gradient(circle, rgb(34 211 238 / 0.4), transparent 70%);
  animation: lm-drift-b 22s ease-in-out infinite alternate;
}

.login-card {
  position: relative;
  border-color: rgb(220 228 239 / 0.9);
  background: rgb(255 255 255 / 0.86);
  box-shadow:
    0 1px 0 rgb(255 255 255 / 0.9) inset,
    0 30px 80px -20px rgb(16 24 40 / 0.22),
    0 12px 30px -12px rgb(37 99 235 / 0.18);
  backdrop-filter: blur(18px) saturate(1.4);
  animation: lm-card-in 0.95s 0.15s var(--lm-ease) backwards;
}
/* Depois da entrada a animação sai do cartão; senão, trocar para a tremida
   e voltar reiniciaria a entrada. */
.login-card.is-ready {
  animation: none;
}
/* Borda em degradê girando atrás do cartão */
.login-card::before {
  position: absolute;
  inset: -1px;
  z-index: -1;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(
    from var(--lm-angle, 0deg),
    rgb(37 99 235 / 0.55),
    rgb(34 211 238 / 0.5),
    rgb(244 114 182 / 0.35),
    rgb(37 99 235 / 0.55)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
  opacity: 0.7;
  pointer-events: none;
  content: '';
  animation: lm-angle 8s linear infinite;
}
/* Brilho que acompanha o ponteiro */
.login-card::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: radial-gradient(
    420px circle at var(--lm-mx, 50%) var(--lm-my, -20%),
    rgb(59 130 246 / 0.1),
    transparent 45%
  );
  opacity: 0;
  pointer-events: none;
  content: '';
  transition: opacity 0.4s ease;
}
.login-card.is-hovered::after {
  opacity: 1;
}
.login-card > * {
  position: relative;
  z-index: 1;
}
.login-card > .eyebrow,
.login-card > h1,
.login-card > p,
#loginForm > * {
  animation: lm-rise 0.7s var(--lm-ease) backwards;
}
.login-card > .eyebrow {
  animation-delay: 0.35s;
}
.login-card > h1 {
  animation-delay: 0.43s;
}
.login-card > p:not(.login-feedback) {
  animation-delay: 0.51s;
}
#loginForm > :nth-child(1) {
  animation-delay: 0.58s;
}
#loginForm > :nth-child(2) {
  animation-delay: 0.62s;
}
#loginForm > :nth-child(3) {
  animation-delay: 0.68s;
}
#loginForm > :nth-child(4) {
  animation-delay: 0.72s;
}
#loginForm > :nth-child(5) {
  animation-delay: 0.78s;
}
#loginForm > :nth-child(6) {
  animation-delay: 0.84s;
}
.login-card > .login-feedback {
  animation-delay: 0.92s;
}

.login-card .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.login-card .eyebrow::before {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--lm-blue), var(--lm-cyan));
  content: '';
}

.field {
  position: relative;
}
.field-icon {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  color: #98a2b3;
  pointer-events: none;
  transition:
    color 0.25s ease,
    scale 0.25s var(--lm-ease);
}
#loginForm .field input:not([type='checkbox']) {
  padding-left: 44px;
  transition:
    border-color 0.25s ease,
    background-color 0.25s ease,
    box-shadow 0.25s ease;
}
#loginForm .field.has-toggle input {
  padding-right: 48px;
}
#loginForm .field input:hover {
  border-color: #b9c7da;
}
.field:focus-within .field-icon {
  color: var(--lm-blue);
  scale: 1.08;
}
#loginForm .field input:focus {
  box-shadow:
    0 0 0 4px rgb(37 99 235 / 0.12),
    0 8px 20px -10px rgb(37 99 235 / 0.35);
}
.field::after {
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--lm-blue), var(--lm-cyan));
  scale: 0 1;
  transform-origin: left;
  content: '';
  transition: scale 0.45s var(--lm-ease);
}
.field:focus-within::after {
  scale: 1 1;
}
.field-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 34px;
  height: 34px;
  margin-top: -17px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #98a2b3;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
.field-toggle:hover {
  background: rgb(37 99 235 / 0.08);
  color: var(--lm-blue);
}
.field-toggle:focus-visible {
  outline: 2px solid var(--lm-blue);
  outline-offset: 1px;
}
.field-toggle svg {
  width: 18px;
  height: 18px;
}
.field-toggle .eye-off {
  display: none;
}
.field-toggle[aria-pressed='true'] .eye-on {
  display: none;
}
.field-toggle[aria-pressed='true'] .eye-off {
  display: block;
}

.primary-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  overflow: hidden;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 45%, #1d4ed8 100%);
  background-size: 160% 100%;
  box-shadow:
    0 1px 0 rgb(255 255 255 / 0.25) inset,
    0 14px 30px -10px rgb(37 99 235 / 0.6);
  transition:
    background-position 0.5s var(--lm-ease),
    box-shadow 0.3s ease,
    translate 0.25s var(--lm-ease);
}
.primary-btn::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgb(255 255 255 / 0.35) 50%, transparent 70%);
  translate: -120% 0;
  content: '';
  animation: lm-btn-sheen 4.5s 1.6s ease-in-out infinite;
}
.primary-btn:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 45%, #1d4ed8 100%);
  background-size: 160% 100%;
  background-position: 100% 0;
  box-shadow:
    0 1px 0 rgb(255 255 255 / 0.25) inset,
    0 18px 36px -10px rgb(37 99 235 / 0.7);
  translate: 0 -2px;
}
.primary-btn:active {
  translate: 0 0;
}
.primary-btn:focus-visible {
  outline: 3px solid rgb(37 99 235 / 0.35);
  outline-offset: 3px;
}
.btn-arrow {
  width: 18px;
  height: 18px;
  transition: translate 0.3s var(--lm-ease);
}
.primary-btn:hover .btn-arrow {
  translate: 4px 0;
}
.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgb(255 255 255 / 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lm-spin 0.7s linear infinite;
}
.primary-btn:disabled {
  opacity: 0.9;
  translate: 0 0;
}
.primary-btn:disabled::before {
  animation-duration: 1.2s;
  animation-delay: 0s;
}
.primary-btn:disabled .btn-arrow {
  display: none;
}
.primary-btn:disabled .btn-spinner {
  display: block;
}

.remember input {
  transition: scale 0.2s var(--lm-ease);
}
.remember input:active {
  scale: 0.85;
}

.login-feedback {
  transition: color 0.3s ease;
}
.login-card.is-ready.is-shaking {
  animation: lm-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* ---------- Celular ---------- */
@media (max-width: 900px) {
  .login-side {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 0;
    background:
      radial-gradient(80% 50% at 90% 0%, rgb(34 211 238 / 0.22), transparent 60%),
      radial-gradient(80% 50% at 0% 100%, rgb(37 99 235 / 0.3), transparent 60%),
      linear-gradient(150deg, #050b17, #0a1830 60%, #0b2533);
  }
  .side-grid {
    background-image: radial-gradient(rgb(148 197 255 / 0.18) 1px, transparent 1.2px);
  }
  .login-card {
    background: rgb(255 255 255 / 0.94);
  }
}

/* ---------- Animações ---------- */
@property --lm-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
@keyframes lm-angle {
  to {
    --lm-angle: 360deg;
  }
}
@keyframes lm-fade {
  to {
    opacity: 1;
  }
}
@keyframes lm-rise {
  from {
    opacity: 0;
    translate: 0 18px;
    filter: blur(6px);
  }
  to {
    opacity: 1;
    translate: 0 0;
    filter: blur(0);
  }
}
@keyframes lm-card-in {
  from {
    opacity: 0;
    translate: 0 30px;
    scale: 0.97;
  }
  to {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
}
@keyframes lm-spin {
  to {
    rotate: 360deg;
  }
}
@keyframes lm-drift-a {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(-60px, 50px) scale(1.12);
  }
}
@keyframes lm-drift-b {
  from {
    transform: translate(0, 0) scale(1.05);
  }
  to {
    transform: translate(70px, -40px) scale(0.92);
  }
}
@keyframes lm-drift-c {
  from {
    transform: translate(0, 0) scale(0.9);
  }
  to {
    transform: translate(-80px, -60px) scale(1.15);
  }
}
@keyframes lm-ping {
  75%,
  100% {
    opacity: 0;
    scale: 2.6;
  }
}
@keyframes lm-sheen {
  0%,
  100% {
    background-position: 100% 0;
  }
  50% {
    background-position: 0% 0;
  }
}
@keyframes lm-pulse-run {
  from {
    stroke-dashoffset: 180;
  }
  to {
    stroke-dashoffset: -900;
  }
}
@keyframes lm-float {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -4px;
  }
}
@keyframes lm-card-sweep {
  0%,
  60% {
    translate: -120% 0;
  }
  85%,
  100% {
    translate: 120% 0;
  }
}
@keyframes lm-btn-sheen {
  0%,
  55% {
    translate: -120% 0;
  }
  80%,
  100% {
    translate: 120% 0;
  }
}
@keyframes lm-logo-glow {
  0%,
  100% {
    box-shadow: 0 12px 30px rgb(37 99 235 / 0.35);
  }
  50% {
    box-shadow:
      0 12px 36px rgb(37 99 235 / 0.55),
      0 0 0 6px rgb(59 130 246 / 0.12);
  }
}
@keyframes lm-grid-drift {
  to {
    background-position: 26px 26px;
  }
}
@keyframes lm-shake {
  10%,
  90% {
    translate: -1px 0;
  }
  20%,
  80% {
    translate: 3px 0;
  }
  30%,
  50%,
  70% {
    translate: -6px 0;
  }
  40%,
  60% {
    translate: 6px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-page *,
  .login-page *::before,
  .login-page *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.001ms !important;
  }
  .story-aurora,
  .story-orbit {
    translate: none;
  }
}
