<nav class="sidebar" aria-label="التنقل الرئيسي">
  <span class="sidebar-brand">EL3AB</span>

  <a href="/play" class="sidebar-play-btn">
    <svg class="icon"><use href="/public/icons/sprite.svg#icon-play"></use></svg>
    العب الان
  </a>

  <div class="sidebar-section">
    <span class="sidebar-label">العاب</span>
    <?php
    $currentRoute = $_GET['route'] ?? '';
    $gameItems = [
      ['/games', 'icon-games', 'جميع الالعاب'],
      ['/puzzles', 'icon-puzzle', 'تمارين'],
      ['/tournaments', 'icon-trophy', 'بطولات', 'tournaments_enabled'],
    ];
    foreach ($gameItems as $item):
      $href = $item[0]; $icon = $item[1]; $label = $item[2]; $flag = $item[3] ?? null;
      if ($flag && !is_feature_enabled($flag)) continue;
      $route = trim($href, '/');
      $isActive = ($route !== '' && $currentRoute === $route);
    ?>
    <a href="<?= $href ?>" class="sidebar-item <?= $isActive ? 'active' : '' ?>">
      <svg class="icon"><use href="/public/icons/sprite.svg#<?= $icon ?>"></use></svg>
      <?= $label ?>
    </a>
    <?php endforeach; ?>
  </div>

  <div class="sidebar-section">
    <span class="sidebar-label">اجتماعي</span>
    <?php
    $socialItems = [
      ['/leaderboard', 'icon-leaderboard', 'المتصدرين'],
      ['/friends', 'icon-friends', 'الاصدقاء'],
      ['/orgs', 'icon-org', 'الاندية'],
    ];
    foreach ($socialItems as $item):
      $href = $item[0]; $icon = $item[1]; $label = $item[2];
      $route = trim($href, '/');
      $isActive = ($route !== '' && $currentRoute === $route);
    ?>
    <a href="<?= $href ?>" class="sidebar-item <?= $isActive ? 'active' : '' ?>">
      <svg class="icon"><use href="/public/icons/sprite.svg#<?= $icon ?>"></use></svg>
      <?= $label ?>
    </a>
    <?php endforeach; ?>
  </div>

  <div class="sidebar-section">
    <span class="sidebar-label">حسابي</span>
    <?php
    $accountItems = [
      ['/profile', 'icon-profile', 'الملف الشخصي'],
      ['/shop', 'icon-shop', 'المتجر', 'cosmetics_shop_enabled'],
      ['/achievements', 'icon-star', 'الانجازات'],
      ['/settings', 'icon-settings', 'الاعدادات'],
    ];
    foreach ($accountItems as $item):
      $href = $item[0]; $icon = $item[1]; $label = $item[2]; $flag = $item[3] ?? null;
      if ($flag && !is_feature_enabled($flag)) continue;
      $route = trim($href, '/');
      $isActive = ($route !== '' && $currentRoute === $route);
    ?>
    <a href="<?= $href ?>" class="sidebar-item <?= $isActive ? 'active' : '' ?>">
      <svg class="icon"><use href="/public/icons/sprite.svg#<?= $icon ?>"></use></svg>
      <?= $label ?>
    </a>
    <?php endforeach; ?>
  </div>
</nav>
