<!doctype html>
<html lang="de" data-bs-theme="light">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>{% block title %}Mould King Control{% endblock %}</title>

    <!-- Bootstrap 5.3 CSS CDN -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
            rel="stylesheet"
            integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
            crossorigin="anonymous">

    <!-- highlight.js für Syntax-Highlighting in Logs -->
    <link rel="stylesheet" href="{{ url_for('static', filename='css/default.min.css') }}">
    <script src="{{ url_for('static', filename='js/highlight.min.js') }}"></script>
    <script src="{{ url_for('static', filename='js/hljs-log.js') }}"></script>
    <script>hljs.highlightAll();</script>

    <!-- Eigenes CSS (optional – später erweitern) -->
    <link rel="stylesheet" href="{{ url_for('static', filename='css/custom.css') }}">

  {% block head_extra %}{% endblock %}
</head>
<body class="d-flex flex-column min-vh-100">

  <!-- Navbar -->
  <nav class="navbar navbar-expand-lg bg-dark navbar-dark">
    <div class="container-fluid">
      <a class="navbar-brand" href="{{ url_for('main.index') }}">MK Control</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">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav me-auto">
          <li class="nav-item">
            <a class="nav-link {% if request.path == url_for('main.index') %}active{% endif %}"
               href="{{ url_for('main.index') }}">Home</a>
          </li>
          <li class="nav-item">
            <a class="nav-link {% if 'control' in request.path %}active{% endif %}"
               href="{{ url_for('main.index') }}">Steuerung</a>
          </li>
          <li class="nav-item">
            <a class="nav-link {% if 'admin' in request.path %}active{% endif %}"
               href="{{ url_for('admin.admin') }}">Admin</a>
          </li>
          <li class="nav-item">
            <a class="nav-link {% if 'soundboard' in request.path %}active{% endif %}"
                href="{{ url_for('main.soundboard') }}">Soundboard</a>
            </li>
        </ul>
      </div>
    </div>
  </nav>

  <!-- Hauptinhalt -->
  <main class="flex-grow-1 py-4">
    <div class="container">
      {% with messages = get_flashed_messages(with_categories=true) %}
        {% if messages %}
          {% for category, message in messages %}
            <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
              {{ message }}
              <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
          {% endfor %}
        {% endif %}
      {% endwith %}

      {% block content %}{% endblock %}
    </div>
  </main>

  <!-- Footer -->
  <footer class="bg-dark text-white text-center py-3 mt-auto">
    <div class="container">
      <p class="mb-0">Mould King Bluetooth Control &copy; 2025–2026 | Powered by Flask & Bootstrap</p>
    </div>
  </footer>

  <!-- Bootstrap JS Bundle (inkl. Popper) -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
          integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
          crossorigin="anonymous"></script>

{% block scripts %}
  <!-- Alle JS-Module laden (immer) -->
  <script src="{{ url_for('static', filename='js/config.js') }}"></script>
  <script src="{{ url_for('static', filename='js/ui-status.js') }}"></script>
  <script src="{{ url_for('static', filename='js/ui-connect.js') }}"></script>
  <script src="{{ url_for('static', filename='js/ui-channels.js') }}"></script>
  <script src="{{ url_for('static', filename='js/ui-soundboard.js') }}"></script>
  <script src="{{ url_for('static', filename='js/connection-check.js') }}"></script>

  <!-- Einstiegspunkt -->
  <script src="{{ url_for('static', filename='js/app.js') }}"></script>

  <!-- Initialisierung aufrufen -->
  <script>
    initConfig();
    initStatus();
    initConnect();
    initChannels();
    initSoundboard();
    // connection-check wird von connect/reconnect aufgerufen
  </script>
{% endblock %}
</body>
</html>