</html>
<!doctype html>
<html lang="pl">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
  <title>{% block title %}Panel{% endblock %}</title>

  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}">

  {% block head %}{% endblock %}
</head>

<body class="d-flex flex-column min-vh-100">

  <header class="border-bottom border-secondary-subtle">
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark" aria-label="Główna nawigacja">
      <div class="container-xxl">
        <a class="navbar-brand fw-semibold text-primary" href="{{ url_for('index') }}">autoban</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav"
          aria-controls="mainNav" aria-label="Menu">
          <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="mainNav">
          <ul class="navbar-nav me-auto mb-2 mb-lg-0">
            <li class="nav-item"><a class="nav-link {% if request.endpoint=='index' %}active{% endif %}"
                href="{{ url_for('index') }}">Dashboard</a></li>
            <li class="nav-item"><a class="nav-link {% if request.endpoint=='ban_management' %}active{% endif %}"
                href="{{ url_for('ban_management') }}">Zarządzanie Banami</a></li>
            <li class="nav-item"><a class="nav-link {% if request.endpoint=='stats_page' %}active{% endif %}"
                href="{{ url_for('stats_page') }}">Statystyki</a></li>
            <li class="nav-item"><a class="nav-link {% if request.endpoint=='charts_page' %}active{% endif %}"
                href="{{ url_for('charts_page') }}">Wykresy</a></li>
            <li class="nav-item"><a class="nav-link {% if request.endpoint=='view_logs' %}active{% endif %}"
                href="{{ url_for('view_logs') }}">Logi</a></li>
            <li class="nav-item"><a class="nav-link {% if request.endpoint=='check_ip_info' %}active{% endif %}"
                href="{{ url_for('check_ip_info') }}">Sprawdź IP</a></li>
            <li class="nav-item"><a class="nav-link {% if request.endpoint=='reset_counters' %}active{% endif %}"
                href="{{ url_for('reset_counters') }}">Reset błędów</a></li>
          </ul>
          <form class="d-flex" action="{{ url_for('check_ip_info') }}" method="post" role="search">
            <input class="form-control form-control-sm bg-dark text-white border-secondary" name="ip"
              placeholder="Szybkie IP" inputmode="numeric" pattern="\d{1,3}(\.\d{1,3}){3}">
          </form>
        </div>
      </div>
    </nav>
  </header>

  <main id="main" class="container-xxl flex-grow-1 py-3">
    {% block content %}{% endblock %}
  </main>

  <footer class="border-top border-secondary-subtle mt-auto bg-dark">
    <div class="container-xxl py-3 text-secondary small d-flex flex-wrap gap-2 justify-content-between">
      <span>linuxiarz.pl</span>
      <a class="link-secondary" href="{{ url_for('healthcheck') }}">Status</a>
    </div>
  </footer>

  {# GLOBALNY TOAST (w całej aplikacji) #}
  <div class="position-fixed end-0 bottom-0 p-3" style="z-index:1080;">
    <div id="appToast" class="toast text-bg-dark border border-secondary" role="status" aria-live="polite"
      aria-atomic="true">
      <div class="toast-header bg-dark text-white border-bottom border-secondary">
        <strong class="me-auto">{{ app_name or "Ban Manager" }}</strong>
        <small>Teraz</small>
        <button class="btn-close btn-close-white ms-2 mb-1" data-bs-dismiss="toast" aria-label="Zamknij"></button>
      </div>
      <div class="toast-body" id="appToastBody">Gotowe.</div>
    </div>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  <script src="{{ url_for('static', filename='js/toast.js') }}" defer></script>
  {% block scripts %}{% endblock %}
</body>

</html>