<?php
$currentPage = $_SERVER['REQUEST_URI'] ?? '';
$authController = new AuthController();
$currentUser = $authController->getCurrentUser();
?>

<aside class="sidebar">
    <div class="sidebar-header">
        <div class="brand">
            <i class="bi bi-cake2-fill"></i>
            <span>Birthday Reminder</span>
        </div>
        <button class="sidebar-toggle" id="sidebarToggle">
            <i class="bi bi-list"></i>
        </button>
    </div>
    
    <div class="sidebar-user">
        <div class="user-avatar">
            <i class="bi bi-person-circle"></i>
        </div>
        <div class="user-info">
            <h6><?php echo htmlspecialchars($currentUser->username ?? 'Admin'); ?></h6>
            <small><?php echo htmlspecialchars($currentUser->email ?? ''); ?></small>
        </div>
    </div>
    
    <nav class="sidebar-nav">
        <ul class="nav flex-column">
            <li class="nav-item">
                <a class="nav-link <?php echo strpos($currentPage, '/dashboard') !== false ? 'active' : ''; ?>" 
                   href="<?php echo URL_PATH; ?>/admin/dashboard">
                    <i class="bi bi-speedometer2"></i>
                    <span>Dashboard</span>
                </a>
            </li>
            
            <li class="nav-item">
                <a class="nav-link <?php echo strpos($currentPage, '/user') !== false && strpos($currentPage, '/users') === false ? 'active' : ''; ?>" 
                   href="<?php echo URL_PATH; ?>/admin/users">
                    <i class="bi bi-people-fill"></i>
                    <span>Users</span>
                </a>
            </li>
            
            <li class="nav-item">
                <a class="nav-link <?php echo strpos($currentPage, '/template') !== false ? 'active' : ''; ?>" 
                   href="<?php echo URL_PATH; ?>/admin/templates">
                    <i class="bi bi-file-text"></i>
                    <span>Templates</span>
                </a>
            </li>
            
            <li class="nav-item">
                <a class="nav-link <?php echo strpos($currentPage, '/contact') !== false ? 'active' : ''; ?>" 
                   href="<?php echo URL_PATH; ?>/admin/contacts">
                    <i class="bi bi-people"></i>
                    <span>Contacts</span>
                </a>
            </li>
            
            <li class="nav-item">
                <a class="nav-link <?php echo strpos($currentPage, '/note') !== false ? 'active' : ''; ?>" 
                   href="<?php echo URL_PATH; ?>/admin/notes">
                    <i class="bi bi-sticky"></i>
                    <span>Notes</span>
                </a>
            </li>
            
            <li class="nav-item">
                <a class="nav-link <?php echo strpos($currentPage, '/excel') !== false ? 'active' : ''; ?>" 
                   href="<?php echo URL_PATH; ?>/admin/excel">
                    <i class="bi bi-file-earmark-excel"></i>
                    <span>Excel Import/Export</span>
                </a>
            </li>
            
            <li class="nav-divider"></li>
            
            <li class="nav-item">
                <a class="nav-link" href="<?php echo URL_PATH; ?>/admin/logout" onclick="return confirm('Are you sure you want to logout?')">
                    <i class="bi bi-box-arrow-right"></i>
                    <span>Logout</span>
                </a>
            </li>
        </ul>
    </nav>
    
    <div class="sidebar-footer">
        <small class="text-muted">v<?php echo APP_VERSION; ?></small>
    </div>
</aside>
