{% 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(152, 199, 231);">
        <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(152, 199, 231);"> 
                
                <!-- 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>
                    <!-- Species Search (Direct Link) -->
                    <li class="nav-item">
                        <a class="nav-link {% if request.resolver_match.url_name == 'speciesSearch' %}active{% endif %}" 
                        href="{% url 'speciesSearch' %}">&nbsp;Species Search&nbsp;</a>
                    </li> 
                    <!-- Aquarists (Direct Link) -->
                    <li class="nav-item">
                        <a class="nav-link {% if request.resolver_match.url_name == 'aquarists' %}active{% endif %}" 
                        href="{% url 'aquarists' %}">&nbsp;Aquarists&nbsp;</a>
                    </li> 
                    {% if user.is_authenticated %}
                        <!-- Community (Dropdown) -->
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle {% if 'club' in request.path %}active{% endif %}" 
                            href="#" id="clubsDropdown" role="button" 
                            data-bs-toggle="dropdown" aria-expanded="false">&nbsp;Community&nbsp;</a>
                            <ul class="dropdown-menu" aria-labelledby="clubsDropdown">
                                <li><a class="dropdown-item" href="{% url 'aquaristClubs' %}">Aquarist Clubs</a></li>
                                <li><a class="dropdown-item" href="{% url 'bap_overview' %}">BAP Program Overview</a></li>
                                <li><a class="dropdown-item" href="{% url 'cares_overview' %}">CARES Preservation Program</a></li>
                                <li><a class="dropdown-item" href="{% url 'speciesMaintenanceLogs' %}">Species Maintenance Groups</a></li>
                            </ul>
                        </li>
                    {% endif %}
                </ul>
                
                <!-- Right-aligned menu items (user account) -->
                <ul class="navbar-nav ms-auto">
                    {% if user.is_authenticated %}
                        <!-- Account (Dropdown when logged in) -->
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="accountDropdown" role="button" 
                            data-bs-toggle="dropdown" aria-expanded="false">{{ user.username }}</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 'aquarist' user.id %}">Fishroom</a></li>
                                {% if request.user.is_species_admin or request.user.is_staff or request.user.is_species_admin %}
                                    <li><a class="dropdown-item" href="{% url 'tools' %}">Tools</a></li>
                                {% endif %}
                                {% if request.user.is_species_admin or request.user.is_staff %}
                                    <li><a class="dropdown-item" href="{% url 'tools2' %}">Tools2</a></li>
                                {% endif %}                                
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="{% url 'logout' %}">Logout</a></li>
                            </ul>
                        </li>
                    {% else %}
                        <!-- Login/Create-Account links when not logged in -->
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'account_login' %}">&nbsp;Sign-in&nbsp;</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="/signup">&nbsp;Create Account&nbsp;</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>
</div>