{% load static %}

<div class="container-lg px-0">
    <div class="navbar navbar-expand-lg bg-body-secondary border-start border-end border-bottom">
        <div class="container">
            <a href="/" class="navbar-brand">
                <img src="{% static '/images/pyrss_logo.webp' %}" alt="Logo" width="50" class="d-inline-block">
            </a>
            <button type="button" class="navbar-toggler" data-bs-toggle="offcanvas" data-bs-target="#navCollapse" aria-controls="navCollapse" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div id="navCollapse" class="offcanvas offcanvas-end" tabindex="-1" aria-labelledby="navCollapseLabel">
                <div class="offcanvas-header">
                    <h5 id="navCollapseLabel" class="offcanvas-title">PYRSS</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
                </div>
                <div class="offcanvas-body">
                    <ul class="navbar-nav justify-content-end flex-grow-1 pe-3 align-items-center">
                        <li class="nav-item">
                            <button type="button" id="themeToggle" class="me-3 btn btn-link p-0 text-body">
                                <i class="bi bi-sun"></i>
                            </button>
                        </li>
                        {% if request.user.is_authenticated %}
                        <li class="nav-item">
                            <div class="dropdown">
                                <button type="button" class="nav-link dropdown-toggle" data-bs-toggle="dropdown">
                                    <img src="{{ request.user.avatar_url }}" alt="User Icon" width="30" class="rounded-circle me-2">
                                    <span>{{ request.user.global_name }}</span>
                                </button>
                                <ul class="dropdown-menu">
                                    <li><h6 class="dropdown-header">@{{ request.user.username }}</h6></li>
                                    <li>
                                        <a href="https://gitea.corbz.dev/corbz/PYRSS-Website/src/branch/master/README.md" class="dropdown-item" target="_blank">
                                            <i class="bi bi-question"></i><span class="ms-2">Help</span>
                                        </a>
                                    </li>
                                    <li>
                                        {% comment %}<!-- Logout only accepts POST requests -->{% endcomment %}
                                        <form action="/logout/" method="post" class="m-0">
                                            {% csrf_token %}
                                            <button type="submit" class="dropdown-item">
                                                <i class="bi bi-arrow-left-short"></i><span class="ms-2">Logout</span>
                                            </button>
                                        </form>
                                    </li>
                                    {% if request.user.is_superuser %}
                                    <li><hr class="dropdown-divider"></li>
                                    <li>
                                        <a href="/admin/" class="dropdown-item" target="_blank">
                                            <i class="bi bi-person-check-fill"></i><span class="ms-2">Admin Interface</span>
                                        </a>
                                    </li>
                                    {% endif %}
                                </ul>
                            </div>
                        </li>
                        {% endif %}
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>