{% extends "base.html" %}

{% block content %}
<div class="content-card">
    <div class="page-header">
        <div>
            <h1>
                {% if mode == "edit" %}
                    Frage bearbeiten
                {% else %}
                    Neue Frage für Thema
                {% endif %}
            </h1>
            <p class="muted">{{ thema.kurztitel }} - {{ thema.titel }}</p>
        </div>
        <a class="btn btn-secondary" href="{{ url_for('admin_themen') }}">Zur Themenübersicht</a>
    </div>

    <div class="card" style="margin-bottom: 24px;">
        <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:8px;">
            <strong>Fortschritt Fragen</strong>
            <span>{{ question_count }}/{{ min_questions }}</span>
        </div>

        {% set progress = (question_count * 100 / min_questions) %}
        {% if progress > 100 %}
            {% set progress = 100 %}
        {% endif %}

        <div class="progress-bar-wrap">
            <div class="progress-bar-fill" style="width: {{ progress }}%;"></div>
        </div>

        {% if question_count < min_questions %}
            <p class="muted" style="margin-top: 10px;">
                Für dieses Thema sollten mindestens {{ min_questions }} Fragen gepflegt werden.
            </p>
        {% else %}
            <p class="muted" style="margin-top: 10px;">
                Mindestanzahl erreicht.
            </p>
        {% endif %}
    </div>

    <form method="post" class="admin-form">
        <div class="form-group">
            <label for="text">Frage</label>
            <textarea id="text" name="text" rows="5" required>{{ frage.text or '' }}</textarea>
        </div>

        <div class="form-actions">
            <button type="submit" class="btn">Speichern</button>
            <a class="btn btn-secondary" href="{{ url_for('admin_question_new_for_thema', thema_id=thema.id) }}">Neu laden</a>
        </div>
    </form>
</div>
{% endblock %}