<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>{{ title }} - Pynenc Monitor</title>

    <!-- Bootstrap CSS from CDN -->
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
      rel="stylesheet"
    />

    <!-- HTMX for dynamic updates -->
    <script src="https://unpkg.com/htmx.org@1.9.2"></script>
  </head>
  <body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
      <div class="container-fluid">
        <a class="navbar-brand" href="/">Pynenc Monitor</a>
        <button
          class="navbar-toggler"
          type="button"
          data-bs-toggle="collapse"
          data-bs-target="#navbarNav"
        >
          <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" href="/">Dashboard</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/broker">Broker</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/orchestrator">Orchestrator</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/state-backend">State Backend</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/arg-cache">Arg Cache</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/invocations">Invocations</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/invocations/timeline">
                <i class="fas fa-chart-line me-1"></i>
                Timeline
              </a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/tasks">Tasks</a>
            </li>
          </ul>

          <!-- App Info -->
          <span class="navbar-text"> App: {{ app_id }} </span>
        </div>
      </div>
    </nav>

    <div class="container mt-4">
      <h1>{{ title }}</h1>

      {% block content %}
      <div class="row">
        <div class="col-md-6">
          <div class="card">
            <div class="card-header">Welcome to Pynenc Monitor</div>
            <div class="card-body">
              <p>
                Select a section from the navigation menu to start monitoring
                your Pynenc application.
              </p>
              <p>Currently monitoring app: <strong>{{ app_id }}</strong></p>
              <div class="mt-3">
                <button
                  class="btn btn-danger"
                  hx-post="/purge"
                  hx-confirm="⚠️ WARNING: This will purge ALL data from the broker, orchestrator, state backend, and argument cache. This operation cannot be undone! Continue?"
                  hx-swap="outerHTML"
                >
                  Purge All Application Data
                </button>
              </div>
            </div>
          </div>
        </div>
      </div>
      {% endblock %}
    </div>

    <!-- Bootstrap JS Bundle -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  </body>
</html>
