import App from '../App';
import AdminLayout from '../layouts/AdminLayout';
import { Navigate } from 'react-router-dom';
import Dashboard from '../pages/admin/Dashboard';
import CategoryManager from '../pages/admin/CategoryManager';
import ProductManager from '../pages/admin/ProductManager';
import CardManager from '../pages/admin/CardManager';
import DepositManager from '../pages/admin/DepositManager';
import DiscountManager from '../pages/admin/DiscountManager';
import WebsiteManager from '../pages/admin/WebsiteManager';
import NotificationManager from '../pages/admin/NotificationManager';
import UserManager from '../pages/admin/UserManager';
import LuckyWheelManager from '../pages/admin/LuckyWheelManager';
import SystemConfigManager from '../pages/admin/SystemConfigManager';
import CategoryAccount from '../pages/CategoryAccount';
import LoginUser from '../pages/LoginUser';
import RegisterUser from '../pages/RegisterUser';
import ForgotPassword from '../pages/ForgotPassword';
import ResetPassword from '../pages/ResetPassword';
import InfoUser from '../pages/InfoUser';
import DetailProduct from '../pages/DetailProduct';
import NotFound from '../pages/NotFound';
import Deposits from '../pages/Deposits';
import TransactionHistory from '../pages/TransactionHistory';
import PurchasedAccounts from '../pages/PurchasedAccounts';
import LuckyWheel from '../pages/LuckyWheel';

// Static pages (footer links)
import PrivacyPolicy from '../pages/PrivacyPolicy';
import TermsOfService from '../pages/TermsOfService';
import WarrantyPolicy from '../pages/WarrantyPolicy';
import GuideRegister from '../pages/GuideRegister';
import GuideDeposit from '../pages/GuideDeposit';
import GuideChangeInfo from '../pages/GuideChangeInfo';
import SecurityPolicy from '../pages/SecurityPolicy';

export const publicRoutes = [
    {
        path: '/',
        element: <App />,
    },
    {
        path: '/login',
        element: <LoginUser />,
    },
    {
        path: '/register',
        element: <RegisterUser />,
    },
    {
        path: '/forgot-password',
        element: <ForgotPassword />,
    },
    {
        path: '/reset-password',
        element: <ResetPassword />,
    },
    {
        path: '/profile',
        element: <InfoUser />,
    },
    {
        path: '/tai-khoan/:slug',
        element: <CategoryAccount />,
    },
    {
        path: '/san-pham/:id',
        element: <DetailProduct />,
    },
    {
        path: '*',
        element: <NotFound />,
    },
    {
        path: '/deposit/card',
        element: <Deposits />,
    },
    {
        path: '/deposit/bank',
        element: <Deposits />,
    },
    {
        path: '/history/transactions',
        element: <TransactionHistory />,
    },
    {
        path: '/history/purchased',
        element: <PurchasedAccounts />,
    },
    {
        path: '/lucky-wheel',
        element: <LuckyWheel />,
    },
    // Static pages (footer links)
    {
        path: '/chinh-sach-bao-mat',
        element: <PrivacyPolicy />,
    },
    {
        path: '/dieu-khoan-dich-vu',
        element: <TermsOfService />,
    },
    {
        path: '/chinh-sach-bao-hanh',
        element: <WarrantyPolicy />,
    },
    {
        path: '/huong-dan/dang-ky',
        element: <GuideRegister />,
    },
    {
        path: '/huong-dan/nap-tien',
        element: <GuideDeposit />,
    },
    {
        path: '/huong-dan/doi-thong-tin',
        element: <GuideChangeInfo />,
    },
    {
        path: '/bao-mat-tai-khoan',
        element: <SecurityPolicy />,
    },
];

export const adminRoutes = [
    {
        path: '/admin',
        element: <AdminLayout />, // Use the Layout here
        title: 'Quản trị',
        children: [
            {
                index: true,
                element: <Dashboard />,
                title: 'Tổng quan',
            },
            {
                path: 'categories',
                element: <CategoryManager />,
                title: 'Quản lý danh mục',
            },
            {
                path: 'products',
                element: <ProductManager />,
                title: 'Quản lý tài khoản',
            },
            {
                path: 'card-types',
                element: <CardManager />,
                title: 'Quản lý loại thẻ',
            },
            {
                path: 'deposits',
                element: <DepositManager />,
                title: 'Quản lý nạp thẻ',
            },
            {
                path: 'discounts',
                element: <DiscountManager />,
                title: 'Quản lý mã giảm giá',
            },
            {
                // Redirect cũ /admin/website → /admin/system-config
                path: 'website',
                element: <Navigate to="/admin/system-config" replace />,
            },
            {
                path: 'notifications',
                element: <NotificationManager />,
                title: 'Quản lý thông báo',
            },
            {
                path: 'users',
                element: <UserManager />,
                title: 'Quản lý người dùng',
            },
            {
                path: 'lucky-wheel',
                element: <LuckyWheelManager />,
                title: 'Vòng quay may mắn',
            },
            {
                path: 'system-config',
                element: <SystemConfigManager />,
                title: 'Cấu hình hệ thống',
            },
        ],
    },
];

export const routes = [...publicRoutes, ...adminRoutes];
