{% from "_macros.html" import render_flash_messages %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}CPM Assessment{% endblock %}</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <a class="navbar-brand" href="{{ url_for('main.index') }}">CPM Assessment</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <div class="navbar-nav ml-auto">
                {% if current_user.is_authenticated %}
                    {% if current_user.role == 'admin' %}
                        <a class="nav-item nav-link" href="{{ url_for('admin.dashboard') }}">Admin</a>
                        <a class="nav-item nav-link" href="{{ url_for('admin.reports') }}">All Reports</a>
                    {% endif %}
                    {% if current_user.role == 'consultant' or current_user.role == 'admin' %}
                        <a class="nav-item nav-link" href="{{ url_for('consultant.dashboard') }}">Consultant</a>
                        <a class="nav-item nav-link" href="{{ url_for('consultant.reports') }}">Client Reports</a>
                    {% endif %}
                    <a class="nav-item nav-link" href="{{ url_for('profile.view_profile') }}">Account</a>
                    <a class="nav-item nav-link" href="{{ url_for('auth.logout') }}">Logout</a>
                {% else %}
                    <a class="nav-item nav-link" href="{{ url_for('auth.login') }}">Login</a>
                    <a class="nav-item nav-link" href="{{ url_for('auth.register') }}">Register</a>
                {% endif %}
            </div>
        </div>
    </nav>

    <main role="main" class="container">
        <div class="row">
            <div class="col-md-12">
                {{ render_flash_messages() }}
                {% block content %}{% endblock %}
            </div>
        </div>
    </main>

    <!-- Swapped slim jQuery for the full version, which is required for some Bootstrap JS features -->
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <!-- Add Chart.js for graphing -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <!-- Add the datalabels plugin for Chart.js to show values on the chart -->
    <script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2.0.0"></script>
    {% block scripts %}{% endblock %}
</body>
</html>
