/* Header com navegacao ancorada, scroll suave, secao ativa e menu mobile */ const NAV_LINKS = [ { id: 'inicio', label: 'Início' }, { id: 'solucoes', label: 'Soluções' }, { id: 'recursos', label: 'Recursos' }, { id: 'como-funciona', label: 'Como Funciona' }, { id: 'precos', label: 'Preços' }, { id: 'contato', label: 'Contato' } ]; function scrollToSection(id) { const el = document.getElementById(id); if (!el) return; el.scrollIntoView({ behavior: 'smooth', block: 'start' }); if (history.replaceState) history.replaceState(null, '', '#' + id); } window.scrollToSection = scrollToSection; function Header() { const [scrolled, setScrolled] = React.useState(false); const [open, setOpen] = React.useState(false); const [active, setActive] = React.useState('inicio'); React.useEffect(() => { const onScroll = () => { setScrolled(window.scrollY > 20); // secao ativa: a ultima cujo topo ja passou do offset do header. // No fim da pagina, forca a ultima secao (limite fisico de scroll). const offset = 120; let current = NAV_LINKS[0].id; for (const { id } of NAV_LINKS) { const el = document.getElementById(id); if (el && el.getBoundingClientRect().top <= offset) current = id; } const atBottom = window.innerHeight + window.scrollY >= document.body.scrollHeight - 4; if (atBottom) current = NAV_LINKS[NAV_LINKS.length - 1].id; setActive(current); }; onScroll(); window.addEventListener('scroll', onScroll, { passive: true }); window.addEventListener('resize', onScroll); return () => { window.removeEventListener('scroll', onScroll); window.removeEventListener('resize', onScroll); }; }, []); const go = (e, id) => { e.preventDefault(); setOpen(false); scrollToSection(id); }; return (
go(e, 'inicio')} style={{ display: 'flex', textDecoration: 'none' }}>
go(e, 'contato')} className="btn btn-primary hide-mobile"> Começar Agora {/* Botao hamburger — so no mobile */}
{/* Painel mobile */}
{NAV_LINKS.map(({ id, label }) => ( go(e, id)} style={{ color: active === id ? '#fff' : 'var(--text-dim)', fontSize: 15, fontWeight: 500, textDecoration: 'none', padding: '12px 8px', borderRadius: 8, background: active === id ? 'rgba(0,229,255,0.08)' : 'transparent' }}>{label} ))} go(e, 'contato')} className="btn btn-primary" style={{ justifyContent: 'center', marginTop: 10 }}> Começar Agora
); } window.Header = Header;