<?php
session_start();

if (!isset($_SESSION['user_id']) || !isset($_SESSION['role'])) {
    header('Location: login.php');
    exit;
}

$role = $_SESSION['role'];
$roleDisplay = [
    'admin' => 'Administrateur',
    'prof' => 'Professeur',
    'student' => 'Étudiant'
];

$layout = 'app/layout/' . $role . '-layout.php';

if (!file_exists($layout)) {
    // Fallback layout
    $layout = 'app/layout/student-layout.php';
}

// Include the layout
include $layout;
?>