<?php
use App\Services\AuthService;
if (session_status() === PHP_SESSION_NONE) session_start();
// Helper de URL debe estar disponible
if (!function_exists('siteUrl')) {
    require_once __DIR__ . '/../../src/Helpers/functions.php';
}

$auth = new AuthService();
$user = $auth->getCurrentUser();
?>
<nav class="navbar">
    <a href="<?= siteUrl('index.php') ?>" class="nav-brand">Contenedor Ibiza</a>
    
    <div class="nav-menu">
        <a href="<?= siteUrl('index.php') ?>" class="nav-link">Inicio</a>
        <a href="<?= siteUrl('rotaciones.php') ?>" class="nav-link">Rotaciones</a>
        <a href="<?= siteUrl('horarios.php') ?>" class="nav-link">Horarios</a>
        
        <?php if ($auth->hasRole(['admin', 'coordinador'])): ?>
            <a href="<?= siteUrl('admin/usuarios.php') ?>" class="nav-link">Usuarios</a>
        <?php endif; ?>
        <?php if ($auth->isAdmin()): ?>
            <a href="<?= siteUrl('admin/telegram.php') ?>" class="nav-link">Telegram</a>
        <?php endif; ?>
        
        <div style="border-left: 1px solid #e2e8f0; padding-left: 1rem; margin-left: 0.5rem; display: flex; align-items: center; gap: 1rem;">
            <span style="font-size: 0.9rem; font-weight: 600;"><?= e($user['username']) ?></span>
            <a href="<?= siteUrl('logout.php') ?>" class="btn btn-sm btn-secondary" style="text-decoration: none;">Salir</a>
        </div>
    </div>
</nav>
