<?php

$router = new Router();

// --- Auth ---
$router->get('/', 'AuthController@showLogin');
$router->get('/login', 'AuthController@showLogin');
$router->post('/login', 'AuthController@login');
$router->get('/logout', 'AuthController@logout');

// --- Dashboard ---
$router->get('/dashboard', 'DashboardController@index');
$router->get('/app-customers', 'AppCustomerController@index');

// --- Admin: Users ---
$router->get('/admin/users', 'UserController@index');
$router->get('/admin/users/create', 'UserController@create');
$router->post('/admin/users/store', 'UserController@store');
$router->get('/admin/users/edit', 'UserController@edit');
$router->post('/admin/users/update', 'UserController@update');
$router->post('/admin/users/delete', 'UserController@delete');

// --- Admin: Roles & Permissions ---
$router->get('/admin/roles', 'RoleController@index');
$router->get('/admin/roles/permissions', 'RoleController@permissions');
$router->post('/admin/roles/permissions/save', 'RoleController@savePermissions');

// --- Admin: Settings ---
$router->get('/admin/settings', 'SettingsController@index');
$router->post('/admin/settings/save', 'SettingsController@save');

// --- Admin: Audit Log ---
$router->get('/admin/audit-log', 'AuditLogController@index');

// --- Orders ---
$router->get('/orders', 'OrderController@index');
$router->get('/orders/create', 'OrderController@create');
$router->post('/orders/store', 'OrderController@store');
$router->get('/orders/show', 'OrderController@show');
$router->get('/orders/label', 'OrderController@label');
$router->post('/orders/update-status', 'OrderController@updateStatus');
$router->post('/orders/cancel', 'OrderController@cancel');
$router->post('/orders/record-payment', 'OrderController@recordPayment');
$router->post('/orders/assign-rider', 'OrderController@assignRider');

// --- Public Order Tracking (no login required — customer scans QR on receipt/label) ---
$router->get('/track', 'TrackController@show');
$router->get('/api/track/status', 'TrackController@status');

// --- Customer Ordering PWA (no login required) ---
$router->get('/shop', 'ShopController@index');
$router->get('/shop/manifest', 'ShopController@manifest');

// --- Public JSON API for the customer PWA ---
$router->get('/api/menu', 'ApiController@getMenu');
$router->get('/api/zones', 'ApiController@getZones');
$router->get('/api/promotions', 'ApiController@getPromotions');
$router->get('/api/store-status', 'ApiController@getStoreStatus');

// --- Rider App (standalone PWA for delivery riders) ---
$router->get('/rider-app', 'RiderAppController@index');
$router->get('/rider-app/manifest', 'RiderAppController@manifest');

// --- Rider auth ---
$router->post('/api/rider/login', 'RiderAuthController@login');
$router->post('/api/rider/logout', 'RiderAuthController@logout');
$router->get('/api/rider/me', 'RiderAuthController@me');

// --- Rider delivery management ---
$router->get('/api/rider/deliveries', 'RiderApiController@myDeliveries');
$router->get('/api/rider/deliveries/history', 'RiderApiController@history');
$router->get('/api/rider/stats', 'RiderApiController@stats');
$router->post('/api/rider/deliveries/picked-up', 'RiderApiController@pickedUp');
$router->post('/api/rider/deliveries/claim', 'RiderApiController@claimAndPickup');
$router->post('/api/rider/deliveries/delivered', 'RiderApiController@delivered');
$router->post('/api/rider/deliveries/failed', 'RiderApiController@failed');
$router->get('/api/bank-details', 'ApiController@getBankDetails');

// --- PayHere card payment gateway ---
$router->post('/api/payhere/initiate', 'PayHereController@initiate');
$router->post('/api/payhere/notify', 'PayHereController@notify');
$router->post('/api/orders', 'ApiController@placeOrder');
$router->get('/api/orders/mine', 'ApiController@myOrders');
$router->get('/api/account/payments', 'ApiController@myPayments');
$router->get('/api/orders/track', 'ApiController@trackOrder');
$router->post('/api/orders/reorder', 'ApiController@reorder');

// --- Customer account auth (login/register/reset password) ---
$router->post('/api/auth/register', 'CustomerAuthController@register');
$router->post('/api/auth/login', 'CustomerAuthController@login');
$router->post('/api/auth/logout', 'CustomerAuthController@logout');
$router->get('/api/auth/me', 'CustomerAuthController@me');
$router->post('/api/auth/change-password', 'CustomerAuthController@changePassword');
$router->post('/api/auth/update-profile', 'CustomerAuthController@updateProfile');
$router->post('/api/auth/upload-profile-pic', 'CustomerAuthController@uploadProfilePic');
$router->post('/api/auth/forgot-password', 'CustomerAuthController@forgotPassword');
$router->post('/api/auth/reset-password', 'CustomerAuthController@resetPassword');

// --- Delivery ---
$router->get('/delivery', 'DeliveryController@index');
$router->post('/delivery/assign', 'DeliveryController@assign');
$router->post('/delivery/picked-up', 'DeliveryController@pickedUp');
$router->post('/delivery/delivered', 'DeliveryController@delivered');
$router->post('/delivery/failed', 'DeliveryController@failed');

// --- Delivery Zones ---
$router->get('/delivery/zones', 'DeliveryZoneController@index');
$router->post('/delivery/zones/store', 'DeliveryZoneController@store');
$router->post('/delivery/zones/update', 'DeliveryZoneController@update');
$router->post('/delivery/zones/toggle', 'DeliveryZoneController@toggle');
$router->post('/delivery/zones/delete', 'DeliveryZoneController@delete');

// --- Delivery Riders (quick management, separate from full Users admin) ---
$router->get('/riders', 'RiderController@index');
$router->post('/riders/store', 'RiderController@store');
$router->post('/riders/update', 'RiderController@update');
$router->post('/riders/toggle', 'RiderController@toggleActive');

// --- Menu Management ---
$router->get('/menu', 'MenuController@index');
$router->get('/menu/today', 'MenuController@today');
$router->post('/menu/categories/store', 'MenuController@storeCategory');
$router->post('/menu/categories/toggle', 'MenuController@toggleCategory');
$router->post('/menu/categories/delete', 'MenuController@deleteCategory');
$router->get('/menu/items/create', 'MenuController@createItem');
$router->post('/menu/items/store', 'MenuController@storeItem');
$router->get('/menu/items/edit', 'MenuController@editItem');
$router->post('/menu/items/update', 'MenuController@updateItem');
$router->post('/menu/items/toggle', 'MenuController@toggleItem');
$router->post('/menu/items/delete', 'MenuController@deleteItem');
$router->post('/menu/variants/store', 'MenuController@storeVariant');
$router->post('/menu/variants/delete', 'MenuController@deleteVariant');
$router->post('/menu/recipe/store', 'MenuController@storeRecipe');
$router->post('/menu/recipe/delete', 'MenuController@deleteRecipe');

// --- Home Promotions (customer app slideshow) ---
$router->get('/promotions', 'PromotionController@index');
$router->post('/promotions/store', 'PromotionController@store');
$router->post('/promotions/update', 'PromotionController@update');
$router->post('/promotions/toggle', 'PromotionController@toggle');
$router->post('/promotions/delete', 'PromotionController@delete');

// --- Stock / Raw Materials ---
$router->get('/stock', 'StockController@index');
$router->post('/stock/store', 'StockController@store');
$router->post('/stock/update', 'StockController@update');
$router->post('/stock/toggle', 'StockController@toggle');
$router->post('/stock/delete', 'StockController@delete');
$router->post('/stock/stock-in', 'StockController@stockIn');
$router->post('/stock/adjust', 'StockController@adjust');

// --- Suppliers ---
$router->get('/suppliers', 'SupplierController@index');
$router->post('/suppliers/store', 'SupplierController@store');
$router->post('/suppliers/update', 'SupplierController@update');
$router->post('/suppliers/toggle', 'SupplierController@toggle');

// --- Purchasing (Purchase Orders) ---
$router->get('/purchasing', 'PurchaseController@index');
$router->post('/purchasing/store', 'PurchaseController@store');
$router->get('/purchasing/show', 'PurchaseController@show');
$router->post('/purchasing/receive', 'PurchaseController@receive');
$router->post('/purchasing/pay', 'PurchaseController@pay');
$router->post('/purchasing/cancel', 'PurchaseController@cancel');

// --- Daily Kitchen Issuance ---
$router->get('/kitchen-issue', 'KitchenIssueController@index');
$router->post('/kitchen-issue/store', 'KitchenIssueController@store');
$router->post('/kitchen-issue/update', 'KitchenIssueController@update');

// --- Payments ---
$router->get('/payments', 'PaymentController@index');
$router->post('/payments/methods/store', 'PaymentController@storeMethod');
$router->post('/payments/methods/update', 'PaymentController@updateMethod');
$router->post('/payments/methods/toggle', 'PaymentController@toggleMethod');

// --- Finance ---
$router->get('/finance', 'FinanceController@index');
$router->post('/finance/accounts/store', 'FinanceController@storeAccount');
$router->post('/finance/accounts/toggle', 'FinanceController@toggleAccount');
$router->post('/finance/manual-entry', 'FinanceController@manualEntry');
$router->post('/finance/expenses/store', 'FinanceController@storeExpense');
$router->post('/finance/expenses/delete', 'FinanceController@deleteExpense');

// --- Attendance ---
$router->get('/attendance', 'AttendanceController@index');
$router->post('/attendance/store', 'AttendanceController@store');

// --- Payroll ---
$router->get('/payroll', 'PayrollController@index');
$router->post('/payroll/generate', 'PayrollController@generate');
$router->get('/payroll/show', 'PayrollController@show');
$router->post('/payroll/items/update', 'PayrollController@updateItem');
$router->post('/payroll/finalize', 'PayrollController@finalize');
$router->post('/payroll/pay-item', 'PayrollController@payItem');
$router->post('/payroll/pay-all', 'PayrollController@payAll');

// --- Reports ---
$router->get('/reports', 'ReportController@index');
$router->get('/reports/export/sales', 'ReportController@exportSales');
$router->get('/reports/export/items', 'ReportController@exportItems');
$router->get('/reports/export/pnl', 'ReportController@exportPnl');

// NOTE: All core modules are now built — no placeholder routes remain.
