{% extends "base.html" %}
{% from "partials/macros.html" import badge_card, nav_icon %}
{% block title %}Badge-Regeln · Putzliga{% endblock %}
{% block page_title %}Badge-Regeln{% endblock %}
{% block content %}
  <section class="settings-tabs">
    {% for endpoint, label, icon in settings_tabs %}
      <a href="{{ url_for(endpoint) }}" class="settings-tab {% if active_settings_tab == endpoint %}is-active{% endif %}">
        {{ nav_icon(icon) }}
        <span>{{ label }}</span>
      </a>
    {% endfor %}
  </section>

  <section class="panel">
    <p class="eyebrow">Admin-Bereich</p>
    <h2>Badges konfigurieren</h2>
    <p class="muted">Die Icons stammen aus `heinz.marketing` und wurden für Putzliga lokal übernommen. Schwelle, Bonus und Aktiv-Status kannst du hier steuern.</p>
    <div class="badge-settings">
      {% for badge in badges %}
        <form method="post" action="{{ url_for('settings.update_badge', badge_id=badge.id) }}" class="badge-setting-card">
          <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
          {{ badge_card(badge) }}
          <div class="field field--compact">
            <label>Schwelle</label>
            <input type="number" name="threshold" min="1" value="{{ badge.threshold }}">
          </div>
          <div class="field field--compact">
            <label>Bonus</label>
            <input type="number" name="bonus_points" min="0" value="{{ badge.bonus_points }}">
          </div>
          <label class="checkbox checkbox--compact">
            <input type="checkbox" name="active" {% if badge.active %}checked{% endif %}>
            <span>Aktiv</span>
          </label>
          <button type="submit" class="button button--secondary">Badge speichern</button>
        </form>
      {% endfor %}
    </div>
  </section>
{% endblock %}
