{% load static i18n compress%}

<nav class="navbar navbar-expand navbar-light bg-white topbar mb-1 static-top shadow">
    <!-- Sidebar Toggle (Topbar) -->
    <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
        <i class="fa fa-bars"></i>
    </button>


    <!-- Topbar Navbar -->
    <ul class="navbar-nav ml-auto">

        <!-- Nav Item - Search Dropdown (Visible Only XS) -->
        <li class="nav-item dropdown no-arrow d-sm-none">
            <a class="nav-link dropdown-toggle" href="#" id="searchDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="fas fa-search fa-fw"></i>
            </a>
            <!-- Dropdown - Messages -->
            <div class="dropdown-menu dropdown-menu-right p-3 shadow animated--grow-in">
                <form class="form-inline mr-auto w-100 navbar-search">
                    <div class="input-group">
                        <input type="text" class="form-control bg-light border-0 small" placeholder="Search for..." aria-label="Search">
                        <div class="input-group-append">
                            <button class="btn btn-primary" type="button">
                                <i class="fas fa-search fa-sm"></i>
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </li>

        <!-- Nav Item - Messages -->
        {% if messages %}
        <li class="nav-item dropdown no-arrow mx-1">
            <a class="nav-link dropdown-toggle" href="#" id="messagesDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="fas fa-envelope fa-fw"></i>
                <!-- Counter - Messages -->
                <span class="badge badge-danger badge-counter">{{messages|length}}</span>
            </a>
            <!-- Dropdown - Messages -->
            <div class="dropdown-list dropdown-menu dropdown-menu-right shadow animated--grow-in">
                <h6 class="dropdown-header">
                    Message Center
                </h6>
                {% for message in messages %}
                    <a class="dropdown-item d-flex align-items-center" href="#">
                        <div class="dropdown-list-image mr-3 {% if message.tags %}alert-{{ message.tags }}{% endif %}">
                            <img class="rounded-circle" src="{% static 'images/undraw_profile_1.svg' %}" alt="Profile">
                            <div class="status-indicator bg-success"></div>
                        </div>
                        <div class="font-weight-bold">
                            <div class="text">{{ message }}</div>
                            <div class="small text-gray-500">System Message</div>
                        </div>
                    </a>
                {% endfor %}
            </div>
        </li>
        {% endif %}

        <div class="topbar-divider d-none d-sm-block"></div>

        <!-- Nav Item - User Information -->
        <li class="nav-item dropdown no-arrow">
            <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="mr-2 d-none d-lg-inline text-gray-600 small">
                    {% firstof user.name user.username user.email %}
                </span>
                <img class="img-profile rounded-circle" src="{% static 'images/undraw_profile.svg' %}" alt="Profile Avatar">
            </a>
            <!-- Dropdown - User Information -->
            <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in">
                {% if request.user.is_authenticated %}
                <a class="dropdown-item" href="{% url 'account_email' %}">
                    <i class="fas fa-envelope fa-sm fa-fw mr-2 text-gray-400"></i>
                    My Email Addresses
                </a>
                <a class="dropdown-item" href="{% url 'users:update' %}">
                    <i class="fas fa-info fa-sm fa-fw mr-2 text-gray-400"></i>
                    My Info
                </a>
                {% comment %}  {% endcomment %}
                <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
                    <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i> Logout
                </a>
                {% else %}
                <a class="dropdown-item" href="{% url 'account_login' %}">
                    <i class="fas fa-list fa-sm fa-fw mr-2 text-gray-400"></i> Sign In
                </a>
                <a class="dropdown-item" href="{% url 'account_signup' %}">
                    <i class="fas fa-list fa-sm fa-fw mr-2 text-gray-400"></i> Sign Up
                </a>
                {% endif %}
                {% if perms.users.can_view_about %}
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="{% url 'about' %}">
                        <i class="fas fa-cogs fa-sm fa-fw mr-2 text-gray-400"></i> About
                    </a>
                {% endif %}
            </div>
        </li>
    </ul>
</nav>
