import { Routes, Route, Navigate } from "react-router-dom";

import MainLayout from "./components/MainLayout";
import SubLayout from "./components/SubLayout";

// Main
import MainPage from "./pages/MainPage";

// Company
import CompanyAboutPage from "./pages/company/AboutPage";
import CompanyHistoryPage from "./pages/company/HistoryPage";
import CompanyPartnersPage from "./pages/company/PartnersPage";
import CompanyLocationPage from "./pages/company/LocationPage";

// UTM/UATM
import UTMIntroPage from "./pages/UTM/IntroPage";
import UTMCasePage from "./pages/UTM/CasePage";

// Business
import BusinessSiPage from "./pages/business/SiPage";
import BusinessRndPage from "./pages/business/RndPage";
import BusinessMaintenancePage from "./pages/business/MaintenancePage";

// Solution
import SolutionFlightControlPage from "./pages/solution/FlightControlPage";
import SolutionIbePage from "./pages/solution/IbePage";
import SolutionSmartTourPage from "./pages/solution/SmartTourPage";
import SolutionKtGcloudPage from "./pages/solution/KtGcloudPage";

// Contact
import ContactInquiryPage from "./pages/contact/InquiryPage";
import ContactRecruitPage from "./pages/contact/RecruitPage";

function Router() {
  return (
    <Routes>
      {/* 루트 진입 시 메인으로 리다이렉트 */}
      <Route path="/" element={<Navigate to="/main" replace />} />

      {/* 메인 페이지 */}
      <Route element={<MainLayout />}>
        <Route path="/main" element={<MainPage />} />
      </Route>

      {/* 서브 페이지 */}
      <Route element={<SubLayout />}>
        {/* Company */}
        <Route path="/company" element={<Navigate to="/company/about" replace />} />
        <Route path="/company/about" element={<CompanyAboutPage />} />
        <Route path="/company/history" element={<CompanyHistoryPage />} />
        <Route path="/company/partners" element={<CompanyPartnersPage />} />
        <Route path="/company/location" element={<CompanyLocationPage />} />

        {/* UTM/UATM */}
        <Route path="/UTM" element={<Navigate to="/UTM/intro" replace />} />
        <Route path="/UTM/intro" element={<UTMIntroPage />} />
        <Route path="/UTM/case" element={<UTMCasePage />} />

        {/* Business */}
        <Route path="/business" element={<Navigate to="/business/si" replace />} />
        <Route path="/business/si" element={<BusinessSiPage />} />
        <Route path="/business/rnd" element={<BusinessRndPage />} />
        <Route path="/business/maintenance" element={<BusinessMaintenancePage />} />

        {/* Solution */}
        <Route path="/solution" element={<Navigate to="/solution/flight-control" replace />} />
        <Route path="/solution/flight-control" element={<SolutionFlightControlPage />} />
        <Route path="/solution/ibe" element={<SolutionIbePage />} />
        <Route path="/solution/smart-tour" element={<SolutionSmartTourPage />} />
        <Route path="/solution/kt-gcloud" element={<SolutionKtGcloudPage />} />

        {/* Contact Us */}
        <Route path="/contact" element={<Navigate to="/contact/inquiry" replace />} />
        <Route path="/contact/inquiry" element={<ContactInquiryPage />} />
        <Route path="/contact/recruit" element={<ContactRecruitPage />} />
      </Route>

      {/* 404: 잘못된 경로는 메인으로 */}
      {/* <Route path="*" element={<Navigate to="/main" replace />} /> */}
    </Routes>
  );
}

export default Router;
