<?php
/**
 * Admin Sidebar
 * Navigation sidebar for admin panel
 */
$currentPage = basename($_SERVER['PHP_SELF']);
?>
<nav class="navbar navbar-light navbar-vertical navbar-expand-xl">
  <script>
    var navbarStyle = localStorage.getItem("navbarStyle");
    if (navbarStyle && navbarStyle !== 'transparent') {
      document.querySelector('.navbar-vertical').classList.add(`navbar-${navbarStyle}`);
    }
  </script>
  <div class="d-flex align-items-center">
    <div class="toggle-icon-wrapper">
      <button class="btn navbar-toggler-humburger-icon navbar-vertical-toggle" data-bs-toggle="tooltip" data-bs-placement="left" title="Toggle Navigation">
        <span class="navbar-toggle-icon"><span class="toggle-line"></span></span>
      </button>
    </div>
    <a class="navbar-brand" href="/admin">
      <div class="d-flex align-items-center py-3">
        <img class="me-2" src="../../Falcon/assets/img/icons/spot-illustrations/falcon.png" alt="" width="40" />
        <span class="font-sans-serif text-primary">Admin</span>
      </div>
    </a>
  </div>
  <div class="collapse navbar-collapse" id="navbarVerticalCollapse">
    <div class="navbar-vertical-content scrollbar">
      <ul class="navbar-nav flex-column mb-3" id="navbarVerticalNav">
        <li class="nav-item">
          <a class="nav-link <?php echo ($currentPage === 'dashboard.php') ? 'active' : ''; ?>" href="/admin">
            <div class="d-flex align-items-center">
              <span class="nav-link-icon"><span class="fas fa-chart-pie"></span></span>
              <span class="nav-link-text ps-1">Dashboard</span>
            </div>
          </a>
        </li>
        <li class="nav-item">
          <div class="row navbar-vertical-label-wrapper mt-3 mb-2">
            <div class="col-auto navbar-vertical-label">E-commerce</div>
            <div class="col ps-0"><hr class="mb-0 navbar-vertical-divider" /></div>
          </div>
          <a class="nav-link dropdown-indicator" href="#e-commerce" role="button" data-bs-toggle="collapse" aria-expanded="<?php echo (in_array($currentPage, ['products.php', 'orders.php', 'customers.php'])) ? 'true' : 'false'; ?>" aria-controls="e-commerce">
            <div class="d-flex align-items-center">
              <span class="nav-link-icon"><span class="fas fa-shopping-cart"></span></span>
              <span class="nav-link-text ps-1">E-commerce</span>
            </div>
          </a>
          <ul class="nav collapse <?php echo (in_array($currentPage, ['products.php', 'orders.php', 'customers.php'])) ? 'show' : ''; ?>" id="e-commerce">
            <li class="nav-item">
              <a class="nav-link <?php echo ($currentPage === 'products.php') ? 'active' : ''; ?>" href="/admin/produse">
                <div class="d-flex align-items-center">
                  <span class="nav-link-text ps-1">Produse</span>
                </div>
              </a>
            </li>
            <li class="nav-item">
              <a class="nav-link <?php echo ($currentPage === 'orders.php') ? 'active' : ''; ?>" href="/admin/comenzi">
                <div class="d-flex align-items-center">
                  <span class="nav-link-text ps-1">Comenzi</span>
                </div>
              </a>
            </li>
            <li class="nav-item">
              <a class="nav-link <?php echo ($currentPage === 'customers.php') ? 'active' : ''; ?>" href="/admin/clienti">
                <div class="d-flex align-items-center">
                  <span class="nav-link-text ps-1">Clienți</span>
                </div>
              </a>
            </li>
            <li class="nav-item">
              <a class="nav-link <?php echo ($currentPage === 'abandoned-carts.php') ? 'active' : ''; ?>" href="/admin/cosuri-abandonate">
                <div class="d-flex align-items-center">
                  <span class="nav-link-text ps-1">Coșuri abandonate</span>
                </div>
              </a>
            </li>
          </ul>
        </li>
        <li class="nav-item">
          <div class="row navbar-vertical-label-wrapper mt-3 mb-2">
            <div class="col-auto navbar-vertical-label">Setări</div>
            <div class="col ps-0"><hr class="mb-0 navbar-vertical-divider" /></div>
          </div>
          <a class="nav-link <?php echo ($currentPage === 'b2b-groups.php') ? 'active' : ''; ?>" href="/admin/grupuri-b2b">
            <div class="d-flex align-items-center">
              <span class="nav-link-icon"><span class="fas fa-users"></span></span>
              <span class="nav-link-text ps-1">Grupuri B2B</span>
            </div>
          </a>
          <a class="nav-link <?php echo ($currentPage === 'loyalty-points.php') ? 'active' : ''; ?>" href="/admin/puncte-fidelitate">
            <div class="d-flex align-items-center">
              <span class="nav-link-icon"><span class="fas fa-star"></span></span>
              <span class="nav-link-text ps-1">Puncte fidelitate</span>
            </div>
          </a>
          <a class="nav-link <?php echo ($currentPage === 'import-export.php') ? 'active' : ''; ?>" href="/admin/import-export">
            <div class="d-flex align-items-center">
              <span class="nav-link-icon"><span class="fas fa-file-import"></span></span>
              <span class="nav-link-text ps-1">Import/Export</span>
            </div>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/api/auth.php?action=logout">
            <div class="d-flex align-items-center">
              <span class="nav-link-icon"><span class="fas fa-sign-out-alt"></span></span>
              <span class="nav-link-text ps-1">Deconectare</span>
            </div>
          </a>
        </li>
      </ul>
    </div>
  </div>
</nav>
<div class="content">
  <nav class="navbar navbar-light navbar-glass navbar-top navbar-expand">
    <button class="btn navbar-toggler-humburger-icon navbar-toggler me-1 me-sm-3" type="button" data-bs-toggle="collapse" data-bs-target="#navbarVerticalCollapse" aria-controls="navbarVerticalCollapse" aria-expanded="false" aria-label="Toggle Navigation">
      <span class="navbar-toggle-icon"><span class="toggle-line"></span></span>
    </button>
    <a class="navbar-brand me-1 me-sm-3" href="/admin">
      <div class="d-flex align-items-center">
        <img class="me-2" src="../../Falcon/assets/img/icons/spot-illustrations/falcon.png" alt="" width="40" />
        <span class="font-sans-serif text-primary">Admin Panel</span>
      </div>
    </a>
    <ul class="navbar-nav navbar-nav-icons ms-auto flex-row align-items-center">
      <li class="nav-item">
        <a class="nav-link" href="/" target="_blank">
          <span class="fas fa-external-link-alt" data-fa-transform="shrink-6"></span>
        </a>
      </li>
      <?php if ($adminUser): ?>
      <li class="nav-item dropdown">
        <a class="nav-link" id="navbarDropdownUser" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <div class="avatar avatar-s">
            <div class="avatar-name rounded-circle bg-primary-subtle text-primary">
              <span><?php echo strtoupper(substr($adminUser['username'] ?? 'A', 0, 1)); ?></span>
            </div>
          </div>
        </a>
        <div class="dropdown-menu dropdown-menu-end py-0" aria-labelledby="navbarDropdownUser">
          <div class="bg-white dark__bg-1000 rounded-2 py-2">
            <a class="dropdown-item fw-medium text-warning" href="#!">
              <span class="fas fa-user me-2"></span>Profil
            </a>
            <a class="dropdown-item fw-medium text-danger" href="/api/auth.php?action=logout">
              <span class="fas fa-sign-out-alt me-2"></span>Deconectare
            </a>
          </div>
        </div>
      </li>
      <?php endif; ?>
    </ul>
  </nav>

