<?php
/**
 * SalonPro X - Sidebar Navigation Partial
 */
$currentUrl = \core\Request::capture()->url();
$isActive = fn($path) => str_starts_with($currentUrl, $path) ? 'active' : '';
$isOpen = fn($paths) => in_array(true, array_map(fn($p) => str_starts_with($currentUrl, $p), $paths)) ? 'show' : '';
?>
<aside class="sidebar glass-sidebar" id="sidebar">
    <!-- Logo -->
    <div class="sidebar-header">
        <a href="<?= url('dashboard') ?>" class="sidebar-logo">
            <img src="<?= asset('images/logo-white.svg') ?>" alt="<?= APP_NAME ?>">
        </a>
    </div>

    <!-- Sidebar Menu -->
    <nav class="sidebar-nav" id="sidebarNav">
        <ul class="sidebar-nav-list">
            <!-- Dashboard -->
            <li class="sidebar-item <?= $isActive('/dashboard') ?>">
                <a href="<?= url('dashboard') ?>" class="sidebar-link">
                    <i class="fas fa-th-large"></i>
                    <span>Dashboard</span>
                </a>
            </li>

            <!-- Appointments -->
            <li class="sidebar-item has-submenu <?= $isOpen(['/appointments', '/reception', '/calendar']) ?>">
                <a href="#" class="sidebar-link submenu-toggle">
                    <i class="fas fa-calendar-check"></i>
                    <span>Appointments</span>
                    <i class="fas fa-chevron-right submenu-arrow"></i>
                </a>
                <ul class="submenu <?= $isOpen(['/appointments', '/reception', '/calendar']) ?>">
                    <li><a href="<?= url('appointments') ?>" class="sidebar-link <?= $isActive('/appointments') ?>">All Appointments</a></li>
                    <li><a href="<?= url('appointments/calendar') ?>" class="sidebar-link <?= $isActive('/calendar') ?>">Calendar</a></li>
                    <li><a href="<?= url('reception') ?>" class="sidebar-link <?= $isActive('/reception') ?>">Reception</a></li>
                </ul>
            </li>

            <!-- POS -->
            <li class="sidebar-item <?= $isActive('/pos') ?>">
                <a href="<?= url('pos') ?>" class="sidebar-link">
                    <i class="fas fa-shopping-cart"></i>
                    <span>POS</span>
                    <span class="badge bg-warning ms-auto">New</span>
                </a>
            </li>

            <!-- Customers -->
            <li class="sidebar-item <?= $isActive('/customers') ?>">
                <a href="<?= url('customers') ?>" class="sidebar-link">
                    <i class="fas fa-users"></i>
                    <span>Customers</span>
                </a>
            </li>

            <!-- Services -->
            <li class="sidebar-item has-submenu <?= $isOpen(['/services', '/packages']) ?>">
                <a href="#" class="sidebar-link submenu-toggle">
                    <i class="fas fa-cut"></i>
                    <span>Services</span>
                    <i class="fas fa-chevron-right submenu-arrow"></i>
                </a>
                <ul class="submenu <?= $isOpen(['/services', '/packages']) ?>">
                    <li><a href="<?= url('services') ?>" class="sidebar-link <?= $isActive('/services') ?>">All Services</a></li>
                    <li><a href="<?= url('packages') ?>" class="sidebar-link <?= $isActive('/packages') ?>">Packages</a></li>
                </ul>
            </li>

            <!-- Inventory -->
            <li class="sidebar-item has-submenu <?= $isOpen(['/inventory', '/suppliers', '/purchases', '/grn', '/stock']) ?>">
                <a href="#" class="sidebar-link submenu-toggle">
                    <i class="fas fa-boxes"></i>
                    <span>Inventory</span>
                    <i class="fas fa-chevron-right submenu-arrow"></i>
                </a>
                <ul class="submenu <?= $isOpen(['/inventory', '/suppliers', '/purchases', '/grn', '/stock']) ?>">
                    <li><a href="<?= url('inventory') ?>" class="sidebar-link <?= $isActive('/inventory') ?>">Products</a></li>
                    <li><a href="<?= url('inventory/low-stock') ?>" class="sidebar-link <?= $isActive('/inventory/low-stock') ?>">Low Stock</a></li>
                    <li><a href="<?= url('suppliers') ?>" class="sidebar-link <?= $isActive('/suppliers') ?>">Suppliers</a></li>
                    <li><a href="<?= url('purchases') ?>" class="sidebar-link <?= $isActive('/purchases') ?>">Purchase Orders</a></li>
                </ul>
            </li>

            <!-- Invoices -->
            <li class="sidebar-item <?= $isActive('/invoices') ?>">
                <a href="<?= url('invoices') ?>" class="sidebar-link">
                    <i class="fas fa-file-invoice"></i>
                    <span>Invoices</span>
                </a>
            </li>

            <!-- Employees -->
            <li class="sidebar-item has-submenu <?= $isOpen(['/employees', '/attendance', '/commissions', '/salary', '/performance']) ?>">
                <a href="#" class="sidebar-link submenu-toggle">
                    <i class="fas fa-user-tie"></i>
                    <span>Employees</span>
                    <i class="fas fa-chevron-right submenu-arrow"></i>
                </a>
                <ul class="submenu <?= $isOpen(['/employees', '/attendance', '/commissions', '/salary', '/performance']) ?>">
                    <li><a href="<?= url('employees') ?>" class="sidebar-link <?= $isActive('/employees') ?>">All Employees</a></li>
                    <li><a href="<?= url('attendance') ?>" class="sidebar-link <?= $isActive('/attendance') ?>">Attendance</a></li>
                    <li><a href="<?= url('commissions') ?>" class="sidebar-link <?= $isActive('/commissions') ?>">Commissions</a></li>
                    <li><a href="<?= url('salary') ?>" class="sidebar-link <?= $isActive('/salary') ?>">Salary</a></li>
                </ul>
            </li>

            <!-- Accounting -->
            <li class="sidebar-item has-submenu <?= $isOpen(['/expenses', '/income', '/accounting']) ?>">
                <a href="#" class="sidebar-link submenu-toggle">
                    <i class="fas fa-wallet"></i>
                    <span>Accounting</span>
                    <i class="fas fa-chevron-right submenu-arrow"></i>
                </a>
                <ul class="submenu <?= $isOpen(['/expenses', '/income', '/accounting']) ?>">
                    <li><a href="<?= url('expenses') ?>" class="sidebar-link <?= $isActive('/expenses') ?>">Expenses</a></li>
                    <li><a href="<?= url('income') ?>" class="sidebar-link <?= $isActive('/income') ?>">Income</a></li>
                    <li><a href="<?= url('accounting/cash-book') ?>" class="sidebar-link <?= $isActive('/accounting/cash-book') ?>">Cash Book</a></li>
                    <li><a href="<?= url('accounting/bank-book') ?>" class="sidebar-link <?= $isActive('/accounting/bank-book') ?>">Bank Book</a></li>
                    <li><a href="<?= url('accounting/petty-cash') ?>" class="sidebar-link <?= $isActive('/accounting/petty-cash') ?>">Petty Cash</a></li>
                </ul>
            </li>

            <!-- Memberships & Loyalty -->
            <li class="sidebar-item has-submenu <?= $isOpen(['/membership', '/loyalty', '/gift-cards']) ?>">
                <a href="#" class="sidebar-link submenu-toggle">
                    <i class="fas fa-crown"></i>
                    <span>Loyalty</span>
                    <i class="fas fa-chevron-right submenu-arrow"></i>
                </a>
                <ul class="submenu <?= $isOpen(['/membership', '/loyalty', '/gift-cards']) ?>">
                    <li><a href="<?= url('membership') ?>" class="sidebar-link <?= $isActive('/membership') ?>">Memberships</a></li>
                    <li><a href="<?= url('loyalty') ?>" class="sidebar-link <?= $isActive('/loyalty') ?>">Loyalty Points</a></li>
                    <li><a href="<?= url('gift-cards') ?>" class="sidebar-link <?= $isActive('/gift-cards') ?>">Gift Cards</a></li>
                </ul>
            </li>

            <!-- Marketing -->
            <li class="sidebar-item has-submenu <?= $isOpen(['/marketing']) ?>">
                <a href="#" class="sidebar-link submenu-toggle">
                    <i class="fas fa-bullhorn"></i>
                    <span>Marketing</span>
                    <i class="fas fa-chevron-right submenu-arrow"></i>
                </a>
                <ul class="submenu <?= $isOpen(['/marketing']) ?>">
                    <li><a href="<?= url('marketing/campaigns') ?>" class="sidebar-link <?= $isActive('/marketing/campaigns') ?>">Campaigns</a></li>
                    <li><a href="<?= url('marketing/templates/email') ?>" class="sidebar-link <?= $isActive('/marketing/templates/email') ?>">Email Templates</a></li>
                    <li><a href="<?= url('marketing/templates/sms') ?>" class="sidebar-link <?= $isActive('/marketing/templates/sms') ?>">SMS Templates</a></li>
                </ul>
            </li>

            <!-- Reports -->
            <li class="sidebar-item has-submenu <?= $isOpen(['/reports']) ?>">
                <a href="#" class="sidebar-link submenu-toggle">
                    <i class="fas fa-chart-bar"></i>
                    <span>Reports</span>
                    <i class="fas fa-chevron-right submenu-arrow"></i>
                </a>
                <ul class="submenu <?= $isOpen(['/reports']) ?>">
                    <li><a href="<?= url('reports/daily-sales') ?>" class="sidebar-link <?= $isActive('/reports/daily-sales') ?>">Daily Sales</a></li>
                    <li><a href="<?= url('reports/monthly-sales') ?>" class="sidebar-link <?= $isActive('/reports/monthly-sales') ?>">Monthly Sales</a></li>
                    <li><a href="<?= url('reports/profit-loss') ?>" class="sidebar-link <?= $isActive('/reports/profit-loss') ?>">Profit & Loss</a></li>
                    <li><a href="<?= url('reports') ?>" class="sidebar-link <?= $isActive('/reports') ?>">All Reports</a></li>
                </ul>
            </li>

            <!-- System -->
            <li class="sidebar-section"><span>System</span></li>
            <li class="sidebar-item <?= $isActive('/users') ?>">
                <a href="<?= url('users') ?>" class="sidebar-link">
                    <i class="fas fa-users"></i>
                    <span>Users</span>
                </a>
            </li>
            <li class="sidebar-item <?= $isActive('/roles') ?>">
                <a href="<?= url('roles') ?>" class="sidebar-link">
                    <i class="fas fa-shield-alt"></i>
                    <span>Roles & Permissions</span>
                </a>
            </li>
            <li class="sidebar-item <?= $isActive('/settings') ?>">
                <a href="<?= url('settings') ?>" class="sidebar-link">
                    <i class="fas fa-cog"></i>
                    <span>Settings</span>
                </a>
            </li>
            <li class="sidebar-item <?= $isActive('/audit-logs') ?>">
                <a href="<?= url('audit-logs') ?>" class="sidebar-link">
                    <i class="fas fa-history"></i>
                    <span>Audit Logs</span>
                </a>
            </li>
            <li class="sidebar-item <?= $isActive('/settings/backup') ?>">
                <a href="<?= url('settings/backup') ?>" class="sidebar-link">
                    <i class="fas fa-database"></i>
                    <span>Backup & Restore</span>
                </a>
            </li>
        </ul>
    </nav>

    <!-- Sidebar Footer -->
    <div class="sidebar-footer">
        <div class="sidebar-version">
            v<?= APP_VERSION ?>
        </div>
    </div>
</aside>
