<?php
session_start();

// Check if user is already logged in
if (isset($_SESSION['user_id'])) {
    // Redirect based on role
    if (isset($_SESSION['is_admin']) && $_SESSION['is_admin']) {
        // Admin -> Dashboard Desktop
        header('Location: dashboard.html');
    } else {
        // User -> Dashboard Mobile
        header('Location: dashboard-mobile.html');
    }
    exit();
}

// Not logged in, redirect to login page
header('Location: login.php');
exit();
?>
