<?php

/**
 * Couple Routes — Couple Portal (Authenticated)
 *
 * This file registers all routes for the Couple portal.
 * Routes are populated in Sprint 1 (Auth + Workspace) onwards.
 *
 * All couple routes share the prefix /app/couple and require:
 *   - AuthMiddleware      → valid session
 *   - RoleMiddleware      → role = 'couple'
 *   - WorkspaceMiddleware → workspace_id validated
 *
 * Available variable: $router (App\Core\Router instance)
 *
 * Routes to be defined here (for reference — NOT yet registered):
 *
 *   [DASHBOARD] — Sprint 2
 *   GET  /app/couple/dashboard           CoupleDashboardController@index
 *
 *   [GUESTS] — Sprint 4
 *   GET  /app/couple/guests              GuestListController@index
 *   GET  /app/couple/guests/import       GuestListController@showImport
 *   POST /app/couple/guests/import       GuestListController@processImport
 *   GET  /app/couple/guests/{id}         GuestListController@show
 *   GET  /app/couple/guests/{id}/edit    GuestListController@edit
 *   POST /app/couple/guests/{id}/edit    GuestListController@update
 *   POST /app/couple/guests/{id}/delete  GuestListController@delete
 *
 *   [SEATING] — Sprint 5
 *   GET  /app/couple/seating             SeatingController@index
 *   POST /app/couple/seating/assign      SeatingController@assign
 *
 *   [THEMES] — Sprint 3
 *   GET  /app/couple/theme               ThemeController@index
 *   POST /app/couple/theme/upload        ThemeController@upload
 *
 *   [CHECKIN] — Sprint 6
 *   GET  /app/couple/checkin             CheckinController@dashboard
 *
 *   [REPORTS] — Sprint 7
 *   GET  /app/couple/reports             ReportController@index
 *   POST /app/couple/reports/export      ReportController@export
 *
 * @package Inveetaire
 * @ref     DBP v1.0 Ch.5, SAD v1.1 Ch.4, INIT-007
 */

// Route group for the Couple portal.
// All couple portal routes inherit Auth, Role, and Workspace boundary middlewares.
$router->group('/app/couple', function ($router) {
    // Dashboard summary mapping
    $router->get('/dashboard', 'App\\Modules\\Invitation\\CoupleDashboardController@index');
    $router->get('/insights', 'App\\Modules\\Invitation\\CoupleDashboardController@insights');
    $router->get('/report', 'App\\Modules\\Invitation\\CoupleDashboardController@report');
    $router->post('/report/complete', 'App\\Modules\\Invitation\\CoupleDashboardController@completeReport');

    // Load Invitation Module routes
    require ROOT_PATH . '/app/modules/Invitation/routes.php';

    // Load Guest Module routes
    require ROOT_PATH . '/app/modules/Guest/routes.php';

    // Load Messaging Module routes
    require ROOT_PATH . '/app/modules/Messaging/routes.php';

    // Load Wedding Operation Module routes
    require ROOT_PATH . '/app/modules/Operation/routes.php';

    // Load Guest Engagement Module routes
    require ROOT_PATH . '/app/modules/Engagement/routes.php';

    // Load Budget Module routes (RC-017)
    require ROOT_PATH . '/app/modules/Budget/routes.php';

    // Load Timeline Module routes (RC-018)
    require ROOT_PATH . '/app/modules/Timeline/routes.php';

    // Load Vendor Module routes (RC-019)
    require ROOT_PATH . '/app/modules/Vendor/routes.php';

    // ── Workspace Users Management (ALPHA STABILIZATION-004) ───────────────────
    $router->get('/users', 'App\\Modules\\Workspace\\WorkspaceUserController@index');
    $router->get('/users/create', 'App\\Modules\\Workspace\\WorkspaceUserController@create');
    $router->post('/users/create', 'App\\Modules\\Workspace\\WorkspaceUserController@store', [
        'App\\Middleware\\CsrfMiddleware',
    ]);
    $router->get('/users/edit/{id}', 'App\\Modules\\Workspace\\WorkspaceUserController@edit');
    $router->post('/users/edit/{id}', 'App\\Modules\\Workspace\\WorkspaceUserController@update', [
        'App\\Middleware\\CsrfMiddleware',
    ]);

    // Couple Settings Page (Change Password)
    $router->get('/settings', 'App\\Modules\\Auth\\SettingsController@edit');
    $router->post('/settings', 'App\\Modules\\Auth\\SettingsController@update', [
        'App\\Middleware\\CsrfMiddleware',
    ]);
    
    // Printer Settings
    $router->get('/settings/printer', 'App\\Modules\\Operation\\PrinterSettingsController@index');
    $router->post('/settings/printer', 'App\\Modules\\Operation\\PrinterSettingsController@update', [
        'App\\Middleware\\CsrfMiddleware',
    ]);
}, [
    'App\Middleware\AuthMiddleware',
    'App\Middleware\RoleMiddleware',
    'App\Middleware\WorkspaceMiddleware',
]);

