import { Routes, Route, Navigate } from 'react-router-dom';
import ProtectedRoute from './components/auth/ProtectedRoute';
import AppShell from './components/layout/AppShell';
import LoginPage from './pages/LoginPage';
import RegisterPage from './pages/RegisterPage';
import DashboardPage from './pages/DashboardPage';
import MarketPage from './pages/MarketPage';
import SignalsPage from './pages/SignalsPage';
import RegimePage from './pages/RegimePage';
import TickerDetailPage from './pages/TickerDetailPage';
import AdminPage from './pages/AdminPage';

export default function App() {
  return (
    <Routes>
      <Route path="/login" element={<LoginPage />} />
      <Route path="/register" element={<RegisterPage />} />
      <Route element={<ProtectedRoute />}>
        <Route element={<AppShell />}>
          <Route path="/" element={<DashboardPage />} />
          <Route path="/market" element={<MarketPage />} />
          <Route path="/signals" element={<SignalsPage />} />
          <Route path="/regime" element={<RegimePage />} />
          <Route path="/ticker/:symbol" element={<TickerDetailPage />} />
          {/* Legacy routes from the old 6-page layout */}
          <Route path="/watchlist" element={<Navigate to="/market" replace />} />
          <Route path="/rankings" element={<Navigate to="/market?tab=rankings" replace />} />
          <Route path="/scanner" element={<Navigate to="/signals" replace />} />
          <Route path="/performance" element={<Navigate to="/signals?tab=track" replace />} />
          <Route element={<ProtectedRoute requireAdmin />}>
            <Route path="/admin" element={<AdminPage />} />
          </Route>
        </Route>
      </Route>
    </Routes>
  );
}
