import { useState, useEffect } from "react"
import { BrowserRouter as Router, Route, Routes } from "react-router-dom"
import { ROUTES } from "./utils/routes"
import AuthRegister from "./pages/Auth/AuthRegister"
import AuthLogin from "./pages/Auth/AuthLogin"
import Test from "./pages/Testing/Test"
import ForgotPassword from "./pages/Auth/ForgotPassword"
import ResetPassword from "./pages/Auth/ResetPassword"
import Landingpage from "./pages/Landing/Landingpage"
import Home from "./pages/Landing/Home"
import DeckManagerPage from "./pages/Decks/DeckManagerPage"
import Card_display from "./pages/Decks/Card_display"
import DeckCreator from "./pages/DeckCreator/DeckCreator"
import CompanyHub from "./pages/Contacts/Contacts"
import About from "./pages/About/About"
import ScrollToTop from "./components/ScrollToTop"
import GameScreen from "./pages/Game/GameScreen"
import GameTest from "./pages/Game/GameTest"
import Reports from "./pages/Report/Reports"
import Lobby from "./pages/Game/Lobby"
import ProfileCard from "./components/Userdetails/Userdetails"
import { ToastConfig } from "./components/Toastify/toastifyServices" // ✅ fontos: named import, nem default!
import VerifyEmailPage from "./pages/Auth/VerifyEmailPage"
import ChooseDeck from "./pages/Game/ChooseDeck"
import PlayerSetup from "./pages/Game/PlayerSetup"
import GameModalsDemo from "./pages/Game/GameModalsDemo"
import { GameWebSocketProvider } from "./contexts/GameWebSocketContext"

function App() {
  const [isMobile, setIsMobile] = useState(false)

  useEffect(() => {
    const handleResize = () => {
      setIsMobile(window.innerWidth <= 1280)
    }

    handleResize()
    window.addEventListener("resize", handleResize)

    return () => window.removeEventListener("resize", handleResize)
  }, [])

  // if (isMobile) {
  //   return (
  //     <Router>
  //       <Routes>
  //         <Route path="/register" element={<AuthRegister />} />
  //         <Route path="/login" element={<AuthLogin />} />
  //         <Route path="/verify-email" element={<EmailVerification />} />
  //       </Routes>
  //     </Router>
  //   );
  // }

  return (
    <>
      <GameWebSocketProvider>
        <Router>
          <Routes>
            <Route path={ROUTES.VERIFY_EMAIL} element={<VerifyEmailPage />} />
            <Route path={ROUTES.ABOUT} element={<About />} />
            <Route path={ROUTES.LOBBY} element={<Lobby />} />
            <Route path={ROUTES.REGISTER} element={<AuthRegister />} />
            <Route path={ROUTES.LOGIN} element={<AuthLogin />} />
            <Route path={ROUTES.FORGOT_PASSWORD} element={<ForgotPassword />} />
            <Route path={ROUTES.RESET_PASSWORD} element={<ResetPassword />} />
            <Route path={ROUTES.PROFILE} element={<ProfileCard />} />
            <Route path={ROUTES.TEST} element={<Test />} />
            <Route path={ROUTES.ROOT} element={<Landingpage />} />
            <Route path={ROUTES.HOME} element={<Home />} />
            <Route path={ROUTES.DECKS} element={<DeckManagerPage />} />
            <Route path={ROUTES.DECK_DETAILS} element={<Card_display />} />
            <Route path={ROUTES.DECK_CREATOR} element={<DeckCreator />} />
            <Route path={ROUTES.DECK_CREATOR_EDIT} element={<DeckCreator />} />
            <Route path={ROUTES.GAME} element={<GameScreen />} />
            <Route path={ROUTES.GAME_TEST} element={<GameTest />} />
            {/* <Route path={ROUTES.CONTACTS} element={<CompanyHub />} /> */}
            <Route path={ROUTES.REPORTS} element={<Reports />} />
            <Route path={ROUTES.CHOOSE_DECK} element={<ChooseDeck />} />
            <Route path={ROUTES.PLAYER_SETUP} element={<PlayerSetup />} />
          </Routes>
        </Router>
      </GameWebSocketProvider>

      {/* ✅ Toastify Container */}
      <ToastConfig />
    </>
  )
}

export default App
