<?php
// Determine path prefix
$loader_path_prefix = "";
$current_dir = basename(dirname($_SERVER['PHP_SELF']));
if ($current_dir == 'admin' || $current_dir == 'student') {
    $loader_path_prefix = "../";
}
?>
<link rel="stylesheet" href="<?php echo $loader_path_prefix; ?>assets/css/loader.css">

<div id="global-loader">
    <div class="loader-content">
        <div class="loader-title">FGV</div>
        <div class="loader-subtitle">Your CBT companion</div>
        <div class="loader-progress"></div>
    </div>
</div>

<script>
    window.addEventListener('load', function() {
        // Minimum display time to ensure animation is seen
        setTimeout(function() {
            const loader = document.getElementById('global-loader');
            if (loader) {
                loader.classList.add('hidden');
                // Remove from DOM to prevent interaction interference
                setTimeout(() => {
                    loader.style.display = 'none';
                }, 600); // Matches CSS transition duration
            }
        }, 1500); // 1.5 second delay for effect
    });
</script>
