{% extends "base.html" %}

{% block content %}
<div class="content-card">
    <h1>
        {% if mode == "edit" %}
            Branche bearbeiten
        {% else %}
            Neue Branche erstellen
        {% endif %}
    </h1>

    <form method="post" class="admin-form">
        <div class="form-group">
            <label for="branchenname">Branchenname</label>
            <input type="text" id="branchenname" name="branchenname" value="{{ branche.branchenname or '' }}" required>
        </div>

        <div class="form-group">
            <label>Zugeordnete Themen</label>
            <div class="checkbox-list">
                {% for thema in themen %}
                    <label class="checkbox-item">
                        <input
                            type="checkbox"
                            name="thema_ids"
                            value="{{ thema.id }}"
                            {% if thema.id in selected_thema_ids %}checked{% endif %}
                        >
                        <span>{{ thema.kurztitel }} - {{ thema.titel }}</span>
                    </label>
                {% endfor %}
            </div>
        </div>

        <div class="form-actions">
            <button type="submit" class="btn">Speichern</button>
            <a class="btn btn-secondary" href="{{ url_for('admin_branchen') }}">Abbrechen</a>
        </div>
    </form>
</div>
{% endblock %}