{% extends "admin_base.html" %}
{% block title %}Dashboard | Nexora Admin{% endblock %}
{% block content %}
<div class="admin-head">
  <p class="eyebrow">Overview</p>
  <h1>Dashboard</h1>
  <p>A complete overview of registrations, payments, game cards, media, and user messages.</p>
</div>

<div class="stat-grid">
  <div class="stat-card">
    <span class="stat-icon"><i class="fas fa-clipboard-list"></i></span>
    <span class="stat-text"><strong>{{ stats.registrations }}</strong><span>Total Registrations</span></span>
  </div>
  <div class="stat-card paid">
    <span class="stat-icon"><i class="fas fa-circle-check"></i></span>
    <span class="stat-text"><strong>{{ stats.paid }}</strong><span>Paid</span></span>
  </div>
  <div class="stat-card unpaid">
    <span class="stat-icon"><i class="fas fa-circle-xmark"></i></span>
    <span class="stat-text"><strong>{{ stats.unpaid }}</strong><span>Unpaid</span></span>
  </div>
  <div class="stat-card cyan">
    <span class="stat-icon"><i class="fas fa-gamepad"></i></span>
    <span class="stat-text"><strong>{{ stats.games }}</strong><span>Game Cards</span></span>
  </div>
  <div class="stat-card amber">
    <span class="stat-icon"><i class="fas fa-envelope"></i></span>
    <span class="stat-text"><strong>{{ stats.contacts }}</strong><span>Messages</span></span>
  </div>
  <div class="stat-card">
    <span class="stat-icon"><i class="fas fa-handshake"></i></span>
    <span class="stat-text"><strong>{{ stats.sponsors }}</strong><span>Sponsors</span></span>
  </div>
  <div class="stat-card cyan">
    <span class="stat-icon"><i class="fas fa-images"></i></span>
    <span class="stat-text"><strong>{{ stats.media }}</strong><span>Media Files</span></span>
  </div>
</div>

<section class="admin-panel">
  <h2><i class="fas fa-chart-pie"></i> Game Wise Entries</h2>
  {% if by_game %}
  <div class="bar-list">
    {% for row in by_game %}
    <div class="bar-row"><span>{{ row.title }}</span><strong>{{ row.total }}</strong></div>
    {% endfor %}
  </div>
  {% else %}
  <div class="empty"><i class="fas fa-gamepad"></i>No games have been added yet.</div>
  {% endif %}
</section>

<section class="admin-panel">
  <h2><i class="fas fa-clock-rotate-left"></i> Recent Registrations</h2>
  {% if recent %}
  <div class="table-wrap">
    <table>
      <thead>
        <tr>
          <th>Name</th>
          <th>Game</th>
          <th>Entry</th>
          <th>Phone</th>
          <th>Status</th>
        </tr>
      </thead>
      <tbody>
        {% for row in recent %}
        <tr>
          <td>{{ row.full_name }}</td>
          <td>{{ row.game_title }}</td>
          <td><span class="badge neutral">{{ row.entry_type }}</span></td>
          <td class="nowrap">{{ row.phone }}</td>
          <td><span class="badge {{ row.payment_status }}">{{ row.payment_status }}</span></td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
  <div style="margin-top:16px;">
    <a class="btn outline small" href="{{ url_for('admin_registrations') }}">View All Registrations <i
        class="fas fa-arrow-right"></i></a>
  </div>
  {% else %}
  <div class="empty"><i class="fas fa-inbox"></i>No registrations have arrived yet.</div>
  {% endif %}
</section>
{% endblock %}
