<aside class="pes-sidebar">
    <?php
        $u   = auth()->user();
        $elo = $u->elo ?? 1200;
        $div = getDivision($elo);
    ?>

    <!-- User card -->
    <div class="pes-user-card mt-2">
        <img src="<?php echo e($u->avatar ?? 'https://ui-avatars.com/api/?name='.urlencode($u->username).'&background=1d4ed8&color=fff&size=96'); ?>"
             class="pes-user-avatar" alt="avatar"
             style="width:44px;height:44px;border-radius:12px;object-fit:cover">
        <div style="flex:1;min-width:0;overflow:hidden">
            <div class="pes-user-name" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis"><?php echo e($u->username); ?></div>
            <span class="pes-user-badge" style="display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis"><?php echo e($div['icon']); ?> <?php echo e($div['name']); ?> · <?php echo e(number_format($elo)); ?> ELO</span>
        </div>
    </div>

    <!-- ELO progress bar -->
    <div style="padding:0 12px 4px">
        <?php
            $nextElo = collect([1000,1300,1600,1900,2200,2500,9999])->first(fn($t) => $t > $elo) ?? 9999;
            $prevElo = collect([0,1000,1300,1600,1900,2200,2500])->last(fn($t) => $t <= $elo) ?? 0;
            $pct = $nextElo < 9999 ? round(($elo - $prevElo) / ($nextElo - $prevElo) * 100) : 100;
        ?>
        <div class="pes-progress" style="background:rgba(255,255,255,.12)">
            <div class="pes-progress-bar" style="width:<?php echo e($pct); ?>%;background:linear-gradient(90deg,#60a5fa,#3b82f6)"></div>
        </div>
        <div style="font-size:10px;color:rgba(255,255,255,.35);margin-top:4px;text-align:right">
            <?php if($nextElo < 9999): ?> <?php echo e($nextElo - $elo); ?> ELO to next <?php else: ?> MAX <?php endif; ?>
        </div>
    </div>

    <!-- Navigation -->
    <div class="pes-nav-group">Main</div>

    <?php
        $navItems = [
            ['route'=>'dashboard',        'icon'=>'ti-home',        'label'=>'Dashboard'],
            ['route'=>'matchmaking.index', 'icon'=>'ti-bolt',        'label'=>'Find Match'],
            ['route'=>'leaderboard.index', 'icon'=>'ti-trophy',      'label'=>'Leaderboard'],
            ['route'=>'profile.show',      'icon'=>'ti-user',        'label'=>'My Profile'],
            ['route'=>'match.history',     'icon'=>'ti-history',     'label'=>'Match History'],
        ];
    ?>

    <?php $__currentLoopData = $navItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php if(\Route::has($item['route'])): ?>
        <a href="<?php echo e(route($item['route'])); ?>"
           class="pes-nav-item <?php echo e(request()->routeIs($item['route'].'*') ? 'active' : ''); ?>">
            <i class="ti <?php echo e($item['icon']); ?>"></i>
            <?php echo e($item['label']); ?>

            <?php if($item['label'] === 'Find Match'): ?>
                <span class="pes-nav-badge">Live</span>
            <?php endif; ?>
        </a>
        <?php endif; ?>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

    <div class="pes-nav-group">Kompetisi</div>

    <?php if(\Route::has('tournament.index')): ?>
    <a href="<?php echo e(route('tournament.index')); ?>"
       class="pes-nav-item <?php echo e(request()->routeIs('tournament*') ? 'active' : ''); ?>">
        <i class="ti ti-medal"></i>
        Tournament
    </a>
    <?php endif; ?>

    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('access-admin')): ?>
    <div class="pes-nav-group">Admin</div>
    <a href="<?php echo e(route('admin.dashboard')); ?>"
       class="pes-nav-item <?php echo e(request()->routeIs('admin.dashboard') ? 'active' : ''); ?>">
        <i class="ti ti-settings"></i>
        Admin Panel
    </a>
    <a href="<?php echo e(route('admin.tournaments')); ?>"
       class="pes-nav-item <?php echo e(request()->routeIs('admin.tournament*') ? 'active' : ''); ?>">
        <i class="ti ti-tournament"></i>
        Turnamen
    </a>
    <a href="<?php echo e(route('admin.clubs')); ?>"
       class="pes-nav-item <?php echo e(request()->routeIs('admin.clubs*') ? 'active' : ''); ?>">
        <i class="ti ti-shield-half"></i>
        Kelola Klub
    </a>
    <?php endif; ?>

    <!-- Footer -->
    <div style="margin:16px 12px 0;padding:12px;background:rgba(255,255,255,.05);border-radius:12px;text-align:center">
        <div style="font-size:11px;color:rgba(255,255,255,.3)">PES League · Season 1</div>
        <div style="font-size:10px;color:rgba(255,255,255,.2);margin-top:2px">MVP v1.0</div>
    </div>

    <!-- Logout -->
    <div style="margin:8px 8px 0">
        <form method="POST" action="<?php echo e(route('auth.logout')); ?>">
            <?php echo csrf_field(); ?>
            <button type="submit" class="pes-nav-item w-100" style="background:none;border:none;cursor:pointer;color:rgba(255,100,100,.7);text-align:left">
                <i class="ti ti-logout"></i>
                Logout
            </button>
        </form>
    </div>
</aside>
<?php /**PATH C:\xampp\htdocs\pes-league\resources\views/layouts/sidebar.blade.php ENDPATH**/ ?>