{% load spirit_tags i18n %}
{% load_settings 'LOGIN_URL' %}

<header class="layout__header js-tabs-container">
  <div class="header__logo_wrapper">
    {% block custom_header_logo %}
      <a class="header__logo" href="{% url "spirit:index" %}"
      >{{ config.site_name }}</a>
    {% endblock %}
  </div>
  {% if user.is_authenticated %}
    {% has_topic_notifications user as has_notifications %}

    {% spaceless %}
      <ul class="header__tabs">
        <li><a
          class="header__tabs__item js-tab"
          href="{% url "spirit:search:search" %}"
          data-related=".js-search-content"
          ><i class="fa fa-search"></i></a></li>
        <li><a
          class="header__tabs__item js-tab-notification{% if has_notifications %} is-highlighted{% endif %}"
          href="{% url "spirit:topic:notification:index" %}"
          data-related=".js-notifications-content"
          data-content=".js-notifications-content-list"
          ><i class="fa fa-bell"></i></a></li>
        <li><a
          class="header__tabs__item js-tab"
          href="{% url "spirit:user:menu" %}"
          data-related=".js-user-content"
          >{{ user.st.nickname }} <i class="fa fa-chevron-down"></i></a></li>
      </ul>
    {% endspaceless %}

    <div class="header__tabs_content">
      <div class="header__tabs_content__tab js-tab-content js-user-content" style="display: none;">
        <nav class="header__tab__nav">
          {% spaceless %}
          <ul class="menu_list">
            <li><a
              class="menu_list__link"
              href="{% url "spirit:user:detail" pk=user.pk slug=user.st.slug %}"
              >{% trans "Profile" %}</a></li>
            <li><a
              class="menu_list__link"
              href="{% url "spirit:topic:index-active" %}"
              >{% trans "Topics" %}</a></li>
            <li><a
              class="menu_list__link"
              href="{% url "spirit:topic:unread:index" %}"
              >{% trans "Unread topics" %}</a></li>
            <li><a
              class="menu_list__link"
              href="{% url "spirit:topic:private:index" %}"
              >{% trans "Private topics" %}</a></li>
            {% if user.st.is_administrator %}
              <li><a
                class="menu_list__link"
                href="{% url "spirit:admin:index" %}"
                >{% trans "Admin" %}</a></li>
            {% endif %}
            <li><a
              class="menu_list__link js-post"
              href="{% url "spirit:user:auth:logout" %}?next={% firstof request.get_full_path|urlencode '/' %}"
              >{% trans "Log out" %}</a></li>
          </ul>
          {% endspaceless %}
        </nav>
      </div>
      <div class="header__tabs_content__tab js-tab-content js-notifications-content" style="display: none;">
        <div class="header__tab__bell js-notifications-content-list">
        </div>
      </div>
      <div class="header__tabs_content__tab js-tab-content js-search-content" style="display: none;">
        <div class="header__tab__search">
          {% render_search_form %}
        </div>
      </div>
    </div>
  {% else %}
    <a class="header__login"
      href="{% url st_settings.LOGIN_URL %}?next={% firstof request.get_full_path|urlencode '/' %}"
    >{% trans "Log in" %}</a>
  {% endif %}

  {% render_messages messages %}
</header>
