{% extends "base.html" %}
{% from "partials/macros.html" import task_card %}
{% block title %}Alle Aufgaben · Putzliga{% endblock %}
{% block page_title %}Alle Aufgaben{% endblock %}
{% block content %}
  <section class="panel">
    <form method="get" class="filter-bar">
      <div class="field field--compact">
        <label for="status">Status</label>
        <select name="status" id="status">
          <option value="all" {% if filters.status == 'all' %}selected{% endif %}>Alle</option>
          <option value="open" {% if filters.status == 'open' %}selected{% endif %}>Offen</option>
          <option value="soon" {% if filters.status == 'soon' %}selected{% endif %}>Bald fällig</option>
          <option value="today" {% if filters.status == 'today' %}selected{% endif %}>Heute fällig</option>
          <option value="tomorrow" {% if filters.status == 'tomorrow' %}selected{% endif %}>Morgen fällig</option>
          <option value="day_after_tomorrow" {% if filters.status == 'day_after_tomorrow' %}selected{% endif %}>Übermorgen fällig</option>
          <option value="overdue" {% if filters.status == 'overdue' %}selected{% endif %}>Überfällig</option>
          <option value="completed" {% if filters.status == 'completed' %}selected{% endif %}>Erledigt</option>
        </select>
      </div>
      <div class="field field--compact">
        <label for="user_id">Nutzer</label>
        <select name="user_id" id="user_id">
          <option value="">Alle</option>
          {% for user in users %}
            <option value="{{ user.id }}" {% if filters.user_id == user.id %}selected{% endif %}>{{ user.name }}</option>
          {% endfor %}
        </select>
      </div>
      <div class="field field--compact">
        <label for="sort">Sortierung</label>
        <select name="sort" id="sort">
          <option value="due" {% if filters.sort == 'due' %}selected{% endif %}>Fälligkeit</option>
          <option value="points" {% if filters.sort == 'points' %}selected{% endif %}>Punkte</option>
          <option value="user" {% if filters.sort == 'user' %}selected{% endif %}>Nutzer</option>
        </select>
      </div>
      <label class="checkbox checkbox--compact">
        <input type="checkbox" name="mine" value="1" {% if filters.mine == '1' %}checked{% endif %}>
        <span>Nur meine</span>
      </label>
      <button type="submit" class="button">Filter anwenden</button>
    </form>
  </section>

  <section class="task-grid">
    {% for task in tasks %}
      {{ task_card(task, current_user) }}
    {% else %}
      <div class="empty-state">Für diese Filter gibt es gerade keine Aufgaben.</div>
    {% endfor %}
  </section>
{% endblock %}
