<?php
session_start();
$config = require __DIR__ . '/../lib/config.php';
$base = rtrim($config['base_url'], '/');
$_SESSION = [];
session_destroy();

// Optional: also sign out of Microsoft globally
// $tenant = urlencode($config['sso']['tenant_id']);
// $logout = "https://login.microsoftonline.com/{$tenant}/oauth2/v2.0/logout?post_logout_redirect_uri=" . urlencode($base . '/admin/login.php');
// header("Location: $logout"); exit;

header("Location: {$base}/admin/login.php");
