<nav class="bg-white shadow-sm border-b border-gray-200">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex justify-between h-16">
            <div class="flex items-center">
                <div class="flex-shrink-0 flex items-center">
                    <div class="w-10 h-10 bg-indigo-600 rounded-lg flex items-center justify-center text-white">
                        <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
                        </svg>
                    </div>
                    <span class="ml-3 text-xl font-bold text-gray-900">Contratos</span>
                </div>
                <?php
                $navRol = $user['rol'] ?? ($rol ?? 'asesor');
                $esNavAdmin = ($navRol === 'administrador');
                $navActive = 'border-indigo-600 text-gray-900';
                $navInactive = 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700';
                $cur = basename($_SERVER['PHP_SELF']);
                ?>
                <div class="hidden sm:ml-8 sm:flex sm:space-x-6">
                    <a href="<?= base_url('admin/dashboard') ?>" class="<?= $cur === 'dashboard.php' ? $navActive : $navInactive ?> inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
                        Dashboard
                    </a>
                    <a href="<?= base_url('admin/crear-contrato') ?>" class="<?= $cur === 'crear-contrato.php' ? $navActive : $navInactive ?> inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
                        Crear Contrato
                    </a>
                    <a href="<?= base_url('admin/plantillas-contratos.php') ?>" class="<?= $cur === 'plantillas-contratos.php' ? $navActive : $navInactive ?> inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
                        Plantillas
                    </a>
                    <?php if ($esNavAdmin): ?>
                        <a href="<?= base_url('admin/usuarios') ?>" class="<?= $cur === 'usuarios.php' ? $navActive : $navInactive ?> inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
                            Usuarios
                        </a>
                        <a href="<?= base_url('admin/access-logs') ?>" class="<?= $cur === 'access-logs.php' ? $navActive : $navInactive ?> inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
                            Access Logs
                        </a>
                        <a href="<?= base_url('admin/user-tracker') ?>" class="<?= $cur === 'user-tracker.php' ? $navActive : $navInactive ?> inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
                            Tracker
                        </a>
                    <?php endif; ?>
                </div>
            </div>
            <div class="flex items-center">
                <div class="flex items-center space-x-4">
                    <span class="text-sm text-gray-700"><?= htmlspecialchars($user['nombre'] ?? 'Admin') ?></span>
                    <?php if ($esNavAdmin): ?>
                        <span class="text-xs bg-violet-100 text-violet-700 px-2 py-0.5 rounded-full font-medium">Admin</span>
                    <?php else: ?>
                        <span class="text-xs bg-blue-100 text-blue-700 px-2 py-0.5 rounded-full font-medium">Asesor</span>
                    <?php endif; ?>
                    <a href="<?= base_url('admin/logout') ?>" class="text-sm text-red-600 hover:text-red-700 font-medium">
                        Cerrar Sesión
                    </a>
                </div>
            </div>
        </div>
    </div>
</nav>