/* MaqZAP: camada de movimento. Só decoração: nada aqui muda o funcionamento (e some com "reduzir movimento" do sistema). */

/* ---------- transição suave entre páginas (Chrome/Edge/Safari novos; os outros navegadores ignoram) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: mz-fade-out .16s ease both; }
::view-transition-new(root) { animation: mz-fade-in .32s var(--ease) both; }
@keyframes mz-fade-out { to { opacity: 0; } }
@keyframes mz-fade-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- fundo "aurora" bem sutil ---------- */
body::before {
  content: ""; position: fixed; inset: -20vmax; z-index: -1; pointer-events: none; opacity: .5;
  background:
    radial-gradient(38vmax 30vmax at 12% 18%, rgba(34, 197, 94, .16), transparent 60%),
    radial-gradient(34vmax 28vmax at 88% 12%, rgba(16, 185, 129, .12), transparent 60%),
    radial-gradient(40vmax 32vmax at 70% 92%, rgba(132, 204, 22, .10), transparent 60%);
  animation: mz-aurora 26s ease-in-out infinite alternate;
}
@keyframes mz-aurora { from { transform: translate3d(0, 0, 0) rotate(0deg); } to { transform: translate3d(3vmax, -2vmax, 0) rotate(6deg) scale(1.06); } }

/* ---------- entrada dos blocos ao rolar a página (classes colocadas pelo motion.js) ---------- */
.mz-reveal { opacity: 0; transform: translateY(22px) scale(.985); }
.mz-reveal.mz-in { animation: mz-reveal .7s var(--ease) both; animation-delay: calc(var(--mz-i, 0) * 70ms); }
@keyframes mz-reveal { from { opacity: 0; transform: translateY(22px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- menu lateral ---------- */
.sidebar nav a { position: relative; }
.sidebar nav a:hover { transform: translateX(4px); }
.sidebar nav a:hover .icon { color: var(--blue); animation: mz-wiggle .55s ease; }
.sidebar nav a.active:hover { transform: translateX(2px); }
.sidebar nav a.active { animation: mz-glow 3.2s ease-in-out infinite; }
.sidebar nav a::before {
  content: ""; position: absolute; left: -2px; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--blue);
  transform: scaleY(0); transition: transform .25s var(--ease);
}
.sidebar nav a:hover::before { transform: scaleY(1); }
.sidebar nav a.active::before { display: none; }
.sidebar.mz-ready nav a { animation: mz-slide-in .55s var(--ease) both; animation-delay: calc(var(--mz-i, 0) * 45ms); }
.sidebar.mz-ready nav a.active { animation: mz-slide-in .55s var(--ease) both, mz-glow 3.2s ease-in-out .8s infinite; animation-delay: calc(var(--mz-i, 0) * 45ms), 0s; }
@keyframes mz-slide-in { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes mz-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg) scale(1.1); } 60% { transform: rotate(9deg) scale(1.1); } }
@keyframes mz-glow { 0%, 100% { box-shadow: 0 6px 16px rgba(22, 163, 74, .32); } 50% { box-shadow: 0 8px 26px rgba(34, 197, 94, .55); } }
.brand-mark { animation: mz-float 4.5s ease-in-out infinite; background-size: 200% 200%; }
@keyframes mz-float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-3px) rotate(-3deg); } }
.topbar h1 { animation: mz-slide-in .6s var(--ease) both; }

/* ---------- botões ---------- */
.btn { position: relative; overflow: hidden; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.96); }
.btn-primary::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .38) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn-primary:hover::after { animation: mz-sheen .9s var(--ease); }
@keyframes mz-sheen { to { transform: translateX(120%); } }
.mz-ripple {
  position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); opacity: .5;
  background: rgba(255, 255, 255, .55); animation: mz-ripple .65s ease-out forwards;
}
.btn-ghost .mz-ripple, .btn:not(.btn-primary):not(.btn-danger) .mz-ripple { background: rgba(34, 197, 94, .35); }
@keyframes mz-ripple { to { transform: scale(1); opacity: 0; } }

/* ---------- cartões e quadros de números ---------- */
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kpi::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 35%, rgba(34, 197, 94, .14) 50%, transparent 65%);
  transform: translateX(-130%);
}
.kpi:hover::after { animation: mz-sheen 1s var(--ease); }
.kpi strong { font-variant-numeric: tabular-nums; }

/* ---------- etiquetas ---------- */
.pill { animation: mz-pop .45s cubic-bezier(.2, .9, .25, 1.3) both; }
@keyframes mz-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.pill-new, .pill-unanswered, .nav-badge { animation: mz-pop .45s cubic-bezier(.2, .9, .25, 1.3) both, mz-beat 2.4s ease-in-out .6s infinite; }
@keyframes mz-beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }

/* ---------- tabelas e listas ---------- */
tbody tr { animation: mz-row-in .5s var(--ease) both; }
tbody tr:nth-child(1) { animation-delay: .02s; } tbody tr:nth-child(2) { animation-delay: .06s; } tbody tr:nth-child(3) { animation-delay: .10s; }
tbody tr:nth-child(4) { animation-delay: .14s; } tbody tr:nth-child(5) { animation-delay: .18s; } tbody tr:nth-child(6) { animation-delay: .22s; }
tbody tr:nth-child(7) { animation-delay: .26s; } tbody tr:nth-child(8) { animation-delay: .30s; } tbody tr:nth-child(n+9) { animation-delay: .34s; }
@keyframes mz-row-in { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
tbody td { transition: background .2s, box-shadow .2s; }

/* ---------- avisos, barras e formulários ---------- */
.alert { animation: mz-drop .55s cubic-bezier(.2, .9, .25, 1.2) both; }
.alert.mz-leave { animation: mz-leave .45s ease forwards; }
@keyframes mz-drop { from { opacity: 0; transform: translateY(-18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes mz-leave { to { opacity: 0; transform: translateY(-10px); max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; } }
.bar > span { transform-origin: left center; animation: mz-bar 1.1s var(--ease) both; position: relative; overflow: hidden; }
.bar > span::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .45) 50%, transparent 80%);
  transform: translateX(-100%); animation: mz-sheen 2.6s ease-in-out 1.2s infinite;
}
@keyframes mz-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
input, select, textarea { transition: box-shadow .2s var(--ease), border-color .2s, transform .2s var(--ease); }
input:focus, select:focus, textarea:focus { transform: translateY(-1px); }
details[open] > :not(summary) { animation: mz-drop .35s var(--ease) both; }
.goal-trophy { display: inline-block; animation: mz-trophy 2.2s ease-in-out infinite; }
@keyframes mz-trophy { 0%, 100% { transform: rotate(0) scale(1); } 20% { transform: rotate(-14deg) scale(1.15); } 40% { transform: rotate(12deg) scale(1.15); } 60% { transform: rotate(0) scale(1); } }
.goal-banner { animation: mz-drop .7s cubic-bezier(.2, .9, .25, 1.25) both; }

/* ---------- confete (meta batida) ---------- */
.mz-confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.mz-confetti i {
  position: absolute; top: -12px; left: var(--x); width: 9px; height: 14px; border-radius: 2px; background: var(--c); opacity: 0;
  animation: mz-fall var(--t) cubic-bezier(.3, .6, .4, 1) var(--d) forwards;
}
@keyframes mz-fall { 0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); } 100% { opacity: 0; transform: translate3d(var(--dx), 105vh, 0) rotate(var(--r)); } }

/* ---------- login ---------- */
.login-page { position: relative; overflow: hidden; }
.login-page::before, .login-page::after { content: ""; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .45; pointer-events: none; }
.login-page::before { width: 38vmax; height: 38vmax; background: #22c55e; left: -10vmax; top: -12vmax; animation: mz-blob 14s ease-in-out infinite alternate; }
.login-page::after { width: 32vmax; height: 32vmax; background: #10b981; right: -8vmax; bottom: -10vmax; animation: mz-blob 18s ease-in-out infinite alternate-reverse; }
@keyframes mz-blob { from { transform: translate(0, 0) scale(1); } to { transform: translate(6vmax, 4vmax) scale(1.18); } }
.login-card { position: relative; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  body::before, .login-page::before, .login-page::after { animation: none; }
  .mz-reveal { opacity: 1; transform: none; }
}

/* Áreas que se atualizam sozinhas (lista de conversas, quadro): sem repetir a animação de entrada a cada atualização. */
[data-live-list] tbody tr, [data-board-live] tbody tr { animation: none; }
[data-live-list] .pill, [data-board-live] .pill { animation: none; }
[data-live-list] .pill-new, [data-live-list] .pill-unanswered { animation: mz-beat 2.4s ease-in-out infinite; }
[data-live-list] .conv-arrive > td { animation: row-flash 2.4s ease-out both; }
