<!doctype html>
<html lang="{{ current_language }}-{{ current_lang_country }}">
<head>
  {% include "head_meta.html" %}
  {% include "dynamic_css.html" %}
  {% block head_meta %}{% endblock %}
  {{ dynamic_head | safe }}

  <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles.css') }}">
  <title>{% block title %}{{app_name}}{% endblock %}</title>
  <meta name="description" content="{% block description %} {{ app_description }} {% endblock %}">
</head>
<body>
{% block body_meta %}
{% include "body_meta.html" %}
{% endblock %}

{% with messages = get_flashed_messages(with_categories=true) %}
  {% if messages %}
    <div class="flash-messages">
      {% for category, message in messages %}
        <div class="alert alert-{{ category }}">{{ message }}</div>
      {% endfor %}
    </div>
  {% endif %}
{% endwith %}

<div class="container-fluid d-flex flex-column h-100 g-0">
  <div class="row header-row bg-light g-0">
    <nav class="navbar navbar-expand-lg navbar-light px-3 py-1" id="mainNav">
      {% if self.left_panel() %}
      <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#left-panel" aria-label="Toggle left panel">
        <i class="fas fa-sliders-h"></i>
      </button>
      {% endif %}

      <a class="navbar-brand" href="/" aria-label="{{_("Link to home page")}}">{% if logo_url %}<img src="{{ logo_url }}" alt="{{ app_name }} logo" class="logo">{% else %}{{_(app_name)}}{% endif %}</a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
              aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <i class="fas fa-bars"></i>
      </button>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav">
          {% for menu_item in menu_items %}
          <li class="nav-item">
            <a class="nav-link" href={{menu_item.url}} >{{_(menu_item.name)}}</a>
          </li>
          {% endfor %}
        </ul>
        <ul class="navbar-nav ms-auto">
          <li class="nav-item dropdown">
            <div id="language-dropdown" class="btn-group">
              <button type="button" class="nav-link dropdown-toggle btn btn-link" id="languages-menu" role="button"
                      data-bs-toggle="dropdown" aria-expanded="false" aria-label="{{ _("Language switch icon, used to change the language of the website")}}">
                <span class="language-indicator-text">{{ current_language }}</i>
                <i class="fi fi-{{ current_flag }}"></i>
              </button>
              <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="languages-menu">
                {% for lg,items in languages.items() %}
                <a class="dropdown-item" href={{url_for('change_language', lang=lg, _external=True)}}>
                  <i class="fi fi-{{ items['flag'] }} "></i>{{ items['name'] }}</a>
                {% endfor %}
              </ul>
            </div>
          </li>
        </ul>
      </div>
    </nav>
  </div>
  {% block header %}{% endblock %}

  <div class="row g-0" id="main-row">
    {% if self.left_panel() %}
    <div class="col-auto left-panel" >
      <div id="left-panel" class="left-panel offcanvas-lg offcanvas-start" aria-modal="true" role="dialog">
        <div class="offcanvas-header d-lg-none justify-content-end">
          <button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" data-bs-target="#left-panel" aria-label="{{ _('Close left panel') }}"></button>
        </div>
        <div class="offcanvas-body">
          <div class="left-panel-contents">
            {% block left_panel %}{% endblock %}
          </div>
        </div>
      </div>

    </div>
    {% endif %}
    <div class="h-100   {% if self.left_panel() %} col {% else %} col-lg-12 {% endif %}">
      <main class="h-100">
        {% block content %}{% endblock %}
      </main>
    </div>
  </div>

</div>
</body>
</html>
