<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>سامانه جامع مهدی</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
    <link rel="stylesheet" href="/portal/assets/css/style.css">
    <link rel="shortcut icon" href="/portal/assets/images/favicon.ico" type="image/x-icon">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom">
        <div class="container">
            <a class="navbar-brand fw-bold" href="/portal/index.php">
                <i class="bi bi-mortarboard-fill text-primary"></i>
                سامانه جامع مهدی
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <?php if(isset($_SESSION['user_id'])): ?>
                        <li class="nav-item"><a class="nav-link" href="/portal/members/register.php"><i class="bi bi-person-plus"></i> ثبت‌نام جدید</a></li>
                        
                        <?php if(isset($_SESSION['user_level']) && $_SESSION['user_level'] == 'admin'): ?>
                            <li class="nav-item"><a class="nav-link" href="/portal/admin/dashboard.php"><i class="bi bi-speedometer2"></i> داشبورد</a></li>
                            <li class="nav-item"><a class="nav-link" href="/portal/admin/users.php"><i class="bi bi-people"></i> کاربران</a></li>
                            <li class="nav-item"><a class="nav-link" href="/portal/admin/fields.php"><i class="bi bi-gear"></i> فیلدها</a></li>
                            <li class="nav-item"><a class="nav-link" href="/portal/admin/reports.php"><i class="bi bi-file-earmark-text"></i> گزارشات</a></li>
                            <li class="nav-item"><a class="nav-link" href="/portal/admin/utm_links.php"><i class="bi bi-link-45deg"></i> مدیریت لینک‌ها</a></li>
                            <li class="nav-item"><a class="nav-link" href="/portal/admin/system_logs.php"><i class="bi bi-clock-history"></i> لاگ</a></li>
                        <?php endif; ?>
                        
                        <?php if(isset($_SESSION['user_level']) && $_SESSION['user_level'] == 'expert'): ?>
                            <li class="nav-item"><a class="nav-link" href="/portal/expert/dashboard.php"><i class="bi bi-clipboard-check"></i> پیگیری</a></li>
                            <li class="nav-item"><a class="nav-link" href="/portal/admin/reports.php"><i class="bi bi-file-earmark-text"></i> گزارشات</a></li>
                        <?php endif; ?>
                        
                        <?php if(isset($_SESSION['user_level']) && $_SESSION['user_level'] == 'reporter'): ?>
                            <li class="nav-item"><a class="nav-link" href="/portal/admin/reports.php"><i class="bi bi-file-earmark-text"></i> گزارشات</a></li>
                        <?php endif; ?>
                        
                        <?php if(isset($_SESSION['user_level']) && $_SESSION['user_level'] == 'representative'): ?>
                            <li class="nav-item"><a class="nav-link" href="/portal/representative/dashboard.php"><i class="bi bi-bar-chart"></i> داشبورد من</a></li>
                        <?php endif; ?>
                        
                        <!-- ===== لینک راهنما برای کاربران لاگین‌شده ===== -->
                        <li class="nav-item"><a class="nav-link" href="/portal/help_pro.php"><i class="bi bi-question-circle"></i> راهنما</a></li>
                        
                        <li class="nav-item"><a class="nav-link text-danger" href="/portal/auth/logout.php"><i class="bi bi-box-arrow-right"></i> خروج</a></li>
                    <?php else: ?>
                        <!-- ===== لینک راهنما برای کاربران مهمان ===== -->
                        <li class="nav-item"><a class="nav-link" href="/portal/help_pro.php"><i class="bi bi-question-circle"></i> راهنما</a></li>
                        <li class="nav-item"><a class="nav-link" href="/portal/auth/login.php"><i class="bi bi-box-arrow-in-right"></i> ورود</a></li>
                    <?php endif; ?>
                </ul>
            </div>
        </div>
    </nav>
    <div class="container mt-4">