<?php
session_start();

// Jika user sudah login → redirect sesuai role
if (!empty($_SESSION['user'])) {

    $role = $_SESSION['user']['role'];

    if ($role === 'superadmin' || $role === 'operator') {
        header("Location: pages/dashboard.php");
        exit;
    }

    if ($role === 'guru') {
        header("Location: pages/dashboard_guru.php");
        exit;
    }
}

// Jika belum login → tampilkan preview
header("Location: preview.php");
exit;
