<?php
/**
 * SalonPro X - Error Controller
 * Handles 404, 403, and 500 error pages
 */

namespace Modules\Dashboard\Controllers;

use core\Controller;
use core\View;

class ErrorController extends Controller
{
    public function notFound(): void
    {
        http_response_code(404);
        $layout = \core\Auth::check() ? 'main' : 'error';
        View::render('Dashboard/errors/404', [
            'title' => '404 - Page Not Found',
            'errorCode' => 404,
            'errorMessage' => 'The page you are looking for does not exist.',
        ], $layout);
    }

    public function forbidden(): void
    {
        http_response_code(403);
        $layout = \core\Auth::check() ? 'main' : 'error';
        View::render('Dashboard/errors/403', [
            'title' => '403 - Forbidden',
            'errorCode' => 403,
            'errorMessage' => 'You do not have permission to access this page.',
        ], $layout);
    }

    public function serverError(): void
    {
        http_response_code(500);
        $layout = \core\Auth::check() ? 'main' : 'error';
        View::render('Dashboard/errors/500', [
            'title' => '500 - Server Error',
            'errorCode' => 500,
            'errorMessage' => 'An internal server error occurred.',
        ], $layout);
    }
}
