import React, { useEffect } from 'react';
import { HashRouter as Router, Routes, Route, useLocation } from 'react-router-dom';
import Navbar from './components/Navbar';
import Footer from './components/Footer';
import ScrollToTopButton from './components/ScrollToTop';
import Home from './pages/Home';
import ServicesPage from './pages/ServicesPage';
import ProjectsPage from './pages/ProjectsPage';
import AboutPage from './pages/AboutPage';
import ContactsPage from './pages/ContactsPage';
import FleetPage from './pages/FleetPage';
import CertificatesPage from './pages/CertificatesPage';
import SurveyingPage from './pages/SurveyingPage';
import DesignPage from './pages/DesignPage';
import ConstructionPage from './pages/ConstructionPage';
import SoilSurveyPage from './pages/SoilSurveyPage';
import BuildingSurveyPage from './pages/BuildingSurveyPage';
import LandSurveyPage from './pages/LandSurveyPage';
import TechnicalTasksPage from './pages/TechnicalTasksPage';
import SoilLabPage from './pages/SoilLabPage';
import RadiationLabPage from './pages/RadiationLabPage';
import PrivacyPolicyPage from './pages/PrivacyPolicyPage';

// Scroll to top on route change
const ScrollToTop = () => {
  const { pathname } = useLocation();
  useEffect(() => {
    window.scrollTo(0, 0);
  }, [pathname]);
  return null;
};

const App: React.FC = () => {
  return (
    <Router>
      <div className="w-full bg-white overflow-hidden font-sans flex flex-col min-h-screen">
        <ScrollToTop />
        <Navbar transparent={true} />
        <main className="flex-grow">
            <Routes>
            {/* Главная */}
            <Route path="/" element={<Home />} />
            <Route path="/en" element={<Home />} />

            {/* Услуги */}
            <Route path="/services" element={<ServicesPage />} />
            <Route path="/en/services" element={<ServicesPage />} />
            <Route path="/services/surveying" element={<SurveyingPage />} />
            <Route path="/en/services/surveying" element={<SurveyingPage />} />
            <Route path="/services/design" element={<DesignPage />} />
            <Route path="/en/services/design" element={<DesignPage />} />
            <Route path="/services/construction" element={<ConstructionPage />} />
            <Route path="/en/services/construction" element={<ConstructionPage />} />
            <Route path="/services/soil-survey" element={<SoilSurveyPage />} />
            <Route path="/en/services/soil-survey" element={<SoilSurveyPage />} />
            <Route path="/services/building-survey" element={<BuildingSurveyPage />} />
            <Route path="/en/services/building-survey" element={<BuildingSurveyPage />} />
            <Route path="/services/land-survey" element={<LandSurveyPage />} />
            <Route path="/en/services/land-survey" element={<LandSurveyPage />} />
            <Route path="/services/technical-tasks" element={<TechnicalTasksPage />} />
            <Route path="/en/services/technical-tasks" element={<TechnicalTasksPage />} />

            {/* Проекты */}
            <Route path="/projects" element={<ProjectsPage />} />
            <Route path="/en/projects" element={<ProjectsPage />} />

            {/* Автопарк */}
            <Route path="/fleet" element={<FleetPage />} />
            <Route path="/en/fleet" element={<FleetPage />} />

            {/* Лаборатории */}
            <Route path="/laboratories/soil" element={<SoilLabPage />} />
            <Route path="/en/laboratories/soil" element={<SoilLabPage />} />
            <Route path="/laboratories/radiation" element={<RadiationLabPage />} />
            <Route path="/en/laboratories/radiation" element={<RadiationLabPage />} />

            {/* Сертификаты */}
            <Route path="/certificates" element={<CertificatesPage />} />
            <Route path="/en/certificates" element={<CertificatesPage />} />

            {/* О компании */}
            <Route path="/about" element={<AboutPage />} />
            <Route path="/en/about" element={<AboutPage />} />

            {/* Контакты */}
            <Route path="/contacts" element={<ContactsPage />} />
            <Route path="/en/contacts" element={<ContactsPage />} />

            {/* Политика конфиденциальности */}
            <Route path="/privacy-policy" element={<PrivacyPolicyPage />} />
            <Route path="/en/privacy-policy" element={<PrivacyPolicyPage />} />
            </Routes>
        </main>
        <Footer />
        <ScrollToTopButton />
      </div>
    </Router>
  );
};

export default App;