<?php
declare(strict_types=1);

return [
    // Dashboard
    ['GET',  '/facility-grids/dashboard',      'FacilityGrids\Controllers\GridDashboardController@index',   ['auth'], 'facility_grid.view'],

    // Grid CRUD
    ['GET',  '/facility-grids',                'FacilityGrids\Controllers\FacilityGridController@index',    ['auth'], 'facility_grid.view'],
    ['GET',  '/facility-grids/create',         'FacilityGrids\Controllers\FacilityGridController@create',   ['auth'], 'facility_grid.manage'],
    ['POST', '/facility-grids',                'FacilityGrids\Controllers\FacilityGridController@store',    ['auth', 'csrf'], 'facility_grid.manage'],
    ['GET',  '/facility-grids/{id:\d+}',       'FacilityGrids\Controllers\FacilityGridController@show',     ['auth'], 'facility_grid.view'],
    ['GET',  '/facility-grids/{id:\d+}/edit',  'FacilityGrids\Controllers\FacilityGridController@edit',     ['auth'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{id:\d+}/update','FacilityGrids\Controllers\FacilityGridController@update',   ['auth', 'csrf'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{id:\d+}/toggle','FacilityGrids\Controllers\FacilityGridController@toggle',   ['auth', 'csrf'], 'facility_grid.manage'],

    // API — grid state (for AJAX polling)
    ['GET',  '/api/facility-grids/{id:\d+}/state', 'FacilityGrids\Controllers\FacilityGridController@apiState', ['auth'], 'facility_grid.view'],

    // Zone Schedules
    ['GET',  '/facility-grids/{gridId:\d+}/schedules',                       'FacilityGrids\Controllers\ZoneScheduleController@index',          ['auth'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{gridId:\d+}/schedules',                       'FacilityGrids\Controllers\ZoneScheduleController@store',          ['auth', 'csrf'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{gridId:\d+}/schedules/{scheduleId:\d+}',      'FacilityGrids\Controllers\ZoneScheduleController@update',         ['auth', 'csrf'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{gridId:\d+}/schedules/{scheduleId:\d+}/delete','FacilityGrids\Controllers\ZoneScheduleController@destroy',       ['auth', 'csrf'], 'facility_grid.manage'],
    ['GET',  '/facility-grids/{gridId:\d+}/schedules/conflicts',             'FacilityGrids\Controllers\ZoneScheduleController@checkConflicts', ['auth'], 'facility_grid.view'],

    // Zone Trainees
    ['POST', '/facility-grids/{gridId:\d+}/trainees',                        'FacilityGrids\Controllers\ZoneTraineeController@assign',          ['auth', 'csrf'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{gridId:\d+}/trainees/{traineeId:\d+}/remove', 'FacilityGrids\Controllers\ZoneTraineeController@remove',          ['auth', 'csrf'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{gridId:\d+}/trainees/{traineeId:\d+}/move',   'FacilityGrids\Controllers\ZoneTraineeController@move',            ['auth', 'csrf'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{gridId:\d+}/zones/{zoneId:\d+}/clear',        'FacilityGrids\Controllers\ZoneTraineeController@clearZone',       ['auth', 'csrf'], 'facility_grid.manage'],

    // Monthly Plans
    ['GET',  '/facility-grids/{gridId:\d+}/plans',                          'FacilityGrids\Controllers\MonthlyPlanController@index',    ['auth'], 'facility_grid.view'],
    ['GET',  '/facility-grids/{gridId:\d+}/plans/create',                   'FacilityGrids\Controllers\MonthlyPlanController@create',   ['auth'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{gridId:\d+}/plans',                          'FacilityGrids\Controllers\MonthlyPlanController@store',    ['auth', 'csrf'], 'facility_grid.manage'],
    ['GET',  '/facility-grids/{gridId:\d+}/plans/{planId:\d+}',             'FacilityGrids\Controllers\MonthlyPlanController@show',     ['auth'], 'facility_grid.view'],
    ['POST', '/facility-grids/{gridId:\d+}/plans/{planId:\d+}/activate',    'FacilityGrids\Controllers\MonthlyPlanController@activate', ['auth', 'csrf'], 'facility_grid.manage'],
    ['POST', '/facility-grids/{gridId:\d+}/plans/{planId:\d+}/archive',     'FacilityGrids\Controllers\MonthlyPlanController@archive',  ['auth', 'csrf'], 'facility_grid.manage'],
    ['GET',  '/facility-grids/{gridId:\d+}/plans/{planId:\d+}/diff',        'FacilityGrids\Controllers\MonthlyPlanController@diff',     ['auth'], 'facility_grid.view'],

    // Legacy redirects (mirror + pool → unified facility-grids)
    ['GET', '/mirror',                  'FacilityGrids\Controllers\RedirectController@mirrorIndex',    ['auth'], 'facility_grid.view'],
    ['GET', '/mirror/{id:\d+}',         'FacilityGrids\Controllers\RedirectController@mirrorShow',     ['auth'], 'facility_grid.view'],
    ['GET', '/pool/{id:\d+}/grid',      'FacilityGrids\Controllers\RedirectController@poolGrid',       ['auth'], 'facility_grid.view'],
    ['GET', '/pool/{id:\d+}/schedules', 'FacilityGrids\Controllers\RedirectController@poolSchedules',  ['auth'], 'facility_grid.view'],
];
