{% load static %}

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>

<div class="div-line-below">
    <nav class="navbar navbar-expand-lg navbar-dark" style="background-color: rgb(183, 208, 189);">
        <div class="container">
            <!-- Brand is used when menu collapses on mobile devices -->
            <a class="navbar-brand" style="font-size: 1rem;" href="{% url 'home' %}">Home</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarMain" aria-controls="navbarMain" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarMain" style="background-color: rgb(183, 208, 189);"> 
                
                <!-- Main Navbar Menus and Direct Links -->       
                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                    <!-- About (Direct Link) -->
                    <li class="nav-item">
                        <a class="nav-link {% if request.resolver_match.url_name == 'about_us' %}active{% endif %}" 
                        href="{% url 'about_us' %}">&nbsp;About Us&nbsp;</a>
                    </li>
                    <!-- CARES Priority List - Species Search (Direct Link) -->
                    <li class="nav-item">
                        <a class="nav-link {% if request.resolver_match.url_name == 'caresSpeciesSearch' %}active{% endif %}" 
                        href="{% url 'caresPriorityList' %}">&nbsp;Priority List&nbsp;</a>
                    </li> 
                    <li class="nav-item">
                        <a class="nav-link {% if request.resolver_match.url_name == 'caresSpeciesSearch' %}active{% endif %}" 
                        href="{% url 'caresSpeciesSearch' %}">&nbsp;Species Search&nbsp;</a>
                    </li>                     
                        {% if request.user.is_authenticated %}
                            <!-- Registrations (Direct Link) -->
                            <li class="nav-item">
                                <a class="nav-link {% if request.resolver_match.url_name == 'caresRegistrations' %}active{% endif %}" 
                                href="{% url 'caresRegistrations' %}?reg_status=OPEN">&nbsp;Registrations&nbsp;</a>
                            </li> 
                        {% else %}
                            <li class="nav-item dropdown">
                                <a class="nav-link dropdown-toggle" href="#" id="accountDropdown" role="button" 
                                data-bs-toggle="dropdown" aria-expanded="false">Registration</a>
                                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="accountDropdown">
                                    <li><a class="dropdown-item" href="{% url 'registerCaresSelectSpecies' %}">Register your CARES Species</a></li>
                                    <li><a class="dropdown-item" href="{% url 'registrationLookup' %}">Check your CARES Registration Status</a></li>  
                                </ul>                                  
                            </li>
                        {% endif %}
                </ul>

                <!-- Right-aligned menu items (admin) -->
                <ul class="navbar-nav ms-auto">
                    {% if user.is_authenticated %}
                        <!-- Admin dropdown (admin only) -->
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="accountDropdown" role="button" 
                            data-bs-toggle="dropdown" aria-expanded="false">Admin</a>
                            <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="accountDropdown">
                                <li><a class="dropdown-item" href="{% url 'userProfile' %}">Profile</a></li>
                                <li><a class="dropdown-item" href="{% url 'aquaristClubs' %}">Clubs</a></li>                                    
                                <li><a class="dropdown-item" href="{% url 'caresApprovers' %}">CARES Approvers</a></li>
                                {% if request.user.is_staff or request.user.is_admin %}
                                    <li><a class="dropdown-item" href="{% url 'createCaresApprover' %}">Add CARES Approver</a></li>
                                {% endif %}
                                {% if request.user.is_staff or request.user.is_admin or request.user.is_species_admin %}
                                    <li><a class="dropdown-item" href="{% url 'createCaresSpecies' %}">Add CARES Species</a></li>
                                {% endif %}
                                {% if request.user.is_staff or request.user.is_admin %}
                                    <li><a class="dropdown-item" href="{% url 'tools' %}">Tools</a></li>
                                {% endif %}
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="{% url 'logout' %}">Logout {{ request.user.username }}</a></li>
                            </ul>
                        </li>
                    {% else %}
                        <!-- Login link when not logged in -->
                        <!--li class="nav-item">
                            <a class="nav-link" href="{% url 'account_login' %}">&nbsp;Sign-in&nbsp;</a>
                        </li-->
                    {% endif %}
                </ul>     

            </div>
        </div>
    </nav>
</div>