<?php

/**
 * Admin Routes — Super Admin Portal (Authenticated)
 *
 * This file registers all routes for the Super Admin portal.
 * Routes are populated in Sprint 1 (Auth + Admin bootstrap).
 *
 * All admin routes share the prefix /app/admin and require:
 *   - AuthMiddleware  → valid session
 *   - RoleMiddleware  → role = 'admin'
 *
 * Available variable: $router (App\Core\Router instance)
 *
 * Routes to be defined here (for reference — NOT yet registered):
 *
 *   [DASHBOARD] — Sprint 1
 *   GET  /app/admin/dashboard                AdminDashboardController@index
 *
 *   [WORKSPACE MANAGEMENT] — Sprint 2
 *   GET  /app/admin/workspaces               AdminWorkspaceController@index
 *   GET  /app/admin/workspaces/create        AdminWorkspaceController@create
 *   POST /app/admin/workspaces/create        AdminWorkspaceController@store
 *   GET  /app/admin/workspaces/{id}          AdminWorkspaceController@show
 *   GET  /app/admin/workspaces/{id}/edit     AdminWorkspaceController@edit
 *   POST /app/admin/workspaces/{id}/edit     AdminWorkspaceController@update
 *   POST /app/admin/workspaces/{id}/delete   AdminWorkspaceController@delete
 *
 *   [USER MANAGEMENT] — Sprint 2
 *   GET  /app/admin/users                    AdminUserController@index
 *   POST /app/admin/users/{id}/deactivate    AdminUserController@deactivate
 *
 *   [SYSTEM LOGS] — Sprint 5
 *   GET  /app/admin/logs                     AdminLogController@index
 *
 * @package Inveetaire
 * @ref     DBP v1.0 Ch.5, SAD v1.1 Ch.4, INIT-007
 */

// Route group for the Super Admin portal.
// All admin portal routes inherit Auth and Role middlewares.
$router->group('/app/admin', function ($router) {
    // Super Admin Dashboard
    $router->get('/dashboard', 'App\\Modules\\Workspace\\AdminDashboardController@index');

    // Open Workspace context adoption (Viewing Mode)
    $router->get('/workspaces/{id}/open', 'App\\Modules\\Workspace\\AdminDashboardController@openWorkspace');

    // Admin Settings Page (Change Password)
    $router->get('/settings', 'App\\Modules\\Auth\\SettingsController@edit');
    $router->post('/settings', 'App\\Modules\\Auth\\SettingsController@update', [
        'App\\Middleware\\CsrfMiddleware',
    ]);

    // Workspace Users (Couple Accounts)
    $router->get('/couples', 'App\\Modules\\Workspace\\AdminCrewController@couplesList');
    $router->post('/couples/{id}/toggle-status', 'App\\Modules\\Workspace\\AdminCrewController@toggleCoupleStatus', [
        'App\\Middleware\\CsrfMiddleware',
    ]);

    // Crew Management
    $router->get('/crews', 'App\\Modules\\Workspace\\AdminCrewController@crewsList');
    $router->post('/crews/create', 'App\\Modules\\Workspace\\AdminCrewController@createCrew', [
        'App\\Middleware\\CsrfMiddleware',
    ]);
    $router->get('/crews/assignments', 'App\\Modules\\Workspace\\AdminCrewController@assignmentsList');
    $router->post('/crews/assignments', 'App\\Modules\\Workspace\\AdminCrewController@saveAssignments', [
        'App\\Middleware\\CsrfMiddleware',
    ]);

    // Plan & Theme Placeholders
    $router->get('/plans', 'App\\Modules\\Workspace\\AdminDashboardController@plansPlaceholder');
    $router->get('/themes', 'App\\Modules\\Workspace\\AdminDashboardController@themesPlaceholder');

    require ROOT_PATH . '/app/modules/Workspace/routes.php';
}, [
    'App\Middleware\AuthMiddleware',
    'App\Middleware\RoleMiddleware',
]);
