/* =========================================================
   ZENITE METAL — Animações futuristas (reutilizáveis)
   Carregar DEPOIS de css/tema-zenite.css  (+ js/zt-animacoes.js)

   AUTOMÁTICO em qualquer página com <body class="zt-theme">:
     entrada escalonada dos cards, sidebar, hero, tabelas,
     brilho que segue o rato nos cards, ripple nos botões,
     contadores nos números "stat", transição suave de tema.

   CLASSES UTILITÁRIAS (para o resto da aplicação):
     .zt-anim-up | .zt-anim-in | .zt-anim-left | .zt-anim-zoom   entradas
     .zt-anim-float | .zt-anim-pulse | .zt-anim-glow            contínuas
     .zt-anim-border     luz a percorrer o contorno (usa --c: r,g,b)
     .zt-anim-shimmer    brilho a passar (skeleton / destaque)
     style="--zt-i:2"    atraso escalonado (×80ms) em qualquer uma
     data-zt-reveal      aparece ao fazer scroll
     data-zt-count       número que "conta" (sobe/desce do valor anterior quando muda)
     data-zt-particles   (num contentor) fundo de partículas

   Desligar tudo: ZTAnim.set(false)  ou  <html data-zt-anim="off">
   Modo leve (automático no Firefox): <html class="zt-lite">  ·  forçar completo: ZTAnim.set('full')
   ========================================================= */

html[data-theme="dark"]  { --zt-glow-rgb: 45, 168, 255; }
html[data-theme="light"] { --zt-glow-rgb: 22, 112, 216; }

:root {
	--zt-ease: cubic-bezier(.22, 1, .36, 1);
	--zt-spring: cubic-bezier(.34, 1.56, .64, 1);
}

@property --zt-ang {
	syntax: "<angle>";
	inherits: false;
	initial-value: 0deg;
}

/* ---------- Keyframes ---------- */
@keyframes zt-rise     { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }
@keyframes zt-fade     { from { opacity: 0; } to { opacity: 1; } }
@keyframes zt-left     { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes zt-zoom     { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: none; } }
@keyframes zt-grow     { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes zt-float    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes zt-breathe  { 0%, 100% { box-shadow: 0 0 10px rgba(var(--zt-glow-rgb), .25); } 50% { box-shadow: 0 0 26px rgba(var(--zt-glow-rgb), .65); } }
@keyframes zt-pulse-s  { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes zt-spin     { to { --zt-ang: 360deg; } }
@keyframes zt-flow     { to { background-position: 200% 0; } }
@keyframes zt-shimmer  { from { transform: translateX(-120%); } to { transform: translateX(120%); } }
@keyframes zt-scan     { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@keyframes zt-blink    { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes zt-grid     { to { background-position: 42px 42px, 42px 42px; } }
@keyframes zt-pin-drop { 0% { opacity: 0; translate: 0 -26px; } 60% { opacity: 1; translate: 0 3px; } 100% { opacity: 1; translate: 0 0; } }
@keyframes zt-dd-slide { from { opacity: 0; translate: 0 -10px; } to { opacity: 1; translate: 0 0; } }
@keyframes zt-row-flash{ 0% { background: rgba(var(--zt-glow-rgb), .38); } 100% { background: transparent; } }
@keyframes zt-ripple   { to { transform: scale(3.2); opacity: 0; } }
@keyframes zt-rotate   { to { rotate: 360deg; } }

/* ---------- Utilitárias ---------- */
.zt-anim-up    { animation: zt-rise .7s var(--zt-ease) backwards; animation-delay: calc(var(--zt-i, 0) * 80ms); }
.zt-anim-in    { animation: zt-fade .8s ease backwards;          animation-delay: calc(var(--zt-i, 0) * 80ms); }
.zt-anim-left  { animation: zt-left .6s var(--zt-ease) backwards; animation-delay: calc(var(--zt-i, 0) * 80ms); }
.zt-anim-zoom  { animation: zt-zoom .6s var(--zt-spring) backwards; animation-delay: calc(var(--zt-i, 0) * 80ms); }
.zt-anim-float { animation: zt-float 4s ease-in-out infinite; }
.zt-anim-pulse { animation: zt-pulse-s 2.4s ease-in-out infinite; }
.zt-anim-glow  { animation: zt-breathe 2.8s ease-in-out infinite; }

.zt-anim-border { --c: var(--zt-glow-rgb); position: relative; }
.zt-anim-border::before,
.zt-theme .stat-card::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	padding: 1.5px;
	background: conic-gradient(from var(--zt-ang), transparent 0 72%, rgba(var(--c), .95) 92%, transparent 100%);
	-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, linear-gradient(#000 0 0);
	mask-composite: exclude;
	animation: zt-spin 5s linear infinite;
	pointer-events: none;
}

.zt-anim-shimmer { position: relative; overflow: hidden; }
.zt-anim-shimmer::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .18) 50%, transparent 70%);
	animation: zt-shimmer 2.2s ease-in-out infinite;
	pointer-events: none;
}

/* aparecer ao fazer scroll (a classe .zt-js é posta pelo JS) */
html.zt-js [data-zt-reveal] {
	opacity: 0;
	transform: translateY(22px);
	transition: opacity .7s var(--zt-ease), transform .7s var(--zt-ease);
	transition-delay: calc(var(--zt-i, 0) * 80ms);
}
html.zt-js [data-zt-reveal].is-in { opacity: 1; transform: none; }

/* ---------- Dashboard / páginas: entrada escalonada ---------- */
.zt-theme .zt-hero-bar {
	transform-origin: left center;
	animation: zt-grow .9s var(--zt-ease) .3s backwards;
	position: relative;
	overflow: hidden;
}
.zt-theme .zt-hero-bar::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .9), transparent);
	animation: zt-shimmer 2.6s ease-in-out 1.2s infinite;
}

/* "Dashboard" a fluir no destaque do título */
.zt-theme .zt-hero h1 span {
	background: linear-gradient(90deg, var(--zt-accent-2), var(--zt-accent), var(--zt-accent-2));
	background-size: 200% 100%;
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	animation: zt-flow 6s linear infinite;
}

/* ---------- ENTRADA DAS CARDS: só depois de a página estar montada ----------
   Antes, as cards animavam enquanto o browser ainda montava a página (tabela, ícones,
   gráfico). Nos PCs lentos, quando ele conseguia desenhar, a animação já tinha acabado
   e aparecia tudo de uma vez, aos solavancos.
   Agora: as cards esperam escondidas (com a barra de carregamento no topo) até o
   zt-animacoes.js pôr a classe .zt-ready no <html>; só aí entram, uma a uma.
   Segurança: se o JS não correr, aparecem sozinhas ao fim de 2,5 s. */
@keyframes zt-wait { from, to { opacity: 0; } }

.zt-theme .container-fluid > .row > [class*="col"],
.zt-theme .zt-hero h1,
.zt-theme .zt-hero p,
.zt-theme .zt-hero-ico,
.zt-theme .zt-page-head {
	animation: zt-wait 2.5s linear backwards;
}
html.zt-ready .zt-theme .container-fluid > .row > [class*="col"] {
	animation: zt-rise .45s var(--zt-ease) backwards;
	animation-delay: calc((var(--zt-base, 0) + var(--zt-i, 0)) * 60ms);
}
html.zt-ready .zt-theme .zt-hero h1,
html.zt-ready .zt-theme .zt-hero-ico,
html.zt-ready .zt-theme .zt-page-head { animation: zt-rise .45s var(--zt-ease) backwards; }
html.zt-ready .zt-theme .zt-hero p { animation: zt-rise .45s var(--zt-ease) .05s backwards; }

/* modo leve (Firefox / PCs fracos): só aparecer suavemente, sem deslocar */
html.zt-lite.zt-ready .zt-theme .container-fluid > .row > [class*="col"],
html.zt-lite.zt-ready .zt-theme .zt-hero h1,
html.zt-lite.zt-ready .zt-theme .zt-hero p,
html.zt-lite.zt-ready .zt-theme .zt-hero-ico,
html.zt-lite.zt-ready .zt-theme .zt-page-head { animation-name: zt-fade; animation-duration: .35s; }

/* página que demorou demasiado (já apareceu pela segurança): não volta a animar */
html.zt-late .zt-theme .container-fluid > .row > [class*="col"],
html.zt-late .zt-theme .zt-hero h1,
html.zt-late .zt-theme .zt-hero p,
html.zt-late .zt-theme .zt-hero-ico,
html.zt-late .zt-theme .zt-page-head { animation: none; }

/* barra de carregamento fina no fundo da barra de topo, enquanto a página se monta */
.zt-theme .navbar-bg::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -1px;
	height: 2px;
	z-index: 2;
	pointer-events: none;
	opacity: 0;
	background: linear-gradient(90deg, transparent, #2da8ff, #22d3ee, transparent) no-repeat;
	background-size: 35% 100%;
	transition: opacity .3s;
}
html:not(.zt-ready) .zt-theme .navbar-bg::before {
	opacity: 1;
	animation: zt-scan 1.1s linear infinite;
}

.zt-theme .container-fluid > .row ~ .row > [class*="col"] { --zt-base: 3; }
.zt-theme .container-fluid > .row > [class*="col"]:nth-child(1) { --zt-i: 0; }
.zt-theme .container-fluid > .row > [class*="col"]:nth-child(2) { --zt-i: 1; }
.zt-theme .container-fluid > .row > [class*="col"]:nth-child(3) { --zt-i: 2; }
.zt-theme .container-fluid > .row > [class*="col"]:nth-child(4) { --zt-i: 3; }
.zt-theme .container-fluid > .row > [class*="col"]:nth-child(5) { --zt-i: 4; }
.zt-theme .container-fluid > .row > [class*="col"]:nth-child(6) { --zt-i: 5; }
.zt-theme .container-fluid > .row > [class*="col"]:nth-child(7) { --zt-i: 6; }
.zt-theme .container-fluid > .row > [class*="col"]:nth-child(8) { --zt-i: 7; }

/* sidebar: sem animação de entrada — é igual em todas as páginas, por isso fica parada ao mudar de página */

.zt-theme .sidebar-link svg,
.zt-theme .sidebar-link i { transition: transform .3s var(--zt-spring), color .2s; }
.zt-theme .sidebar-link:hover svg,
.zt-theme .sidebar-link:hover i { transform: translateX(3px) scale(1.12); }
.zt-theme .sidebar-item.active > .sidebar-link { animation: zt-breathe 3.2s ease-in-out infinite; }

/* ---------- Cards ---------- */
.zt-theme .card {
	transition: transform .35s var(--zt-ease), box-shadow .35s, border-color .35s;
}
.zt-theme .card:not(.zt-map-card):hover {
	transform: translateY(-3px);
	border-color: rgba(var(--zt-glow-rgb), .5);
	box-shadow: var(--zt-shadow), 0 0 30px rgba(var(--zt-glow-rgb), .16);
}

/* luz que segue o rato (o JS define --mx / --my) */
.zt-theme .card:not(.zt-map-card)::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--zt-glow-rgb), .11), transparent 62%);
	opacity: 0;
	transition: opacity .3s;
	pointer-events: none;
}
.zt-theme .card:not(.zt-map-card):hover::after { opacity: 1; }
.zt-theme .card { position: relative; }

/* cards de estatística */
/* ícone: parado (a flutuação contínua distraía); só cresce um pouco ao passar o rato na card */
.zt-theme .stat-icon { transition: transform .35s var(--zt-spring); }
.zt-theme .stat-card:hover .stat-icon { transform: scale(1.06); }
.zt-theme .stat-card::before { z-index: 1; }

/* números a contar (JS): brilho verde quando sobe, vermelho quando desce */
.zt-theme .stat-info h1,
[data-zt-count] { transition: text-shadow .6s ease, filter .6s ease; }
.zt-count-up   { text-shadow: 0 0 14px rgba(16, 224, 140, .65); }
.zt-count-down { text-shadow: 0 0 14px rgba(255, 77, 109, .65); }
html[data-theme="light"] .zt-count-up   { text-shadow: 0 0 10px rgba(10, 159, 106, .35); }
html[data-theme="light"] .zt-count-down { text-shadow: 0 0 10px rgba(220, 53, 69, .35); }

/* ---------- Barra superior ---------- */
.zt-theme .navbar-bg::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -1px;
	height: 1px;
	background: linear-gradient(90deg, transparent, rgb(var(--zt-glow-rgb)), transparent) no-repeat;
	background-size: 30% 100%;
	animation: zt-scan 7s linear infinite;
	opacity: .8;
	pointer-events: none;
}

.zt-toggle .zt-opt svg { transition: transform .6s var(--zt-spring); }
html[data-theme="light"] .zt-toggle .zt-sun svg { transform: rotate(180deg); }
html[data-theme="dark"] .zt-toggle .zt-moon svg { transform: rotate(-20deg); }

.zt-theme .navbar .nav-icon .indicator { animation: zt-pulse-s 1.8s ease-in-out infinite; }

/* dropdowns: deslizam e a lista entra em cascata */
.zt-theme .dropdown-menu.show { animation: zt-dd-slide .22s var(--zt-ease), zt-fade .22s ease; }
.zt-theme .dropdown-menu.show .list-group-item { animation: zt-left .4s var(--zt-ease) backwards; }
.zt-theme .dropdown-menu.show .list-group-item:nth-child(1) { animation-delay: 105ms; }
.zt-theme .dropdown-menu.show .list-group-item:nth-child(2) { animation-delay: 150ms; }
.zt-theme .dropdown-menu.show .list-group-item:nth-child(3) { animation-delay: 195ms; }
.zt-theme .dropdown-menu.show .list-group-item:nth-child(4) { animation-delay: 240ms; }
.zt-theme .dropdown-menu.show .list-group-item:nth-child(5) { animation-delay: 285ms; }
.zt-theme .dropdown-menu.show .list-group-item:nth-child(6) { animation-delay: 330ms; }
.zt-theme .dropdown-menu.show .list-group-item:nth-child(7) { animation-delay: 375ms; }
.zt-theme .dropdown-menu.show .list-group-item:nth-child(8) { animation-delay: 420ms; }

/* ---------- Tabelas ---------- */
.zt-theme .table tbody tr { transition: box-shadow .2s, background .2s; }   /* sem animação de entrada: já entram com a coluna */

.zt-theme .table-hover tbody tr:hover { box-shadow: inset 3px 0 0 var(--zt-accent); }
.zt-theme .table tbody tr.zt-flash > * { animation: zt-row-flash 2.2s ease-out; }

.zt-pill::before { animation: zt-blink 1.8s ease-in-out infinite; }
/* nas tabelas o ponto fica fixo: centenas de pastilhas a piscar pesam muito (Firefox/PC fracos) */
.zt-theme td .zt-pill::before, .zt-theme .table .zt-pill::before { animation: none; }
.zt-pill:hover { filter: brightness(1.15); }

/* ---------- Calendário ---------- */
.zt-theme .flatpickr-day { transition: transform .2s var(--zt-spring), background .2s; }
.zt-theme .flatpickr-day:hover { transform: scale(1.14); }
.zt-theme .flatpickr-calendar .flatpickr-day.selected { animation: zt-breathe 2.8s ease-in-out infinite; }

/* ---------- Mapa ---------- */
html[data-theme="dark"] .zt-theme #map::after { animation: zt-grid 18s linear infinite; }

/* radar a varrer o mapa */
.zt-theme .zt-map-card::after {
	content: "";
	position: absolute;
	z-index: 450;
	left: 50%;
	top: 50%;
	width: 170%;
	aspect-ratio: 1;
	translate: -50% -50%;
	border-radius: 50%;
	background: conic-gradient(from 0deg, transparent 0deg, rgba(var(--zt-glow-rgb), .20) 46deg, transparent 47deg 360deg);
	animation: zt-rotate 8s linear infinite;   /* roda o elemento (GPU) em vez de redesenhar o gradiente */
	will-change: rotate;
	pointer-events: none;
}
html[data-theme="light"] .zt-theme .zt-map-card::after { opacity: .55; }

/* pinos "caem" no mapa */
.zt-theme .leaflet-marker-icon:not(.marker-cluster):not(.zt-country-label) {
	animation: zt-pin-drop .75s var(--zt-spring) backwards;
	transition: translate .25s var(--zt-spring);
}
.zt-theme .leaflet-marker-icon:not(.marker-cluster):not(.zt-country-label):nth-child(3n)   { animation-delay: .12s; }
.zt-theme .leaflet-marker-icon:not(.marker-cluster):not(.zt-country-label):nth-child(3n+1) { animation-delay: .24s; }
.zt-theme .leaflet-marker-icon:not(.marker-cluster):not(.zt-country-label):hover { translate: 0 -5px; }
.zt-theme .leaflet-bar a { transition: background .2s, box-shadow .2s, transform .2s var(--zt-spring); }
.zt-theme .leaflet-bar a:hover { transform: scale(1.08); }

/* ---------- Botões: ripple ---------- */
.zt-has-ripple { position: relative; overflow: hidden; }
.zt-ripple-wave {
	position: absolute;
	width: 60px;
	height: 60px;
	margin: -30px 0 0 -30px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .45);
	transform: scale(0);
	animation: zt-ripple .6s ease-out forwards;
	pointer-events: none;
}

.zt-theme .spinner-border { filter: drop-shadow(0 0 4px rgb(var(--zt-glow-rgb))); }

/* ---------- Partículas ---------- */
.zt-particles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- Transição suave ao trocar de tema ---------- */
html.zt-switching body.zt-theme *,
html.zt-switching body.zt-theme *::before,
html.zt-switching body.zt-theme *::after {
	transition: background-color .45s ease, color .45s ease, border-color .45s ease, box-shadow .45s ease, fill .45s ease !important;
}

/* ---------- Acessibilidade / desligar ---------- */
@media (prefers-reduced-motion: reduce) {
	.zt-theme *, .zt-theme *::before, .zt-theme *::after,
	.zt-anim-up, .zt-anim-in, .zt-anim-left, .zt-anim-zoom {
		animation-duration: .001ms !important;
		animation-iteration-count: 1 !important;
		animation-delay: 0s !important;
		transition-duration: .001ms !important;
	}
	html.zt-js [data-zt-reveal] { opacity: 1; transform: none; }
}

html[data-zt-anim="off"] .zt-theme *,
html[data-zt-anim="off"] .zt-theme *::before,
html[data-zt-anim="off"] .zt-theme *::after {
	animation: none !important;
	transition: none !important;
}
html[data-zt-anim="off"] [data-zt-reveal] { opacity: 1 !important; transform: none !important; }


/* =========================================================
   MODO LEVE (html.zt-lite) — ligado automaticamente no Firefox pelo zt-animacoes.js
   O Firefox desenha no processador principal os efeitos abaixo (gradientes a rodar,
   sombras a "respirar", desfoque de vidro), o que dá solavancos em PCs mais fracos.
   Aqui ficam parados/simplificados; as entradas, contadores e hovers mantêm-se.
   ========================================================= */
/* contornos com luz a rodar: ficam com um brilho fixo */
html.zt-lite .zt-theme .stat-card::before,
html.zt-lite .zt-anim-border::before,
html.zt-lite .zt-btn-glow::before { animation: none; --zt-ang: 200deg; }

/* sombras animadas (repintam a cada frame) */
html.zt-lite .zt-anim-glow,
html.zt-lite .zt-theme .sidebar-item.active > .sidebar-link,
html.zt-lite .zt-theme .flatpickr-calendar .flatpickr-day.selected { animation: none; }

/* gradientes a deslizar */
html.zt-lite .zt-theme .zt-hero h1 span,
html.zt-lite .zt-theme .navbar-bg::after,
html.zt-lite .zt-theme #map::after { animation: none; }

/* bolinha a piscar das pastilhas (centenas numa tabela) */
html.zt-lite .zt-pill::before { animation: none; }

/* vidro desfocado: troca por fundo mais opaco (o desfoque é o mais pesado no scroll) */
html.zt-lite .zt-theme .navbar-bg,
html.zt-lite .zt-theme .dropdown-menu,
html.zt-lite .zt-form-actions,
html.zt-lite .zt-theme .input-group-navbar,
html.zt-lite .zt-theme .modal-backdrop.show {
	backdrop-filter: none !important;
	-webkit-backdrop-filter: none !important;
}
html.zt-lite[data-theme="dark"] .zt-theme .navbar-bg { background: rgba(6, 15, 32, .94); }
html.zt-lite[data-theme="light"] .zt-theme .navbar-bg { background: rgba(255, 255, 255, .95); }
html.zt-lite[data-theme="dark"] .zt-form-actions { background: rgba(6, 15, 32, .92); }
html.zt-lite[data-theme="light"] .zt-form-actions { background: rgba(255, 255, 255, .95); }

/* hover dos cards: só sobe, sem sombra extra animada */
html.zt-lite .zt-theme .card { transition: transform .3s var(--zt-ease), border-color .3s; }


/* =========================================================
   TRANSIÇÃO ENTRE PÁGINAS
   Ao mudar de página, a barra lateral e a barra de topo ficam paradas
   e só o conteúdo faz um "fade" rápido. É o browser que trata disto,
   quase sem custo. Funciona no Edge/Chrome; nos browsers que ainda
   não suportam isto, as páginas abrem normalmente (com a entrada acima).
   ========================================================= */
@view-transition { navigation: auto; }

.zt-theme .sidebar     { view-transition-name: zt-sidebar; }
.zt-theme .navbar-bg   { view-transition-name: zt-navbar; }

/* elementos fixos: sem animação (ficam exatamente onde estão) */
::view-transition-group(zt-sidebar),
::view-transition-group(zt-navbar),
::view-transition-old(zt-sidebar), ::view-transition-new(zt-sidebar),
::view-transition-old(zt-navbar),  ::view-transition-new(zt-navbar) { animation: none; }

/* resto da página: fade curto */
::view-transition-old(root) { animation: zt-vt-out .16s ease-in both; }
::view-transition-new(root) { animation: zt-vt-in .22s ease-out both; }
@keyframes zt-vt-out { to { opacity: 0; } }
@keyframes zt-vt-in  { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
	::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
html[data-zt-anim="off"]::view-transition-old(root),
html[data-zt-anim="off"]::view-transition-new(root) { animation: none; }
.zt-particles { animation: zt-fade 1s ease both; }   /* partículas aparecem suavemente quando o browser fica livre */
