import { BrowserRouter, Routes, Route, useLocation } from 'react-router-dom';
import { useEffect } from 'react';
import { Navbar } from './components/navbar';
import { Footer } from './components/footer';
import { Home } from './pages/home';
import { Services } from './pages/services';
import { About } from './pages/about';
import { Team } from './pages/team';
import { Blog } from './pages/blog';
import { BlogPost } from './pages/blog-post';
import { Features } from './pages/features';
import { Contact } from './pages/contact';
import { Results } from './pages/results';
import { NotFound } from './pages/not-found';
import { CookieBanner } from './components/cookie-banner';

function ScrollToTop() {
  const { pathname } = useLocation();
  useEffect(() => {
    window.scrollTo(0, 0);
  }, [pathname]);
  return null;
}

export default function App() {
  return (
    <BrowserRouter>
      <ScrollToTop />
      <div className="min-h-screen flex flex-col font-sans">
        <Navbar />
        <main className="flex-grow">
          <Routes>
            <Route path="/" element={<Home />} />
            <Route path="/sobre" element={<About />} />
            <Route path="/servicos" element={<Services />} />
            <Route path="/profissionais" element={<Team />} />
            <Route path="/resultados" element={<Results />} />
            <Route path="/diferenciais" element={<Features />} />
            <Route path="/blog" element={<Blog />} />
            <Route path="/blog/:id" element={<BlogPost />} />
            <Route path="/contato" element={<Contact />} />
            <Route path="*" element={<NotFound />} />
          </Routes>
        </main>
        <Footer />
        <CookieBanner />
      </div>
    </BrowserRouter>
  );
}
