<?php

if (!function_exists('is_super_admin')) {
    function is_super_admin(): bool {
        return isset($_SESSION['user']) &&
               ($_SESSION['user']['role'] ?? '') === 'super_admin';
    }
}

if (!function_exists('current_org_scope')) {
    function current_org_scope(): ?int {
        if (is_super_admin()) {
            return null; // no restriction
        }
        return $_SESSION['user']['org_id'] ?? null;
    }
}
