<?php
session_start();

// If user is already logged in, redirect based on role
if (isset($_SESSION['user'])) {
    $role = $_SESSION['user']['role'];

    switch ($role) {
        case 'admin':
            header("Location: modules/dashboard.php");
            break;
        case 'pharmacist':
            header("Location: modules/dashboard.php");
            break;
        case 'cashier':
            header("Location: modules/dashboard.php");
            break;
        default:
            header("Location: auth/login.php");
    }
    exit;
} else {
    // Not logged in → go to login page
    header("Location: auth/login.php");
    exit;
}
?>
