{% extends "base.html" %}

{% block title %}{{ person.get_full_name }} - Stiftungsverwaltung{% endblock %}

{% block content %}

    <div class="row">
        <div class="col-12">
            <!-- Header -->
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h1 class="h3">
                    <i class="fas fa-user text-primary me-2"></i>{{ person.get_full_name }}
                </h1>
                <div class="btn-group" role="group">
                    <a href="{% url 'stiftung:person_update' person.id %}" class="btn btn-warning">
                        <i class="fas fa-edit me-2"></i>Bearbeiten
                    </a>
                    <a href="{% url 'stiftung:person_delete' person.id %}" class="btn btn-danger">
                        <i class="fas fa-trash me-1"></i>Löschen
                    </a>
                </div>
            </div>

            <!-- Person Information -->
            <div class="row">
                <div class="col-lg-8">
                    <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-info-circle me-2"></i>Persönliche Informationen
                            </h6>
                        </div>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-6">
                                    <h6 class="text-primary">Name</h6>
                                    <p class="mb-3">{{ person.vorname }} {{ person.nachname }}</p>
                                    
                                    <h6 class="text-primary">Geburtsdatum</h6>
                                    <p class="mb-3">{{ person.geburtsdatum|date:"d.m.Y" }}</p>
                                    
                                    <h6 class="text-primary">Familienzweig</h6>
                                    <p class="mb-3">
                                        <span class="badge bg-secondary">{{ person.get_familienzweig_display }}</span>
                                    </p>
                                </div>
                                <div class="col-md-6">
                                    <h6 class="text-primary">Adresse</h6>
                                    <p class="mb-3">
                                        {{ person.strasse }} {{ person.hausnummer }}<br>
                                        {{ person.plz }} {{ person.ort }}
                                    </p>
                                    
                                    <h6 class="text-primary">Kontakt</h6>
                                    <p class="mb-3">
                                        {% if person.telefon %}
                                        <i class="fas fa-phone me-2"></i>{{ person.telefon }}<br>
                                        {% endif %}
                                        {% if person.email %}
                                        <i class="fas fa-envelope me-2"></i>{{ person.email }}
                                        {% endif %}
                                    </p>
                                </div>
                            </div>
                            
                            {% if person.bemerkungen %}
                            <hr class="my-3">
                            <h6 class="text-primary">Bemerkungen</h6>
                            <p class="mb-0">{{ person.bemerkungen }}</p>
                            {% endif %}
                        </div>
                    </div>

                    <!-- Förderungen -->
                    <div class="card shadow mb-4">
                        <div class="card-header py-3 d-flex justify-content-between align-items-center">
                            <h6 class="m-0 font-weight-bold text-primary">
                                <i class="fas fa-gift me-2"></i>Förderungen
                            </h6>
                            <a href="{% url 'stiftung:foerderung_create' %}?person={{ person.id }}" class="btn btn-sm btn-success">
                                <i class="fas fa-plus me-2"></i>Neue Förderung
                            </a>
                        </div>
                        <div class="card-body">
                            {% if foerderungen %}
                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                        <tr>
                                            <th>Jahr</th>
                                            <th>Betrag</th>
                                            <th>Kategorie</th>
                                            <th>Status</th>
                                            <th>Aktionen</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {% for foerderung in foerderungen %}
                                        <tr>
                                            <td>{{ foerderung.jahr }}</td>
                                            <td>€{{ foerderung.betrag|floatformat:2 }}</td>
                                            <td>
                                                <span class="badge bg-secondary">{{ foerderung.get_kategorie_display }}</span>
                                            </td>
                                            <td>
                                                <span class="badge bg-{{ foerderung.get_status_color }}">{{ foerderung.get_status_display }}</span>
                                            </td>
                                            <td>
                                                <div class="btn-group" role="group">
                                                    <a href="{% url 'stiftung:foerderung_detail' foerderung.pk %}" class="btn btn-sm btn-outline-primary">
                                                        <i class="fas fa-eye"></i>
                                                    </a>
                                                    <a href="{% url 'stiftung:foerderung_update' foerderung.pk %}" class="btn btn-sm btn-outline-warning">
                                                        <i class="fas fa-edit"></i>
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                        {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                            {% else %}
                            <div class="text-center py-4">
                                <i class="fas fa-gift fa-3x text-muted mb-3"></i>
                                <h5 class="text-muted">Keine Förderungen vorhanden</h5>
                                <p class="text-muted">Erstellen Sie die erste Förderung für diese Person.</p>
                                <a href="{% url 'stiftung:foerderung_create' %}?person={{ person.id }}" class="btn btn-success">
                                    <i class="fas fa-plus me-2"></i>Förderung erstellen
                                </a>
                            </div>
                            {% endif %}
                        </div>
                    </div>
                </div>

                <!-- Sidebar -->
                <div class="col-lg-4">
                    <!-- Quick Stats -->
                    <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-chart-pie me-2"></i>Übersicht
                            </h6>
                        </div>
                        <div class="card-body">
                            <div class="row text-center">
                                <div class="col-6">
                                    <div class="border-end">
                                        <h4 class="text-primary">{{ foerderungen|length }}</h4>
                                        <small class="text-muted">Förderungen</small>
                                    </div>
                                </div>
                                <div class="col-6">
                                    <h4 class="text-success">€{{ total_foerderungen|floatformat:2 }}</h4>
                                    <small class="text-muted">Gesamtbetrag</small>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Actions -->
                    <div class="card shadow">
                        <div class="card-header py-3">
                            <h6 class="m-0 font-weight-bold text-primary">
                                <i class="fas fa-bolt me-2"></i>Schnellzugriff
                            </h6>
                        </div>
                        <div class="card-body">
                            <div class="d-grid gap-2">
                                <a href="{% url 'stiftung:person_update' person.id %}" class="btn btn-warning">
                                    <i class="fas fa-edit me-2"></i>Person bearbeiten
                                </a>
                                <a href="{% url 'stiftung:foerderung_create' %}?person={{ person.id }}" class="btn btn-success">
                                    <i class="fas fa-plus me-2"></i>Neue Förderung
                                </a>
                                <a href="{% url 'stiftung:person_list' %}" class="btn btn-outline-secondary">
                                    <i class="fas fa-arrow-left me-2"></i>Zurück zur Liste
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %} 
