import React, { useState, useEffect } from 'react';
import Navbar from './components/Navbar';
import Hero from './components/Hero';
import Features from './components/Features';
import HowItWorks from './components/HowItWorks';
import CallToAction from './components/CallToAction';
import Footer from './components/Footer';
import PrivacyPolicy from './components/PrivacyPolicy';

const App: React.FC = () => {
  const [currentPage, setCurrentPage] = useState<'home' | 'privacy'>('home');

  useEffect(() => {
    window.scrollTo(0, 0);
  }, [currentPage]);

  const navigateToPrivacy = (e?: React.MouseEvent) => {
    e?.preventDefault();
    setCurrentPage('privacy');
  };

  const navigateToHome = (e?: React.MouseEvent) => {
    e?.preventDefault();
    setCurrentPage('home');
  };

  return (
    <div className="bg-background-dark text-text-light font-sans min-h-screen selection:bg-primary selection:text-background-dark">
      <Navbar onLogoClick={navigateToHome} />
      <main>
        {currentPage === 'home' ? (
          <>
            <Hero />
            <Features />
            <HowItWorks />
            <CallToAction />
          </>
        ) : (
          <PrivacyPolicy onBack={navigateToHome} />
        )}
      </main>
      <Footer onPrivacyClick={navigateToPrivacy} />
    </div>
  );
};

export default App;
