{% extends "base.html" %}

{% block title %}{{ title }}{% endblock %}

{% block content %}
<div class="container-fluid">
    <!-- Header -->
    <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-edit me-2"></i>{{ title }}
        </h1>
        <div class="d-flex gap-2">
            <a href="{% url 'stiftung:kalender_detail' event.pk %}" class="btn btn-secondary">
                <i class="fas fa-arrow-left me-1"></i>Zurück
            </a>
        </div>
    </div>

    <!-- Edit Form -->
    <div class="row">
        <div class="col-lg-8">
            <div class="card shadow">
                <div class="card-header bg-primary text-white">
                    <h5 class="mb-0">
                        <i class="fas fa-calendar-edit me-2"></i>Termin bearbeiten
                    </h5>
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        
                        <div class="row mb-3">
                            <div class="col-md-12">
                                <label for="titel" class="form-label">
                                    <i class="fas fa-heading me-1"></i>Titel *
                                </label>
                                <input type="text" class="form-control" id="titel" name="titel" 
                                       value="{{ event.titel }}" required>
                            </div>
                        </div>

                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label for="datum" class="form-label">
                                    <i class="fas fa-calendar me-1"></i>Datum *
                                </label>
                                <input type="date" class="form-control" id="datum" name="datum" 
                                       value="{{ event.datum|date:'Y-m-d' }}" required>
                            </div>
                            <div class="col-md-6">
                                <label for="zeit" class="form-label">
                                    <i class="fas fa-clock me-1"></i>Uhrzeit
                                </label>
                                <input type="time" class="form-control" id="zeit" name="zeit" 
                                       value="{% if event.uhrzeit %}{{ event.uhrzeit|time:'H:i' }}{% endif %}">
                            </div>
                        </div>

                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label for="kategorie" class="form-label">
                                    <i class="fas fa-tag me-1"></i>Kategorie
                                </label>
                                <select class="form-control" id="kategorie" name="kategorie">
                                    <option value="termin" {% if event.kategorie == 'termin' %}selected{% endif %}>Termin</option>
                                    <option value="zahlung" {% if event.kategorie == 'zahlung' %}selected{% endif %}>Zahlung</option>
                                    <option value="deadline" {% if event.kategorie == 'deadline' %}selected{% endif %}>Deadline</option>
                                    <option value="geburtstag" {% if event.kategorie == 'geburtstag' %}selected{% endif %}>Geburtstag</option>
                                    <option value="vertrag" {% if event.kategorie == 'vertrag' %}selected{% endif %}>Vertrag</option>
                                    <option value="pruefung" {% if event.kategorie == 'pruefung' %}selected{% endif %}>Prüfung</option>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label for="prioritaet" class="form-label">
                                    <i class="fas fa-exclamation-circle me-1"></i>Priorität
                                </label>
                                <select class="form-control" id="prioritaet" name="prioritaet">
                                    <option value="niedrig" {% if event.prioritaet == 'niedrig' %}selected{% endif %}>Niedrig</option>
                                    <option value="normal" {% if event.prioritaet == 'normal' %}selected{% endif %}>Normal</option>
                                    <option value="hoch" {% if event.prioritaet == 'hoch' %}selected{% endif %}>Hoch</option>
                                </select>
                            </div>
                        </div>

                        <div class="mb-3">
                            <label for="beschreibung" class="form-label">
                                <i class="fas fa-align-left me-1"></i>Beschreibung
                            </label>
                            <textarea class="form-control" id="beschreibung" name="beschreibung" 
                                      rows="4" placeholder="Optionale Beschreibung...">{{ event.beschreibung }}</textarea>
                        </div>

                        <div class="mb-3">
                            <label for="ort" class="form-label">
                                <i class="fas fa-map-marker-alt me-1"></i>Ort
                            </label>
                            <input type="text" class="form-control" id="ort" name="ort" 
                                   value="{{ event.ort }}" placeholder="Optional...">
                        </div>

                        <div class="mb-4">
                            <div class="form-check">
                                <input class="form-check-input" type="checkbox" id="erledigt" 
                                       name="erledigt" {% if event.erledigt %}checked{% endif %}>
                                <label class="form-check-label" for="erledigt">
                                    <i class="fas fa-check-circle me-1"></i>Als erledigt markieren
                                </label>
                            </div>
                        </div>

                        <div class="d-flex justify-content-between">
                            <a href="{% url 'stiftung:kalender_detail' event.pk %}" class="btn btn-secondary">
                                <i class="fas fa-times me-1"></i>Abbrechen
                            </a>
                            <button type="submit" class="btn btn-success">
                                <i class="fas fa-save me-1"></i>Änderungen speichern
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-lg-4">
            <!-- Help Card -->
            <div class="card shadow">
                <div class="card-header bg-info text-white">
                    <h6 class="mb-0">
                        <i class="fas fa-question-circle me-2"></i>Hilfe
                    </h6>
                </div>
                <div class="card-body">
                    <h6>Kategorien:</h6>
                    <ul class="small">
                        <li><strong>Termin:</strong> Allgemeine Termine und Meetings</li>
                        <li><strong>Zahlung:</strong> Zahlungserinnerungen</li>
                        <li><strong>Deadline:</strong> Wichtige Fristen</li>
                        <li><strong>Geburtstag:</strong> Geburtstage</li>
                        <li><strong>Vertrag:</strong> Vertragsereignisse</li>
                        <li><strong>Prüfung:</strong> Überprüfungen und Kontrollen</li>
                    </ul>

                    <h6 class="mt-3">Prioritäten:</h6>
                    <ul class="small">
                        <li><span class="badge bg-secondary me-1">Niedrig</span> Optionale Termine</li>
                        <li><span class="badge bg-warning me-1">Normal</span> Standard-Priorität</li>
                        <li><span class="badge bg-danger me-1">Hoch</span> Wichtige/dringende Termine</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}