<?php

namespace App\Core;

class RoleMatrix
{
    public static function can(string $permission): bool
    {
        if (session_status() !== PHP_SESSION_ACTIVE) {
            session_start();
        }

        /*
        -----------------------------------------
        SUPERADMIN BYPASS (CRITICAL)
        -----------------------------------------
        */
        if (
            ($_SESSION['role'] ?? '') === 'super_admin' ||
            ($_SESSION['conference_role'] ?? '') === 'super_admin' ||
            ($_SESSION['user']['role_id'] ?? 0) == 1
        ) {
            return true;
        }

        /*
        -----------------------------------------
        NORMAL PERMISSION CHECK (fallback)
        -----------------------------------------
        */

        // You can extend later with DB permissions

        return false;
    }
}
