<?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
// Admin Routes
$router->get('/admin/dashboard', [\App\Controllers\AdminDashboardController::class, 'index']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/search', [\App\Controllers\SearchController::class, 'search']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/logs', [\App\Controllers\LogController::class, 'index']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

// Admin Profile
$router->get('/admin/profile', [\App\Controllers\AdminProfileController::class, 'index']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/profile/update', [\App\Controllers\AdminProfileController::class, 'update']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/profile/password', [\App\Controllers\AdminProfileController::class, 'updatePassword']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

// Clients CRUD
$router->get('/admin/clients', [\App\Controllers\ClientController::class, 'index']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/clients/create', [\App\Controllers\ClientController::class, 'create']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/clients/store', [\App\Controllers\ClientController::class, 'store']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/clients/edit/{id}', [\App\Controllers\ClientController::class, 'edit']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/clients/update/{id}', [\App\Controllers\ClientController::class, 'update']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/clients/delete/{id}', [\App\Controllers\ClientController::class, 'delete']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

// Servers CRUD
$router->get('/admin/servers', [\App\Controllers\ServerController::class, 'index']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/servers/create', [\App\Controllers\ServerController::class, 'create']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/servers/store', [\App\Controllers\ServerController::class, 'store']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/servers/edit/{id}', [\App\Controllers\ServerController::class, 'edit']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/servers/update/{id}', [\App\Controllers\ServerController::class, 'update']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/servers/delete/{id}', [\App\Controllers\ServerController::class, 'delete']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/servers/reset-machine/{id}', [\App\Controllers\ServerController::class, 'resetMachineId']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

// Orders CRUD
$router->get('/admin/orders', [\App\Controllers\OrderController::class, 'index']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/orders/create', [\App\Controllers\OrderController::class, 'create']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/orders/store', [\App\Controllers\OrderController::class, 'store']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->get('/admin/orders/view/{id}', [\App\Controllers\OrderController::class, 'view']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

// Settings
$router->get('/admin/settings', [\App\Controllers\SettingsController::class, 'index']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/settings/update', [\App\Controllers\SettingsController::class, 'update']);
$router->addMiddleware(\App\Middleware\AdminMiddleware::class);

$router->post('/admin/settings/test-telegram', [\App\Controllers\SettingsController::class, 'testTelegram']);
$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);

// Integration Routes
$router->get('/api/integration/stats', [\App\Controllers\IntegrationController::class, 'stats']);
$router->addMiddleware(\App\Middleware\IntegrationMiddleware::class);

// Client Routes
$router->get('/client/dashboard', [\App\Controllers\ClientDashboardController::class, 'index']);
$router->addMiddleware(\App\Middleware\ClientMiddleware::class);

$router->get('/client/servers', [\App\Controllers\ClientDashboardController::class, 'servers']);
$router->addMiddleware(\App\Middleware\ClientMiddleware::class);

$router->get('/client/orders', [\App\Controllers\ClientDashboardController::class, 'orders']);
$router->addMiddleware(\App\Middleware\ClientMiddleware::class);

$router->get('/client/orders/view/{id}', [\App\Controllers\ClientDashboardController::class, 'viewOrder']);
$router->addMiddleware(\App\Middleware\ClientMiddleware::class);

$router->get('/client/profile', [\App\Controllers\ClientDashboardController::class, 'profile']);
$router->addMiddleware(\App\Middleware\ClientMiddleware::class);

$router->post('/client/profile/password', [\App\Controllers\ClientDashboardController::class, 'updatePassword']);
$router->addMiddleware(\App\Middleware\ClientMiddleware::class);
