<?php
declare(strict_types=1);

define('APP_BASE', rtrim(str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'] ?? '')), '/'));
$route = trim((string) ($_GET['route'] ?? ''), '/');

$routes = [
    '' => 'index.php', 'home' => 'index.php', 'about' => 'index.php', 'how-it-works' => 'index.php', 'faq' => 'index.php', 'contact' => 'index.php',
    'login' => 'login.php', 'register' => 'register.php', 'dashboard' => 'dashboard.php', 'portfolio' => 'wallet.php',
    'investments' => 'investments.php', 'transactions' => 'transactions.php', 'deposit' => 'deposits.php',
    'withdraw' => 'withdrawals.php', 'withdrawal' => 'withdrawals.php', 'profile' => 'profile.php', 'security' => 'profile.php',
    'notifications' => 'transactions.php', 'support' => 'profile.php', 'admin' => 'admin.php', 'admin-dashboard' => 'admin_dashboard.php',
    'manage-transactions' => 'manage_transactions.php', 'manage-earnings' => 'manage_earnings.php', 'manage-users' => 'manage_users.php',
];

if (!isset($routes[$route])) {
    http_response_code(404);
    echo '<h1>Page not found</h1>';
    exit;
}
require __DIR__ . '/view/' . $routes[$route];
