@php
    $role = session('role');
@endphp

<!-- ======= Sidebar ======= -->
<aside id="sidebar" class="sidebar">
    <ul class="sidebar-nav" id="sidebar-nav">
        {{-- Selalu tampil untuk semua --}}
        <li class="nav-item">
            <a class="nav-link {{ Request::routeIs('dashboard') ? 'active' : 'collapsed' }}" href="{{ route('dashboard') }}">
                <i class="bi bi-grid"></i>
                <span>Dashboard</span>
            </a>
        </li>

        {{-- Hanya kasir & admin --}}
        <li class="nav-item">
            <a class="nav-link {{ Request::is('cashier') ? 'active' : 'collapsed' }}" href="{{ route('cashier') }}">
                <i class="bi bi-basket"></i>
                <span>Kasir</span>
            </a>
        </li>

        {{-- Hanya kasir & admin --}}
        <li class="nav-item">
            <a class="nav-link {{ Request::is('income') ? 'active' : 'collapsed' }}" href="{{ route('income') }}">
                <i class="bi bi-receipt"></i>
                <span>Penjualan</span>
            </a>
        </li>

        {{-- Semua menu di bawah ini hanya untuk admin --}}
        @if ($role === 'Admin')
            <li class="nav-item">
                <a class="nav-link {{ Request::is('expense') ? 'active' : 'collapsed' }}" href="{{ route('expense') }}">
                    <i class="bi bi-cash"></i>
                    <span>Pengeluaran</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link {{ Request::is('brand') || Request::is('category') || Request::is('product') || Request::is('stock') ? '' : 'collapsed' }}"
                    data-bs-target="#forms-nav" data-bs-toggle="collapse" href="#">
                    <i class="bi bi-box"></i><span>Manajemen Barang</span><i class="bi bi-chevron-down ms-auto"></i>
                </a>
                <ul id="forms-nav"
                    class="nav-content collapse {{ Request::is('brand') || Request::is('category') || Request::is('product') || Request::is('stock') ? 'show' : '' }}"
                    data-bs-parent="#sidebar-nav">
                    <li>
                        <a href="{{ route('product') }}" class="{{ Request::is('product') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Produk</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ route('brand') }}" class="{{ Request::is('brand') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Brand</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ route('category') }}" class="{{ Request::is('category') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Kategori</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ route('stock') }}" class="{{ Request::is('stock') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Stok</span>
                        </a>
                    </li>
                </ul>
            </li>

            <li class="nav-item">
                <a class="nav-link {{ Request::is('user') ? 'active' : 'collapsed' }}" href="{{ route('user') }}">
                    <i class="bi bi-people"></i>
                    <span>Manajemen Pengguna</span>
                </a>
            </li>

            <li class="nav-item">
                <a class="nav-link {{ Request::is('sample*') || Request::is('training*') || Request::is('testing*') || Request::is('hasil*') || Request::is('peringkat*') ? '' : 'collapsed' }}"
                    data-bs-target="#data-nav" data-bs-toggle="collapse" href="#">
                    <i class="bi bi-bar-chart"></i><span>Data Mining</span><i class="bi bi-chevron-down ms-auto"></i>
                </a>
                <ul id="data-nav"
                    class="nav-content collapse {{ Request::is('sample*') || Request::is('training*') || Request::is('testing*') || Request::is('hasil*') || Request::is('peringkat*') ? 'show' : '' }}"
                    data-bs-parent="#sidebar-nav">
                    <li>
                        <a href="{{ route('sample.index') }}" class="{{ Request::is('sample*') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Sampel Data Awal</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ route('training.index') }}" class="{{ Request::is('training*') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Data Training</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ route('testing.index') }}" class="{{ Request::is('testing*') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Data Testing</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ route('hasil.index') }}" class="{{ Request::is('hasil*') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Perhitungan & Hasil Prediksi</span>
                        </a>
                    </li>
                    <li>
                        <a href="{{ route('peringkat.index') }}" class="{{ Request::is('peringkat*') ? 'active' : '' }}">
                            <i class="bi bi-circle"></i><span>Peringkat Brand Terlaris</span>
                        </a>
                    </li>
                </ul>
            </li>
        @endif
    </ul>
</aside>
<!-- ======= End Sidebar ======= -->
