{% extends 'base.html' %}

{% block title %}{{ title }} - van Hees-Theyssen-Vogel'sche Stiftung{% endblock %}

{% block content %}

    <div class="row">
        <div class="col-12">
            <div class="d-sm-flex align-items-center justify-content-between mb-4">
                <h1 class="h3 mb-0 text-gray-800">
                    <i class="fas fa-user-tie me-2"></i>{{ title }}
                </h1>
                <div class="btn-group" role="group">
                    <a href="{% url 'stiftung:rentmeister_list' %}" class="btn btn-outline-secondary">
                        <i class="fas fa-arrow-left me-1"></i>Zurück zur Liste
                    </a>
                    {% if rentmeister %}
                    <a href="{% url 'stiftung:rentmeister_detail' rentmeister.pk %}" class="btn btn-outline-info">
                        <i class="fas fa-eye me-1"></i>Details ansehen
                    </a>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>

    <form method="post" novalidate>
        {% csrf_token %}
        
        <div class="row">
            <!-- Persönliche Daten -->
            <div class="col-xl-6 col-lg-6">
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">
                            <i class="fas fa-user me-2"></i>Persönliche Daten
                        </h6>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-4 mb-3">
                                <label for="{{ form.anrede.id_for_label }}" class="form-label">{{ form.anrede.label }}</label>
                                {{ form.anrede }}
                                {% if form.anrede.errors %}
                                    <div class="text-danger small">{{ form.anrede.errors.0 }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-4 mb-3">
                                <label for="{{ form.vorname.id_for_label }}" class="form-label">{{ form.vorname.label }}</label>
                                {{ form.vorname }}
                                {% if form.vorname.errors %}
                                    <div class="text-danger small">{{ form.vorname.errors.0 }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-4 mb-3">
                                <label for="{{ form.nachname.id_for_label }}" class="form-label">{{ form.nachname.label }}</label>
                                {{ form.nachname }}
                                {% if form.nachname.errors %}
                                    <div class="text-danger small">{{ form.nachname.errors.0 }}</div>
                                {% endif %}
                            </div>
                        </div>
                        
                        <div class="mb-3">
                            <label for="{{ form.titel.id_for_label }}" class="form-label">{{ form.titel.label }}</label>
                            {{ form.titel }}
                            {% if form.titel.errors %}
                                <div class="text-danger small">{{ form.titel.errors.0 }}</div>
                            {% endif %}
                        </div>
                    </div>
                </div>

                <!-- Kontaktdaten -->
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">
                            <i class="fas fa-address-book me-2"></i>Kontaktdaten
                        </h6>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label for="{{ form.email.id_for_label }}" class="form-label">{{ form.email.label }}</label>
                            {{ form.email }}
                            {% if form.email.errors %}
                                <div class="text-danger small">{{ form.email.errors.0 }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label for="{{ form.telefon.id_for_label }}" class="form-label">{{ form.telefon.label }}</label>
                                {{ form.telefon }}
                                {% if form.telefon.errors %}
                                    <div class="text-danger small">{{ form.telefon.errors.0 }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-6 mb-3">
                                <label for="{{ form.mobil.id_for_label }}" class="form-label">{{ form.mobil.label }}</label>
                                {{ form.mobil }}
                                {% if form.mobil.errors %}
                                    <div class="text-danger small">{{ form.mobil.errors.0 }}</div>
                                {% endif %}
                            </div>
                        </div>
                        
                        <div class="mb-3">
                            <label for="{{ form.strasse.id_for_label }}" class="form-label">{{ form.strasse.label }}</label>
                            {{ form.strasse }}
                            {% if form.strasse.errors %}
                                <div class="text-danger small">{{ form.strasse.errors.0 }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="row">
                            <div class="col-md-4 mb-3">
                                <label for="{{ form.plz.id_for_label }}" class="form-label">{{ form.plz.label }}</label>
                                {{ form.plz }}
                                {% if form.plz.errors %}
                                    <div class="text-danger small">{{ form.plz.errors.0 }}</div>
                                {% endif %}
                                {% if form.plz.help_text %}
                                    <div class="form-text">{{ form.plz.help_text }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-8 mb-3">
                                <label for="{{ form.ort.id_for_label }}" class="form-label">{{ form.ort.label }}</label>
                                {{ form.ort }}
                                {% if form.ort.errors %}
                                    <div class="text-danger small">{{ form.ort.errors.0 }}</div>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Stiftungsdaten und Vergütung -->
            <div class="col-xl-6 col-lg-6">
                <!-- Stiftungsdaten -->
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">
                            <i class="fas fa-calendar-alt me-2"></i>Stiftungsdaten
                        </h6>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label for="{{ form.seit_datum.id_for_label }}" class="form-label">{{ form.seit_datum.label }}</label>
                                {{ form.seit_datum }}
                                {% if form.seit_datum.errors %}
                                    <div class="text-danger small">{{ form.seit_datum.errors.0 }}</div>
                                {% endif %}
                                {% if form.seit_datum.help_text %}
                                    <div class="form-text">{{ form.seit_datum.help_text }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-6 mb-3">
                                <label for="{{ form.bis_datum.id_for_label }}" class="form-label">{{ form.bis_datum.label }}</label>
                                {{ form.bis_datum }}
                                {% if form.bis_datum.errors %}
                                    <div class="text-danger small">{{ form.bis_datum.errors.0 }}</div>
                                {% endif %}
                                {% if form.bis_datum.help_text %}
                                    <div class="form-text">{{ form.bis_datum.help_text }}</div>
                                {% endif %}
                            </div>
                        </div>
                        
                        <div class="form-check mb-3">
                            {{ form.aktiv }}
                            <label class="form-check-label" for="{{ form.aktiv.id_for_label }}">
                                {{ form.aktiv.label }}
                            </label>
                            {% if form.aktiv.errors %}
                                <div class="text-danger small">{{ form.aktiv.errors.0 }}</div>
                            {% endif %}
                        </div>
                    </div>
                </div>

                <!-- Vergütung -->
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">
                            <i class="fas fa-euro-sign me-2"></i>Vergütung
                        </h6>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label for="{{ form.monatliche_verguetung.id_for_label }}" class="form-label">{{ form.monatliche_verguetung.label }}</label>
                                <div class="input-group">
                                    {{ form.monatliche_verguetung }}
                                    <span class="input-group-text">€</span>
                                </div>
                                {% if form.monatliche_verguetung.errors %}
                                    <div class="text-danger small">{{ form.monatliche_verguetung.errors.0 }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-6 mb-3">
                                <label for="{{ form.km_pauschale.id_for_label }}" class="form-label">{{ form.km_pauschale.label }}</label>
                                <div class="input-group">
                                    {{ form.km_pauschale }}
                                    <span class="input-group-text">€/km</span>
                                </div>
                                {% if form.km_pauschale.errors %}
                                    <div class="text-danger small">{{ form.km_pauschale.errors.0 }}</div>
                                {% endif %}
                                {% if form.km_pauschale.help_text %}
                                    <div class="form-text">{{ form.km_pauschale.help_text }}</div>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Bankdaten -->
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">
                            <i class="fas fa-university me-2"></i>Bankdaten
                        </h6>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label for="{{ form.iban.id_for_label }}" class="form-label">{{ form.iban.label }}</label>
                            {{ form.iban }}
                            {% if form.iban.errors %}
                                <div class="text-danger small">{{ form.iban.errors.0 }}</div>
                            {% endif %}
                            {% if form.iban.help_text %}
                                <div class="form-text">{{ form.iban.help_text }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="row">
                            <div class="col-md-4 mb-3">
                                <label for="{{ form.bic.id_for_label }}" class="form-label">{{ form.bic.label }}</label>
                                {{ form.bic }}
                                {% if form.bic.errors %}
                                    <div class="text-danger small">{{ form.bic.errors.0 }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-8 mb-3">
                                <label for="{{ form.bank_name.id_for_label }}" class="form-label">{{ form.bank_name.label }}</label>
                                {{ form.bank_name }}
                                {% if form.bank_name.errors %}
                                    <div class="text-danger small">{{ form.bank_name.errors.0 }}</div>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Notizen -->
        <div class="row">
            <div class="col-12">
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">
                            <i class="fas fa-sticky-note me-2"></i>Notizen
                        </h6>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label for="{{ form.notizen.id_for_label }}" class="form-label">{{ form.notizen.label }}</label>
                            {{ form.notizen }}
                            {% if form.notizen.errors %}
                                <div class="text-danger small">{{ form.notizen.errors.0 }}</div>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Form Errors -->
        {% if form.non_field_errors %}
        <div class="row">
            <div class="col-12">
                <div class="alert alert-danger">
                    <strong>Fehler:</strong>
                    {{ form.non_field_errors }}
                </div>
            </div>
        </div>
        {% endif %}

        <!-- Submit Buttons -->
        <div class="row">
            <div class="col-12">
                <div class="card shadow mb-4">
                    <div class="card-body text-end">
                        <a href="{% url 'stiftung:rentmeister_list' %}" class="btn btn-secondary me-2">
                            <i class="fas fa-times me-1"></i>Abbrechen
                        </a>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save me-1"></i>{{ submit_text }}
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </form>

{% endblock %}
