{% extends 'base.html' %}
{% block content %}
<section class="card">
  <h1>{{ t('host_access_title') }}</h1>
  <p>{{ t('host_access_note') }}</p>
</section>

{% if not unlocked %}
<section class="card form-card">
  <form method="post" action="{{ url_for('host_area') }}" class="form-grid">
    <label>
      {{ t('host_password') }}
      <input type="password" name="host_password" required />
    </label>
    <button class="btn" type="submit">{{ t('host_access_submit') }}</button>
  </form>
</section>
{% else %}
<section class="stats-grid">
  <article class="card stat-card">
    <h2>{{ t('total_guests') }}</h2>
    <p>{{ stats.total_guests }}</p>
  </article>
  <article class="card stat-card">
    <h2>{{ t('attending_yes') }}</h2>
    <p>{{ stats.attending_yes }}</p>
  </article>
  <article class="card stat-card">
    <h2>{{ t('attending_no') }}</h2>
    <p>{{ stats.attending_no }}</p>
  </article>
  <article class="card stat-card">
    <h2>{{ t('attending_open') }}</h2>
    <p>{{ stats.attending_open }}</p>
  </article>
  <article class="card stat-card">
    <h2>{{ t('plus_one_total') }}</h2>
    <p>{{ stats.plus_one_total }}</p>
  </article>
</section>

<section class="card">
  <h2>{{ t('host_stats_title') }}</h2>
  <div class="table-wrap">
    <table class="guest-table">
      <thead>
        <tr>
          <th>{{ t('host_table_name') }}</th>
          <th>{{ t('host_table_status') }}</th>
          <th>{{ t('host_table_plus_one') }}</th>
        </tr>
      </thead>
      <tbody>
        {% for guest in guests %}
        <tr>
          <td>{{ guest["name"] }}</td>
          <td>
            {% if guest["attending"] == 1 %}
              {{ t('status_yes') }}
            {% elif guest["attending"] == 0 %}
              {{ t('status_no') }}
            {% else %}
              {{ t('status_open') }}
            {% endif %}
          </td>
          <td>
            {% if guest["attending"] == 1 and guest["plus_one"] == 1 %}
              {{ t('yes') }}
            {% else %}
              {{ t('no') }}
            {% endif %}
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
</section>
{% endif %}
{% endblock %}
