{% extends "base.html" %}

{% block title %}Neuer Kunde{% endblock %}

{% block content %}
<div class="container py-5">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2>👤 Neuer Kunde anlegen</h2>
        <a href="/customers-licenses" class="btn btn-secondary">← Zurück zur Übersicht</a>
    </div>

    <div class="card">
        <div class="card-body">
            <form method="post" action="/customer/create" accept-charset="UTF-8">
                <div class="row g-3">
                    <div class="col-md-6">
                        <label for="name" class="form-label">Kundenname <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" id="name" name="name" 
                               placeholder="Firmenname oder Vor- und Nachname" 
                               accept-charset="UTF-8" required autofocus>
                        <div class="form-text">Der Name des Kunden oder der Firma</div>
                    </div>
                    <div class="col-md-6">
                        <label for="email" class="form-label">E-Mail <span class="text-danger">*</span></label>
                        <input type="email" class="form-control" id="email" name="email" 
                               placeholder="kunde@beispiel.de"
                               accept-charset="UTF-8" required>
                        <div class="form-text">Kontakt-E-Mail-Adresse des Kunden</div>
                    </div>
                </div>

                <div class="form-check mt-3">
                    <input class="form-check-input" type="checkbox" id="isTest" name="is_test">
                    <label class="form-check-label" for="isTest">
                        <i class="fas fa-flask"></i> Als Testdaten markieren
                        <small class="text-muted">(Kunde wird von der Software ignoriert)</small>
                    </label>
                </div>

                <div class="alert alert-info mt-4" role="alert">
                    <i class="fas fa-info-circle"></i> 
                    <strong>Hinweis:</strong> Nach dem Anlegen des Kunden können Sie direkt Lizenzen für diesen Kunden erstellen.
                </div>

                <div class="mt-4">
                    <button type="submit" class="btn btn-primary">💾 Kunde anlegen</button>
                    <a href="/customers-licenses" class="btn btn-secondary">Abbrechen</a>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- Flash Messages -->
{% with messages = get_flashed_messages(with_categories=true) %}
    {% if messages %}
        <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
            {% for category, message in messages %}
                <div class="toast show align-items-center text-white bg-{{ 'danger' if category == 'error' else 'success' }} border-0" role="alert">
                    <div class="d-flex">
                        <div class="toast-body">
                            {{ message }}
                        </div>
                        <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
                    </div>
                </div>
            {% endfor %}
        </div>
    {% endif %}
{% endwith %}
{% endblock %}