{% 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 text-danger">
            <i class="fas fa-exclamation-triangle 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>

    <!-- Confirmation Form -->
    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="card shadow border-danger">
                <div class="card-header bg-danger text-white">
                    <h5 class="mb-0">
                        <i class="fas fa-trash me-2"></i>Termin löschen - Bestätigung erforderlich
                    </h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-danger" role="alert">
                        <i class="fas fa-exclamation-triangle me-2"></i>
                        <strong>Achtung!</strong> Diese Aktion kann nicht rückgängig gemacht werden.
                    </div>

                    <p class="mb-4">
                        Sind Sie sicher, dass Sie den folgenden Kalendereintrag permanent löschen möchten?
                    </p>

                    <!-- Event Details Summary -->
                    <div class="bg-light p-4 rounded mb-4">
                        <h6 class="text-muted mb-3">Zu löschender Termin:</h6>
                        
                        <div class="row mb-2">
                            <div class="col-sm-3"><strong>Titel:</strong></div>
                            <div class="col-sm-9">{{ event.titel }}</div>
                        </div>
                        
                        <div class="row mb-2">
                            <div class="col-sm-3"><strong>Datum:</strong></div>
                            <div class="col-sm-9">
                                {{ event.datum|date:"d.m.Y" }}
                                {% if event.uhrzeit %}um {{ event.uhrzeit|time:"H:i" }} Uhr{% endif %}
                            </div>
                        </div>
                        
                        <div class="row mb-2">
                            <div class="col-sm-3"><strong>Kategorie:</strong></div>
                            <div class="col-sm-9">
                                <span class="badge bg-info">{{ event.get_kategorie_display }}</span>
                            </div>
                        </div>
                        
                        {% if event.beschreibung %}
                        <div class="row mb-2">
                            <div class="col-sm-3"><strong>Beschreibung:</strong></div>
                            <div class="col-sm-9">{{ event.beschreibung|truncatechars:100 }}</div>
                        </div>
                        {% endif %}
                        
                        <div class="row">
                            <div class="col-sm-3"><strong>Erstellt:</strong></div>
                            <div class="col-sm-9">
                                {{ event.erstellt_am|date:"d.m.Y H:i" }} 
                                {% if event.erstellt_von %}von {{ event.erstellt_von }}{% endif %}
                            </div>
                        </div>
                    </div>

                    <form method="post" class="d-flex justify-content-between align-items-center">
                        {% csrf_token %}
                        
                        <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-danger">
                            <i class="fas fa-trash me-1"></i>Ja, endgültig löschen
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
// Add confirmation dialog as extra safety measure
document.addEventListener('DOMContentLoaded', function() {
    const deleteForm = document.querySelector('form');
    if (deleteForm) {
        deleteForm.addEventListener('submit', function(e) {
            if (!confirm('Sind Sie wirklich sicher? Diese Aktion kann nicht rückgängig gemacht werden!')) {
                e.preventDefault();
            }
        });
    }
});
</script>
{% endblock %}