<!doctype html>
<html lang="ru">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="icon" href="https://deev.space/media/favicon.ico" type="image/x-icon">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">

    <title>
        {% if title %}
          {{ title }}
        {% else %}
          Лабораторная работа №4
        {% endif %}
    </title>
  </head>
  <body>
    <header>
        <nav class="navbar navbar-expand-lg navbar-dark">
            <div class="container">
              <a class="navbar-brand" href="{{ url_for('index') }}">Лабораторная работа № 4</a>
              <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
              </button>
              <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
                  <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('index') }}"><i class="fas fa-home"></i> Задание</a>
                  </li>

                  <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navDropdownContent" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                      <i class="fas fa-newspaper"></i> Лаб. 1
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navDropdownContent">
                      <li><a class="dropdown-item" href="{{ url_for('posts') }}"><i class="fas fa-newspaper"></i> Посты</a></li>
                      <li><a class="dropdown-item" href="{{ url_for('about') }}"><i class="fas fa-user"></i> Об авторе</a></li>
                    </ul>
                  </li>

                  <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navDropdownLab2" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                      <i class="fas fa-flask"></i> Лаб. 2
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navDropdownLab2">
                      <li><a class="dropdown-item" href="{{ url_for('request_data') }}"><i class="fas fa-database"></i> Данные запроса</a></li>
                      <li><a class="dropdown-item" href="{{ url_for('phone') }}"><i class="fas fa-phone"></i> Телефон</a></li>
                    </ul>
                  </li>

                  {% if current_user.is_authenticated %}
                  <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navDropdownLab3" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                      <i class="fas fa-shield-alt"></i> Лаб. 3
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navDropdownLab3">
                      <li><a class="dropdown-item" href="{{ url_for('visits') }}"><i class="fas fa-eye"></i> Счётчик</a></li>
                      <li><a class="dropdown-item" href="{{ url_for('secret') }}"><i class="fas fa-lock"></i> Секретная</a></li>
                    </ul>
                  </li>
                  {% else %}
                  <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('visits') }}"><i class="fas fa-eye"></i> Счётчик</a>
                  </li>
                  {% endif %}

                  {% if current_user.is_authenticated %}
                  <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navDropdownLab4" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                      <i class="fas fa-users"></i> Лаб. 4
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navDropdownLab4">
                      <li><a class="dropdown-item" href="{{ url_for('users_list') }}"><i class="fas fa-users"></i> Пользователи</a></li>
                      <li><a class="dropdown-item" href="{{ url_for('change_password') }}"><i class="fas fa-key"></i> Сменить пароль</a></li>
                    </ul>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('logout') }}"><i class="fas fa-sign-out-alt"></i> Выйти</a>
                  </li>
                  {% else %}
                  <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('users_list') }}"><i class="fas fa-users"></i> Пользователи</a>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" href="{{ url_for('auth') }}"><i class="fas fa-sign-in-alt"></i> Войти</a>
                  </li>
                  {% endif %}
                </ul>
              </div>
            </div>
          </nav>
    </header>

    <main class="my-1">
        <div class="container">
            {% with messages = get_flashed_messages(with_categories=true) %}
                {% if messages %}
                <div class="flash-messages mt-3">
                    {% for category, message in messages %}
                    <div class="flash-message flash-{{ category }}">
                        <div class="flash-icon">
                            {% if category == 'success' %}
                            <i class="fas fa-check-circle"></i>
                            {% elif category == 'error' %}
                            <i class="fas fa-exclamation-circle"></i>
                            {% elif category == 'warning' %}
                            <i class="fas fa-exclamation-triangle"></i>
                            {% else %}
                            <i class="fas fa-info-circle"></i>
                            {% endif %}
                        </div>
                        <span>{{ message }}</span>
                    </div>
                    {% endfor %}
                </div>
                {% endif %}
            {% endwith %}

            {% block content %}
                <h1>Содержимое по умолчанию</h1>
            {% endblock %}
        </div>
    </main>

    <footer>
        <div class="container">
            <div class="footer-content">
                <div>
                    <div class="footer-name">Деев Егор Викторович, ст. гр. 241-327</div>
                    <div class="footer-group">Московский Политехнический университет</div>
                </div>
                <div class="footer-links">
                    <a href="mailto:egor@deev.space">egor@deev.space</a>
                    <a href="https://deev.space" target="_blank">My Site</a>
                    <a href="https://t.me/Egor_Deev" target="_blank">Telegram</a>
                    <a href="https://github.com/EDeev" target="_blank">GitHub</a>
                </div>
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
  </body>
</html>
