<?php
// index.php — Entry point, redirect berdasarkan role
require_once 'includes/config.php';
startSession();

if (empty($_SESSION['user_id'])) {
    header('Location: login.php');
    exit;
}

$role = $_SESSION['role'] ?? '';
$redirectMap = [
    'admin'           => 'dashboard/pengurus.php',
    'pengurus_ibadah' => 'dashboard/pengurus.php',
    'masyarakat'      => 'dashboard/masyarakat.php',
    'pemerintah'      => 'dashboard/pemerintah.php',
];

header('Location: ' . ($redirectMap[$role] ?? 'login.php'));
exit;
?>
