{% extends "base.html" %}
{% import "macros.j2" as macros %}
{% block content %}
<div class="row mt-4 mb-3">
    <div class="col d-flex justify-content-between align-items-center">
        <h2>{% if current_page == "home" %}Kommende{% else %}Vergangene{% endif %} Kochabende</h2>
        {% if user %}
        <a href="/event/add" class="btn btn-primary">
            <i class="bi bi-plus-circle"></i> Neues Event erstellen
        </a>
        {% else %}
        <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#loginInfo">
            <i class="bi bi-plus-circle"></i> Neues Event erstellen
        </button>
        {% endif %}
    </div>
</div>
<div class="mb-4">
  <div class="card bg-success-subtle text-success-emphasis border-0 shadow-sm text-center">
    <div class="card-body py-4">
      <i class="bi bi-calendar-heart fs-3 mb-2"></i>
      <h5 class="card-title mb-2">Nie wieder die Anmeldung vergessen</h5>
      <p class="card-text small mb-3">
        Die Dauerhafte Anmeldung gilt für alle kommenden Kochabende.
      </p>
      <a href="/subscribe" class="btn btn-light btn-sm fw-semibold px-3">
        Jetzt dauerhaft Anmelden
      </a>
    </div>
  </div>
</div>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">


{% for event in events %}
  <div class="col">
    <div class="card h-100 shadow-sm">
      <div class="card-body">
          <div class="d-flex justify-content-between align-items-start mb-2">
            <div>
              <h5 class="card-title mb-0">
                {{ event.title }}
                {% if event.billed %}<i class="bi bi-cash-coin" title="Abgerechnet"></i>{% endif %}
                {% if event.exclude_from_billing %}<i class="bi bi-ban" title="Keine Abrechung"></i>{% endif %}
                {% if not event.all_teams_min() %}<span class="badge text-bg-warning">Hilfe benötigt</span>{% endif %}
              </h5>
            </div>
            {% if event.organizer_name %}<p class="text-muted small mb-0"><i class="bi bi-person"></i> {{ event.organizer_name }}</p>{% endif %}
          </div>
          <p class="text-muted mb-3"><i class="bi bi-calendar"></i> {{ event.event_time.strftime('%A, %d.%m.%Y') }}</p>
        <p class="card-text">{{ event.description }}</p>
        <a href="event/{{ event.id }}" class="btn btn-sm {% if event.registration_deadline > now %}btn-primary{% else %}btn-secondary{% endif %}">{% if event.registration_deadline > now %}Zur Anmeldung{% else %}Details ansehen{% endif %}</a>
      </div>
    </div>
  </div>
{% endfor %}
</div>

<!-- Modal -->
{{ macros.login_info_modal() }}
{% endblock %}
