<?php

use App\Controllers\AuthController;

/** @var \App\Core\Router $router */

$router->get('/', [AuthController::class, 'login']);
$router->get('/login', [AuthController::class, 'login']);
$router->post('/login', [AuthController::class, 'authenticate']);
$router->get('/logout', [AuthController::class, 'logout']);

// Admin Routes
$router->get('/admin/dashboard', [\App\Controllers\AdminDashboardController::class, 'index']);
$router->get('/admin/search', [\App\Controllers\SearchController::class, 'search']);
$router->get('/admin/logs', [\App\Controllers\LogController::class, 'index']);

// Admin Profile
$router->get('/admin/profile', [\App\Controllers\AdminProfileController::class, 'index']);
$router->post('/admin/profile/update', [\App\Controllers\AdminProfileController::class, 'update']);
$router->post('/admin/profile/password', [\App\Controllers\AdminProfileController::class, 'updatePassword']);

// Clients CRUD
$router->get('/admin/clients', [\App\Controllers\ClientController::class, 'index']);
$router->get('/admin/clients/create', [\App\Controllers\ClientController::class, 'create']);
$router->post('/admin/clients/store', [\App\Controllers\ClientController::class, 'store']);
$router->get('/admin/clients/edit/{id}', [\App\Controllers\ClientController::class, 'edit']);
$router->post('/admin/clients/update/{id}', [\App\Controllers\ClientController::class, 'update']);
$router->get('/admin/clients/delete/{id}', [\App\Controllers\ClientController::class, 'delete']);

// Servers CRUD
$router->get('/admin/servers', [\App\Controllers\ServerController::class, 'index']);
$router->get('/admin/servers/create', [\App\Controllers\ServerController::class, 'create']);
$router->post('/admin/servers/store', [\App\Controllers\ServerController::class, 'store']);
$router->get('/admin/servers/edit/{id}', [\App\Controllers\ServerController::class, 'edit']);
$router->post('/admin/servers/update/{id}', [\App\Controllers\ServerController::class, 'update']);
$router->get('/admin/servers/delete/{id}', [\App\Controllers\ServerController::class, 'delete']);
$router->get('/admin/servers/delete/{id}', [\App\Controllers\ServerController::class, 'delete']);
$router->get('/admin/servers/reset-machine/{id}', [\App\Controllers\ServerController::class, 'resetMachineId']);

// Orders CRUD
$router->get('/admin/orders', [\App\Controllers\OrderController::class, 'index']);
$router->get('/admin/orders/create', [\App\Controllers\OrderController::class, 'create']);
$router->post('/admin/orders/store', [\App\Controllers\OrderController::class, 'store']);
$router->get('/admin/orders/view/{id}', [\App\Controllers\OrderController::class, 'view']);

$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

// API Routes
$router->post('/api/auth/login', [\App\Controllers\ApiAuthController::class, 'login']);

$router->get('/api/v1/domains', [\App\Controllers\ApiController::class, 'domains']);
$router->addMiddleware(\App\Middleware\ApiMiddleware::class);

// Client Routes
$router->get('/client/dashboard', [\App\Controllers\ClientDashboardController::class, 'index']);
$router->get('/client/servers', [\App\Controllers\ClientDashboardController::class, 'servers']);
$router->get('/client/orders', [\App\Controllers\ClientDashboardController::class, 'orders']);
$router->get('/client/orders/view/{id}', [\App\Controllers\ClientDashboardController::class, 'viewOrder']);
$router->get('/client/profile', [\App\Controllers\ClientDashboardController::class, 'profile']);
$router->post('/client/profile/password', [\App\Controllers\ClientDashboardController::class, 'updatePassword']);

$router->addMiddleware(\App\Middleware\ClientMiddleware::class);
