import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { BrowserView, MobileView } from 'react-device-detect';

// 공통 컴포넌트
import ScrollToTop from './components/ScrollToTop';

// PC 페이지
import PCHome from './pages/pc/Home';
import PCMembers from './pages/pc/Members';
import PCAlbum from './pages/pc/Album';
import PCAlbumDetail from './pages/pc/AlbumDetail';
import PCAlbumGallery from './pages/pc/AlbumGallery';
import PCSchedule from './pages/pc/Schedule';

// 모바일 페이지
import MobileHome from './pages/mobile/Home';
import MobileMembers from './pages/mobile/Members';
import MobileAlbum from './pages/mobile/Album';
import MobileAlbumDetail from './pages/mobile/AlbumDetail';
import MobileAlbumGallery from './pages/mobile/AlbumGallery';
import MobileSchedule from './pages/mobile/Schedule';

// 관리자 페이지
import AdminLogin from './pages/pc/admin/AdminLogin';
import AdminDashboard from './pages/pc/admin/AdminDashboard';
import AdminMembers from './pages/pc/admin/AdminMembers';
import AdminMemberEdit from './pages/pc/admin/AdminMemberEdit';
import AdminAlbums from './pages/pc/admin/AdminAlbums';
import AdminAlbumForm from './pages/pc/admin/AdminAlbumForm';
import AdminAlbumPhotos from './pages/pc/admin/AdminAlbumPhotos';
import AdminSchedule from './pages/pc/admin/AdminSchedule';
import AdminScheduleForm from './pages/pc/admin/AdminScheduleForm';
import AdminScheduleCategory from './pages/pc/admin/AdminScheduleCategory';
import AdminScheduleBots from './pages/pc/admin/AdminScheduleBots';

// 레이아웃
import PCLayout from './components/pc/Layout';
import MobileLayout from './components/mobile/Layout';

function App() {
    return (
        <BrowserRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
            <ScrollToTop />
            <BrowserView>
                <Routes>
                    {/* 관리자 페이지 (레이아웃 없음) */}
                    <Route path="/admin" element={<AdminLogin />} />
                    <Route path="/admin/dashboard" element={<AdminDashboard />} />
                    <Route path="/admin/members" element={<AdminMembers />} />
                    <Route path="/admin/members/:name/edit" element={<AdminMemberEdit />} />
                    <Route path="/admin/albums" element={<AdminAlbums />} />
                    <Route path="/admin/albums/new" element={<AdminAlbumForm />} />
                    <Route path="/admin/albums/:id/edit" element={<AdminAlbumForm />} />
                    <Route path="/admin/albums/:albumId/photos" element={<AdminAlbumPhotos />} />
                    <Route path="/admin/schedule" element={<AdminSchedule />} />
                    <Route path="/admin/schedule/new" element={<AdminScheduleForm />} />
                    <Route path="/admin/schedule/:id/edit" element={<AdminScheduleForm />} />
                    <Route path="/admin/schedule/categories" element={<AdminScheduleCategory />} />
                    <Route path="/admin/schedule/bots" element={<AdminScheduleBots />} />

                    {/* 일반 페이지 (레이아웃 포함) */}
                    <Route path="/*" element={
                        <PCLayout>
                            <Routes>
                                <Route path="/" element={<PCHome />} />
                                <Route path="/members" element={<PCMembers />} />
                                <Route path="/album" element={<PCAlbum />} />
                                <Route path="/album/:name" element={<PCAlbumDetail />} />
                                <Route path="/album/:name/gallery" element={<PCAlbumGallery />} />
                                <Route path="/schedule" element={<PCSchedule />} />
                            </Routes>
                        </PCLayout>
                    } />
                </Routes>
            </BrowserView>
            <MobileView>
                <Routes>
                    <Route path="/" element={<MobileLayout><MobileHome /></MobileLayout>} />
                    <Route path="/members" element={<MobileLayout pageTitle="멤버"><MobileMembers /></MobileLayout>} />
                    <Route path="/album" element={<MobileLayout pageTitle="앨범"><MobileAlbum /></MobileLayout>} />
                    <Route path="/album/:name" element={<MobileLayout pageTitle="앨범"><MobileAlbumDetail /></MobileLayout>} />
                    <Route path="/album/:name/gallery" element={<MobileLayout pageTitle="앨범"><MobileAlbumGallery /></MobileLayout>} />
                    <Route path="/schedule" element={<MobileLayout useCustomLayout><MobileSchedule /></MobileLayout>} />
                </Routes>
            </MobileView>
        </BrowserRouter>
    );
}

export default App;

