<?php
/**
 * Sidebar Navigation Template
 */
$role = SessionManager::getUserRole();
?>
<nav class="sidebar" id="sidebar">
    <div class="sidebar-header">
        <div class="sidebar-brand">
            <span class="brand-icon">&#128202;</span>
            <span class="brand-text">InvCount</span>
        </div>
    </div>

    <div class="sidebar-menu">
        <?php if ($role === ROLE_ADMIN): ?>
        <!-- Admin Navigation -->
        <div class="menu-section">
            <div class="menu-section-title">Management</div>
            <a href="<?= APP_URL ?>/admin/dashboard.php" class="menu-item <?= str_contains($currentUrl, 'admin/dashboard') ? 'active' : '' ?>">
                <span class="menu-icon">&#127968;</span>
                <span>Dashboard</span>
            </a>
            <a href="<?= APP_URL ?>/admin/users.php" class="menu-item <?= str_contains($currentUrl, 'admin/users') ? 'active' : '' ?>">
                <span class="menu-icon">&#128101;</span>
                <span>Users</span>
            </a>
            <a href="<?= APP_URL ?>/admin/sessions.php" class="menu-item <?= str_contains($currentUrl, 'admin/sessions') ? 'active' : '' ?>">
                <span class="menu-icon">&#128197;</span>
                <span>Sessions</span>
            </a>
            <a href="<?= APP_URL ?>/admin/items.php" class="menu-item <?= str_contains($currentUrl, 'admin/items') ? 'active' : '' ?>">
                <span class="menu-icon">&#128230;</span>
                <span>Items</span>
            </a>
            <a href="<?= APP_URL ?>/admin/assignments.php" class="menu-item <?= str_contains($currentUrl, 'admin/assignments') ? 'active' : '' ?>">
                <span class="menu-icon">&#9999;</span>
                <span>Assignments</span>
            </a>
            <a href="<?= APP_URL ?>/admin/system_qty_snapshots.php" class="menu-item <?= str_contains($currentUrl, 'admin/system_qty_snapshots') ? 'active' : '' ?>">
                <span class="menu-icon">&#128202;</span>
                <span>System Qty Snapshots</span>
            </a>
        </div>
        <div class="menu-section">
            <div class="menu-section-title">Workflow</div>
            <a href="<?= APP_URL ?>/admin/pending_counts.php" class="menu-item <?= str_contains($currentUrl, 'admin/pending') ? 'active' : '' ?>">
                <span class="menu-icon">&#9203;</span>
                <span>Pending Counts</span>
            </a>
            <a href="<?= APP_URL ?>/admin/counting_instructions.php" class="menu-item <?= str_contains($currentUrl, 'counting_instructions') ? 'active' : '' ?>">
                <span class="menu-icon">&#128221;</span>
                <span>Count Instructions</span>
            </a>
            <a href="<?= APP_URL ?>/admin/checking_guidelines.php" class="menu-item <?= str_contains($currentUrl, 'checking_guidelines') ? 'active' : '' ?>">
                <span class="menu-icon">&#9989;</span>
                <span>Check Guidelines</span>
            </a>
        </div>
        <div class="menu-section">
            <div class="menu-section-title">Reports</div>
            <a href="<?= APP_URL ?>/admin/reports.php" class="menu-item <?= str_contains($currentUrl, 'admin/reports') ? 'active' : '' ?>">
                <span class="menu-icon">&#128200;</span>
                <span>Reports</span>
            </a>
            <a href="<?= APP_URL ?>/admin/settings.php" class="menu-item <?= str_contains($currentUrl, 'admin/settings') ? 'active' : '' ?>">
                <span class="menu-icon">&#9881;</span>
                <span>Settings</span>
            </a>
        </div>

        <?php elseif ($role === ROLE_COUNTER): ?>
        <!-- Counter Navigation -->
        <div class="menu-section">
            <div class="menu-section-title">My Work</div>
            <a href="<?= APP_URL ?>/counter/dashboard.php" class="menu-item <?= str_contains($currentUrl, 'counter/dashboard') ? 'active' : '' ?>">
                <span class="menu-icon">&#127968;</span>
                <span>Dashboard</span>
            </a>
            <a href="<?= APP_URL ?>/counter/count_items.php" class="menu-item <?= str_contains($currentUrl, 'counter/count_items') ? 'active' : '' ?>">
                <span class="menu-icon">&#128203;</span>
                <span>Count Items</span>
            </a>
            <a href="<?= APP_URL ?>/counter/counting_instructions.php" class="menu-item <?= str_contains($currentUrl, 'counter/counting_instructions') ? 'active' : '' ?>">
                <span class="menu-icon">&#128221;</span>
                <span>Instructions</span>
            </a>
            <a href="<?= APP_URL ?>/counter/my_assignments.php" class="menu-item <?= str_contains($currentUrl, 'counter/my_assignments') ? 'active' : '' ?>">
                <span class="menu-icon">&#9999;</span>
                <span>My Assignments</span>
            </a>
            <a href="<?= APP_URL ?>/counter/reports.php" class="menu-item <?= str_contains($currentUrl, 'counter/reports') ? 'active' : '' ?>">
                <span class="menu-icon">&#128200;</span>
                <span>My Reports</span>
            </a>
        </div>

        <?php elseif ($role === ROLE_CHECKER): ?>
        <!-- Checker Navigation -->
        <div class="menu-section">
            <div class="menu-section-title">Verification</div>
            <a href="<?= APP_URL ?>/checker/dashboard.php" class="menu-item <?= str_contains($currentUrl, 'checker/dashboard') ? 'active' : '' ?>">
                <span class="menu-icon">&#127968;</span>
                <span>Dashboard</span>
            </a>
            <a href="<?= APP_URL ?>/checker/pending_counts.php" class="menu-item <?= str_contains($currentUrl, 'checker/pending') ? 'active' : '' ?>">
                <span class="menu-icon">&#9203;</span>
                <span>Pending Reviews</span>
            </a>
            <a href="<?= APP_URL ?>/checker/checking_guidelines.php" class="menu-item <?= str_contains($currentUrl, 'checker/checking_guidelines') ? 'active' : '' ?>">
                <span class="menu-icon">&#9989;</span>
                <span>Guidelines</span>
            </a>
            <a href="<?= APP_URL ?>/checker/reports.php" class="menu-item <?= str_contains($currentUrl, 'checker/reports') ? 'active' : '' ?>">
                <span class="menu-icon">&#128200;</span>
                <span>Reports</span>
            </a>
        </div>

        <?php elseif ($role === ROLE_CONTROLLER): ?>
        <!-- Controller Navigation -->
        <div class="menu-section">
            <div class="menu-section-title">Inventory Control</div>
            <a href="<?= APP_URL ?>/controller/dashboard.php" class="menu-item <?= str_contains($currentUrl, 'controller/dashboard') ? 'active' : '' ?>">
                <span class="menu-icon">&#127968;</span>
                <span>Dashboard</span>
            </a>
            <a href="<?= APP_URL ?>/controller/users.php" class="menu-item <?= str_contains($currentUrl, 'controller/users') ? 'active' : '' ?>">
                <span class="menu-icon">&#128101;</span>
                <span>Users</span>
            </a>
            <a href="<?= APP_URL ?>/controller/sessions.php" class="menu-item <?= str_contains($currentUrl, 'controller/sessions') ? 'active' : '' ?>">
                <span class="menu-icon">&#128197;</span>
                <span>Sessions</span>
            </a>
            <a href="<?= APP_URL ?>/controller/items.php" class="menu-item <?= str_contains($currentUrl, 'controller/items') ? 'active' : '' ?>">
                <span class="menu-icon">&#128230;</span>
                <span>Items</span>
            </a>
            <a href="<?= APP_URL ?>/controller/assignments.php" class="menu-item <?= str_contains($currentUrl, 'controller/assignments') ? 'active' : '' ?>">
                <span class="menu-icon">&#9999;</span>
                <span>Assignments</span>
            </a>
            <a href="<?= APP_URL ?>/controller/system_qty_snapshots.php" class="menu-item <?= str_contains($currentUrl, 'controller/system_qty_snapshots') ? 'active' : '' ?>">
                <span class="menu-icon">&#128202;</span>
                <span>System Qty Snapshots</span>
            </a>
        </div>
        <div class="menu-section">
            <div class="menu-section-title">Workflow</div>
            <a href="<?= APP_URL ?>/controller/pending_counts.php" class="menu-item <?= str_contains($currentUrl, 'controller/pending') ? 'active' : '' ?>">
                <span class="menu-icon">&#9203;</span>
                <span>Pending Counts</span>
            </a>
            <a href="<?= APP_URL ?>/controller/counting_instructions.php" class="menu-item <?= str_contains($currentUrl, 'controller/counting_instructions') ? 'active' : '' ?>">
                <span class="menu-icon">&#128221;</span>
                <span>Count Instructions</span>
            </a>
            <a href="<?= APP_URL ?>/controller/checking_guidelines.php" class="menu-item <?= str_contains($currentUrl, 'controller/checking_guidelines') ? 'active' : '' ?>">
                <span class="menu-icon">&#9989;</span>
                <span>Check Guidelines</span>
            </a>
        </div>
        <div class="menu-section">
            <div class="menu-section-title">Reports</div>
            <a href="<?= APP_URL ?>/controller/reports.php" class="menu-item <?= str_contains($currentUrl, 'controller/reports') ? 'active' : '' ?>">
                <span class="menu-icon">&#128200;</span>
                <span>Reports</span>
            </a>
            <a href="<?= APP_URL ?>/controller/variance_report.php" class="menu-item <?= str_contains($currentUrl, 'variance_report') ? 'active' : '' ?>">
                <span class="menu-icon">📊</span>
                <span>Variance Report</span>
            </a>
            <a href="<?= APP_URL ?>/controller/variance_edit.php" class="menu-item <?= str_contains($currentUrl, 'variance_edit') ? 'active' : '' ?>">
                <span class="menu-icon">📝</span>
                <span>Variance Edit</span>
            </a>
            <a href="<?= APP_URL ?>/controller/count_report.php" class="menu-item <?= str_contains($currentUrl, 'count_report') ? 'active' : '' ?>">
                <span class="menu-icon">&#128202;</span>
                <span>Count Summary</span>
            </a>
            <a href="<?= APP_URL ?>/controller/settings.php" class="menu-item <?= str_contains($currentUrl, 'controller/settings') ? 'active' : '' ?>">
                <span class="menu-icon">&#9881;</span>
                <span>Settings</span>
            </a>
        </div>
        <?php endif; ?>
    </div>

    <div class="sidebar-footer">
        <div class="sidebar-version">v<?= APP_VERSION ?></div>
    </div>
</nav>
