<?php
require_once __DIR__ . '/../includes/auth.php';
require_once __DIR__ . '/../includes/helpers.php';
require_login();

$role = $_SESSION['user_role'] ?? '';  // Cambiado a 'user_role'

// Define URL del dashboard para cada rol
if ($role === 'superadmin') {
    $dashboard_url = '/miportal_pro/superadmin/dashboard.php';
} elseif ($role === 'admin') {
    $dashboard_url = '/miportal_pro/admin/dashboard.php';
} else {
    $dashboard_url = '/miportal_pro/client/dashboard.php';
}
?>
<!doctype html>
<html lang="es">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="/miportal_pro/assets/css/estilos.css" />
<title><?= e($title ?? 'MiPortal') ?></title>
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  <div class="container-fluid">
    <a class="navbar-brand" href="<?= e($dashboard_url) ?>">MiPortal</a>
    <div class="collapse navbar-collapse">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        <?php if ($role === 'superadmin'): ?>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/superadmin/dashboard.php">Dashboard SuperAdmin</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/superadmin/request_code_superadmin.php">Consultar Codigo</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/superadmin/clients.php">Clientes</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/superadmin/platforms.php">Plataformas</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/superadmin/assigned_accounts.php">Cuentas Asignadas</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/superadmin/imap.php">Imap</a></li>
        <?php elseif ($role === 'admin'): ?>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/admin/dashboard.php">Dashboard Admin</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/admin/clients.php">Clientes</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/admin/platforms.php">Plataformas</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/admin/assigned_accounts.php">Cuentas Asignadas</a></li>
        <?php else: ?>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/client/dashboard.php">Inicio</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/client/request_code.php">Consultar Codigo</a></li>
          <li class="nav-item"><a class="nav-link" href="/miportal_pro/client/assigned_summary.php">Resumen Cuentas</a></li>
        <?php endif; ?>
      </ul>
      <span class="navbar-text me-3"><?= e(current_user()['email'] ?? '') ?></span>
      <a class="btn btn-outline-light btn-sm" href="/miportal_pro/public/logout.php">Salir</a>
    </div>
  </div>
</nav>
<!-- Contenido de la página -->
<div class="container my-4">
