{% extends "base.html" %}

{% block content %}
<!-- Admin Header -->
<section class="mb-2">
  <h1>Admin Dashboard</h1>
  <p class="text-muted">
    Welcome back, <strong>{{ user.email }}</strong>
    <span class="badge badge-admin">{{ user.role }}</span>
  </p>
</section>

<!-- Admin Actions Grid -->
<section class="grid-2" style="margin: 3rem 0;">
  <!-- Content Management -->
  <article class="card">
    <header>
      <h3>📝 Content Management</h3>
    </header>
    <p>
      Manage blog posts, pages, and other content.
      Create, edit, and publish multilingual content.
    </p>
    <footer>
      <a href="/admin/posts" role="button">
        Manage Posts →
      </a>
    </footer>
  </article>

  <!-- RAG System -->
  <article class="card">
    <header>
      <h3>🤖 RAG System</h3>
    </header>
    <p>
      Index content, search semantically, and manage AI providers.
      OpenAI, Claude, and OpenRouter support.
    </p>
    <footer>
      <a href="/admin/rag" role="button" class="secondary">
        RAG Dashboard →
      </a>
    </footer>
  </article>

  <!-- API Management -->
  <article class="card">
    <header>
      <h3>⚙️ API & Settings</h3>
    </header>
    <p>
      View API documentation, check system health, and configure settings.
    </p>
    <footer>
      <div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
        <a href="/docs" role="button" class="outline" target="_blank">API Docs</a>
        <a href="/__routes" role="button" class="outline" target="_blank">Routes</a>
      </div>
    </footer>
  </article>

  <!-- Logs & Stats -->
  <article class="card">
    <header>
      <h3>📈 Logs & Stats</h3>
    </header>
    <p>
      Monitor chat comparisons, token usage, and role interactions.
    </p>
    <footer>
      <div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
        <a href="/admin/logs" role="button" class="secondary">View Logs</a>
        <a href="/admin/vectors" role="button" class="outline">Search Brain 🧠</a>
      </div>
    </footer>
  </article>

  <!-- System Status -->
  <article class="card">
    <header>
      <h3>📊 System Status</h3>
    </header>
    <p>
      Monitor system health, view logs, and check database status.
    </p>
    <footer>
      <div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
        <a href="/health" role="button" class="outline" target="_blank">Health</a>
        <a href="http://localhost:6333/dashboard" role="button" class="outline" target="_blank">Qdrant</a>
      </div>
    </footer>
  </article>
</section>

<!-- Quick Links -->
<section style="margin: 3rem 0;">
  <details>
    <summary><strong>Developer Tools</strong></summary>
    <div style="padding: 1rem;">
      <h4>Debug Endpoints</h4>
      <ul>
        <li><a href="/__routes" target="_blank">All Routes</a> - View all available API routes</li>
        <li><a href="/__whoami" target="_blank">Whoami</a> - Current user and session info</li>
        <li><a href="/health" target="_blank">Health Check</a> - System health status</li>
        <li><a href="/admin/rag/providers" target="_blank">Provider Status</a> - AI provider availability</li>
        <li><a href="/admin/rag/status" target="_blank">RAG Status</a> - Indexing status</li>
      </ul>

      <h4>External Services</h4>
      <ul>
        <li><a href="http://localhost:6333/dashboard" target="_blank">Qdrant Dashboard</a> - Vector database UI</li>
        <li><a href="/docs" target="_blank">Swagger UI</a> - Interactive API documentation</li>
      </ul>

      <h4>Shell Commands</h4>
      <pre><code>./logs.sh app     # View FastAPI logs
./test.sh         # Run tests
./stop.sh         # Stop system</code></pre>
    </div>
  </details>
</section>

<!-- System Info Table -->
<section style="margin: 3rem 0;">
  <article>
    <header>
      <h3>Session Information</h3>
    </header>
    <table>
      <tbody>
        <tr>
          <th scope="row">User ID</th>
          <td>{{ user.id }}</td>
        </tr>
        <tr>
          <th scope="row">Email</th>
          <td>{{ user.email }}</td>
        </tr>
        <tr>
          <th scope="row">Role</th>
          <td><span class="badge badge-admin">{{ user.role }}</span></td>
        </tr>
        <tr>
          <th scope="row">Locale</th>
          <td>{{ user.locale }}</td>
        </tr>
        <tr>
          <th scope="row">Current Language</th>
          <td>{{ lang }} ({{ 'Deutsch' if lang == 'de' else 'English' }})</td>
        </tr>
      </tbody>
    </table>
  </article>
</section>

{% endblock %}