{% extends 'base.html' %}
{% load static %}

{% block title %}Anmelden - Stiftungsverwaltung{% endblock %}

{% block content %}
    <div class="row justify-content-center">
        <div class="col-lg-5 col-md-7">
            <div class="card shadow-lg border-0">
                <div class="card-header bg-gradient-primary text-white text-center py-4">
                    <h4 class="mb-0">
                        <i class="fas fa-landmark me-2"></i>Stiftungsverwaltung
                    </h4>
                    <p class="mb-0 mt-2">Bitte melden Sie sich an</p>
                </div>
                <div class="card-body p-4">
                    {% if form.errors %}
                    <div class="alert alert-danger">
                        <h6 class="alert-heading">
                            <i class="fas fa-exclamation-triangle me-2"></i>Anmeldung fehlgeschlagen
                        </h6>
                        <p class="mb-0">Ihr Benutzername und/oder Passwort ist falsch. Bitte versuchen Sie es erneut.</p>
                    </div>
                    {% endif %}

                    {% if next %}
                        {% if user.is_authenticated %}
                        <div class="alert alert-warning">
                            <h6 class="alert-heading">
                                <i class="fas fa-exclamation-triangle me-2"></i>Zugriff verweigert
                            </h6>
                            <p class="mb-0">Ihr Account hat keinen Zugriff auf diese Seite. Um fortzufahren, melden Sie sich mit einem Account an, der Zugriff hat.</p>
                        </div>
                        {% else %}
                        <div class="alert alert-info">
                            <h6 class="alert-heading">
                                <i class="fas fa-info-circle me-2"></i>Anmeldung erforderlich
                            </h6>
                            <p class="mb-0">Bitte melden Sie sich an, um diese Seite zu sehen.</p>
                        </div>
                        {% endif %}
                    {% endif %}

                    <form method="post" action="{% url 'login' %}">
                        {% csrf_token %}
                        
                        <div class="mb-3">
                            <label for="{{ form.username.id_for_label }}" class="form-label">
                                <i class="fas fa-user me-2"></i>Benutzername
                            </label>
                            {{ form.username }}
                            {% if form.username.errors %}
                            <div class="invalid-feedback d-block">
                                {% for error in form.username.errors %}
                                {{ error }}
                                {% endfor %}
                            </div>
                            {% endif %}
                        </div>

                        <div class="mb-4">
                            <label for="{{ form.password.id_for_label }}" class="form-label">
                                <i class="fas fa-lock me-2"></i>Passwort
                            </label>
                            {{ form.password }}
                            {% if form.password.errors %}
                            <div class="invalid-feedback d-block">
                                {% for error in form.password.errors %}
                                {{ error }}
                                {% endfor %}
                            </div>
                            {% endif %}
                        </div>

                        <div class="d-grid">
                            <button type="submit" class="btn btn-primary btn-lg">
                                <i class="fas fa-sign-in-alt me-2"></i>Anmelden
                            </button>
                        </div>

                        <input type="hidden" name="next" value="{{ next }}">
                    </form>

                    <hr class="my-4">

                    <div class="text-center">
                        <p class="text-muted mb-2">Haben Sie Fragen oder Probleme?</p>
                        <a href="{% url 'stiftung:health_check' %}" class="btn btn-outline-info btn-sm">
                            <i class="fas fa-heartbeat me-2"></i>System-Status
                        </a>
                    </div>
                </div>
            </div>

            <div class="text-center mt-4">
                <small class="text-muted">
                    &copy; 2025 Stiftungsverwaltung. Alle Rechte vorbehalten.
                </small>
            </div>
        </div>
    </div>

<style>
    .card {
        border-radius: 15px;
    }
    
    .card-header {
        border-radius: 15px 15px 0 0 !important;
    }
    
    .form-control {
        border-radius: 10px;
        border: 2px solid #e9ecef;
        padding: 12px 15px;
        transition: all 0.3s ease;
    }
    
    .form-control:focus {
        border-color: #4e73df;
        box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
    }
    
    .btn-lg {
        padding: 12px 24px;
        border-radius: 10px;
        font-weight: 600;
    }
    
    .bg-gradient-primary {
        background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    }
</style>
{% endblock %} 