<?php

use CodeIgniter\Router\RouteCollection;

/** @var RouteCollection $routes */
$routes->get('/', 'Home::index');
$routes->get('services', 'Home::services');
$routes->get('about', 'Home::about');
$routes->get('contact', 'Home::contact');
$routes->post('contact/submit', 'Home::submit_inquiry');
$routes->get('gallery', 'Home::gallery');
$routes->get('menu-planner', 'Home::menu_planner');

// Admin root redirect → login page
$routes->get('admin', function() {
    return redirect()->to(base_url('admin/login'));
});

// Admin Auth Routes
$routes->get('admin/login', 'Admin::login');
$routes->post('admin/login', 'Admin::login_submit');
$routes->get('admin/logout', 'Admin::logout');

// Protected Admin Panel Routes
$routes->group('admin', ['filter' => 'adminAuth'], function($routes) {
    $routes->get('dashboard', 'Admin::dashboard');
    
    // Gallery Management
    $routes->get('gallery', 'Admin::gallery');
    $routes->post('gallery/upload', 'Admin::gallery_upload');
    $routes->post('gallery/delete/(:num)', 'Admin::gallery_delete/$1');
    
    // Menu Management
    $routes->get('menu', 'Admin::menu');
    $routes->post('menu/save', 'Admin::menu_save');
    $routes->post('menu/delete/(:num)', 'Admin::menu_delete/$1');
    
    // Services Management
    $routes->get('services', 'Admin::services');
    $routes->post('services/save', 'Admin::services_save');
    $routes->post('services/delete/(:num)', 'Admin::services_delete/$1');
    $routes->post('services/reorder', 'Admin::services_reorder');
    
    // Inquiries management
    $routes->get('inquiries', 'Admin::inquiries');
    $routes->post('inquiries/delete/(:num)', 'Admin::inquiry_delete/$1');
});
