<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">

<style>
    :root {
        --font-family: 'Inter', sans-serif;
        --bg-sidebar: #ffffff;
        --bg-hover: #f1f5f9;
        --bg-profile: #f8fafc;
        --text-primary: #1e293b;
        --text-secondary: #64748b;
        --border-color: #e2e8f0;
        --accent-primary: #335ae6;
        --accent-light: #dbeafe;
        --accent-dark: #1d4ed8;
        --shadow-color: rgba(100, 116, 139, 0.06);
        --shadow-active: rgba(51, 90, 230, 0.18);
    }

    .sidebar {
        font-family: var(--font-family);
        flex: 0 0 280px;
        width: 280px;
        height: 100vh;
        position: sticky;
        top: 0;
        background: var(--bg-sidebar);
        box-shadow: 0 6px 20px var(--shadow-color);
        padding: 24px;
        display: flex;
        flex-direction: column;
        gap: 20px;
        box-sizing: border-box;
        z-index: 50;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar .brand-container {
        padding: 0 8px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sidebar .brand {
        font-weight: 700;
        font-size: 22px;
        color: var(--text-primary);
        letter-spacing: -0.5px;
    }

    .sidebar .brand-sub {
        font-size: 13px;
        color: var(--text-secondary);
    }

    .sidebar .close-btn {
        display: none;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-secondary);
    }

    .sidebar .profile-card {
        padding: 16px;
        border-radius: 12px;
        background: var(--bg-profile);
        border: 1px solid var(--border-color);
    }

    .sidebar .profile-card h4 {
        margin: 0;
        font-size: 15px;
        font-weight: 600;
        color: var(--text-primary);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar .profile-card p {
        margin: 2px 0 0;
        color: var(--text-secondary);
        font-size: 13px;
    }

    .sidebar .role-pill {
        display: inline-block;
        margin-top: 10px;
        padding: 4px 10px;
        background: var(--accent-light);
        color: var(--accent-dark);
        border-radius: 999px;
        font-size: 11px;
        font-weight: 700;
        border: 1px solid #bfdbfe;
        text-transform: uppercase;
    }

    .sidebar .nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 0;
        overflow-y: auto;
        flex-grow: 1;
    }

    .sidebar .nav::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar .nav::-webkit-scrollbar-thumb {
        background: #e2e8f0;
        border-radius: 10px;
    }

    .sidebar .nav a {
        display: flex;
        gap: 12px;
        align-items: center;
        padding: 10px 14px;
        color: #475569;
        text-decoration: none;
        border-radius: 8px;
        font-weight: 500;
        font-size: 14px;
        transition: all .2s ease;
    }

    .sidebar .nav a:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }

    .sidebar .nav a.active {
        background: var(--accent-primary);
        color: #fff;
        font-weight: 600;
        box-shadow: 0 4px 12px -2px var(--shadow-active);
    }

    .sidebar .nav a.active .nav-icon {
        stroke: #ffffff;
    }

    .sidebar .nav-icon {
        width: 20px;
        height: 20px;
        stroke-width: 2;
        flex-shrink: 0;
    }

    .sidebar .nav-section-title {
        margin: 20px 14px 8px;
        font-size: 11px;
        font-weight: 700;
        color: #94a3b8;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .sidebar .divider {
        margin: 10px 0;
        border-top: 1px solid var(--border-color);
    }

    .sidebar .sidebar-footer {
        margin-top: auto;
        border-top: 1px solid var(--border-color);
        padding-top: 12px;
    }

    .sidebar .logout-btn {
        display: flex;
        gap: 12px;
        align-items: center;
        color: #64748b;
        font-weight: 600;
        width: 100%;
        padding: 10px 14px;
        font-family: inherit;
        font-size: 14px;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all .2s ease;
    }

    .sidebar .logout-btn:hover {
        background: #fff1f2;
        color: #e11d48;
    }

    .mobile-toggle {
        display: none;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 40;
        background: #fff;
        border: 1px solid var(--border-color);
        padding: 8px;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 45;
        backdrop-filter: blur(4px);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
    }

    @media (max-width: 1024px) {
        .mobile-toggle {
            display: block;
        }

        .sidebar {
            position: fixed;
            left: 0;
            top: 0;
            transform: translateX(-100%);
        }

        .sidebar.active {
            transform: translateX(0);
        }

        .sidebar .close-btn {
            display: block;
        }

        .sidebar-overlay {
            display: block;
            pointer-events: none;
        }

        .sidebar-overlay.active {
            pointer-events: auto;
        }
    }
</style>

<button class="mobile-toggle" onclick="toggleSidebar()">
    <svg width="24" height="24" fill="none" stroke="currentColor" stroke-width="2">
        <path d="M4 6h16M4 12h16M4 18h16" stroke-linecap="round" />
    </svg>
</button>

<div class="sidebar-overlay" onclick="toggleSidebar()"></div>

<aside class="sidebar" id="appSidebar">
    <div class="brand-container">
        <div>
            <div class="brand">E-Sekretariat</div>
            <div class="brand-sub">Management Portal</div>
        </div>
        <button class="close-btn" onclick="toggleSidebar()">
            <svg width="20" height="20" fill="none" stroke="currentColor" stroke-width="2">
                <path d="M15 5L5 15M5 5l10 10" stroke-linecap="round" />
            </svg>
        </button>
    </div>

    <div class="profile-card">
        <?php
            $user = auth()->user();
            $lowStockRequestItemCount = $user && $user->role === 'sekretariat'
                ? \App\Models\RequestItem::query()
                    ->whereColumn('stock', '<=', 'min_stock')
                    ->count()
                : 0;
        ?>
        <h4><?php echo e($user->name ?? 'Guest'); ?></h4>
        <p><?php echo e(data_get($user, 'divisi.nama', $user->divisi ?? 'General')); ?></p>
        <div class="role-pill"><?php echo e(ucfirst(str_replace('_', ' ', $user->role ?? 'user'))); ?></div>
    </div>

    <nav class="nav">
        <a href="<?php echo e(route('dashboard')); ?>" class="<?php echo e(request()->routeIs('dashboard') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            <span>Dashboard</span>
        </a>

        <a href="<?php echo e(route('items.index')); ?>" class="<?php echo e(request()->is('items*') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            <span>Stok Barang</span>
        </a>

        <a href="<?php echo e(route('borrow.index')); ?>" class="<?php echo e(request()->is('borrow*') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            <span>Peminjaman Barang</span>
        </a>

        <a href="<?php echo e(route('item-requests.index')); ?>" class="<?php echo e(request()->is('item-requests*') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M9 12h6m-6 4h6M7 4h10a2 2 0 012 2v12a2 2 0 01-2 2H7a2 2 0 01-2-2V6a2 2 0 012-2z" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            <span>Permintaan Barang</span>
        </a>

        <a href="<?php echo e(route('returns.index')); ?>" class="<?php echo e(request()->is('returns*') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            <span>Peminjaman Aktif</span>
        </a>

        <a href="<?php echo e(route('history.index')); ?>" class="<?php echo e(request()->is('history*') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            <span>Riwayat Selesai</span>
        </a>

        <a href="<?php echo e(route('rooms.index')); ?>" class="<?php echo e(request()->routeIs('rooms.*') ? 'active' : ''); ?>">
            <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke="currentColor" fill="none">
                <path stroke-linecap="round" stroke-linejoin="round" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
            </svg>
            <span>Manajemen Ruangan</span>
        </a>

        <a href="<?php echo e(route('vehicles.index')); ?>" class="<?php echo e(request()->routeIs('vehicles.*') ? 'active' : ''); ?>">
            <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke="currentColor" fill="none">
                <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 18.75a1.5 1.5 0 0 1-3 0m13.5 0a1.5 1.5 0 0 1-3 0m-13.5 0H5.25A2.25 2.25 0 0 1 3 16.5V15.75m14.25 3h.75A2.25 2.25 0 0 0 21 16.5v-7.5a2.25 2.25 0 0 0-2.25-2.25h-3a1.125 1.125 0 0 1-1.125-1.125V4.5a2.25 2.25 0 0 0-2.25-2.25h-3a2.25 2.25 0 0 0-2.25 2.25v.75m10.5 3.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM3.75 13.5h16.5a1.5 1.5 0 0 1 1.5 1.5v2.25a1.5 1.5 0 0 1-1.5 1.5H3.75a1.5 1.5 0 0 1-1.5-1.5V15a1.5 1.5 0 0 1 1.5-1.5Z" />
            </svg>
            <span>Manajemen Kendaraan</span>
        </a>

        <?php if(in_array($user->role, ['staff_bidang', 'kepala_bidang', 'sekretariat'])): ?>
        <div class="nav-section-title">Admin Menu</div>

        <?php if($user->role === 'sekretariat'): ?>
        <a href="<?php echo e(route('admin.request-items.index')); ?>"
            class="<?php echo e(request()->is('admin/request-items*') ? 'active' : ''); ?> <?php echo e($lowStockRequestItemCount > 0 && !request()->is('admin/request-items*') ? '!bg-rose-50 !text-rose-700 border border-rose-200' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            <span>Barang</span>
            <?php if($lowStockRequestItemCount > 0): ?>
            <span class="ml-auto inline-flex min-w-[22px] items-center justify-center rounded-full bg-rose-600 px-2 py-0.5 text-[11px] font-bold text-white shadow-sm">
                <?php echo e($lowStockRequestItemCount); ?>

            </span>
            <?php endif; ?>
        </a>
        <?php endif; ?>

        <a href="<?php echo e(route('verification.index')); ?>" class="<?php echo e(request()->is('verification*') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round" />
            </svg>
            <span>Verifikasi</span>
        </a>

        <a href="<?php echo e(Route::has('reports.index') ? route('reports.index') : '#'); ?>" class="<?php echo e(request()->is('reports*') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" d="M9 17v-2m3 2v-4m3 2v-6m2 9H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
            </svg>
            <span>Laporan</span>
        </a>
        <?php endif; ?>

        <div class="divider"></div>

        <a href="<?php echo e(Route::has('profile.index') ? route('profile.index') : '#'); ?>" class="<?php echo e(request()->is('profile*') ? 'active' : ''); ?>">
            <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
            </svg>
            <span>Profil</span>
        </a>
    </nav>

    <div class="sidebar-footer">
        <form method="POST" action="<?php echo e(route('logout')); ?>">
            <?php echo csrf_field(); ?>
            <button class="logout-btn" type="submit">
                <svg class="nav-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" stroke-linecap="round" stroke-linejoin="round" />
                </svg>
                <span>Logout</span>
            </button>
        </form>
    </div>
</aside>

<script>
    function toggleSidebar() {
        const sidebar = document.getElementById('appSidebar');
        const overlay = document.querySelector('.sidebar-overlay');
        sidebar.classList.toggle('active');
        overlay.classList.toggle('active');
    }
</script>
<?php /**PATH /Users/Afifudin/Downloads/Laravel 15-04-26 3/production/resources/views/partials/sidebar.blade.php ENDPATH**/ ?>