{% extends "base.html" %}
{% block content %}
<div class="level">
    <div class="level-left"><h1 class="title is-3">{{ titel }}</h1></div>
    <div class="level-right">
        <a class="button is-small" href="{{ url_for('superadmin.dashboard') }}">← Zurück</a>
    </div>
</div>

<div class="box" style="max-width:800px;margin:0 auto">
    <form method="POST">
        <h2 class="title is-5 mb-3">Firmendaten</h2>
        <div class="columns is-multiline">
            <div class="column is-6">
                <div class="field">
                    <label class="label">Firmenname *</label>
                    <div class="control">
                        <input class="input" type="text" name="name" value="{{ company.name if company else '' }}" required>
                    </div>
                </div>
            </div>
            <div class="column is-6">
                <div class="field">
                    <label class="label">E-Mail (Firma)</label>
                    <div class="control">
                        <input class="input" type="email" name="email" value="{{ company.email if company else '' }}">
                    </div>
                </div>
            </div>
            <div class="column is-5">
                <div class="field">
                    <label class="label">Straße</label>
                    <div class="control">
                        <input class="input" type="text" name="strasse" value="{{ company.strasse if company else '' }}">
                    </div>
                </div>
            </div>
            <div class="column is-4">
                <div class="field">
                    <label class="label">Hausnummer</label>
                    <div class="control">
                        <input class="input" type="text" name="house_number" value="{{ company.house_number if company else '' }}">
                    </div>
                </div>
            </div>
            <div class="column is-3">
                <div class="field">
                    <label class="label">PLZ</label>
                    <div class="control">
                        <input class="input" type="text" name="plz" value="{{ company.plz if company else '' }}">
                    </div>
                </div>
            </div>
            <div class="column is-4">
                <div class="field">
                    <label class="label">Ort</label>
                    <div class="control">
                        <input class="input" type="text" name="ort" value="{{ company.ort if company else '' }}">
                    </div>
                </div>
            </div>
            <div class="column is-6">
                <div class="field">
                    <label class="label">Telefon</label>
                    <div class="control">
                        <input class="input" type="text" name="telefon" value="{{ company.telefon if company else '' }}">
                    </div>
                </div>
            </div>
        </div>

        {% if not company %}
        <hr class="my-5">
        <h2 class="title is-5 mb-3">Firmadmin-User direkt anlegen (optional)</h2>
        <div class="columns is-multiline">
            <div class="column is-4">
                <div class="field">
                    <label class="label">E-Mail *</label>
                    <div class="control">
                        <input class="input" type="email" name="admin_email" placeholder="admin@firma.de">
                    </div>
                </div>
            </div>
            <div class="column is-4">
                <div class="field">
                    <label class="label">Passwort *</label>
                    <div class="control">
                        <input class="input" type="password" name="admin_password" minlength="6" placeholder="mind. 6 Zeichen">
                    </div>
                </div>
            </div>
            <div class="column is-4">
                <div class="field">
                    <label class="label">&nbsp;</label>
                    <div class="control">
                        <label class="checkbox is-size-7"><input type="checkbox" id="chk-admin" onchange="document.getElementById('admin-fields').style.display=this.checked?'':'none'"> Admin-User anlegen</label>
                    </div>
                </div>
            </div>
            <div class="column is-12" id="admin-fields" style="display:none">
                <div class="columns is-multiline">
                    <div class="column is-4">
                        <div class="field">
                            <label class="label">Vorname</label>
                            <div class="control"><input class="input is-small" type="text" name="admin_vorname"></div>
                        </div>
                    </div>
                    <div class="column is-4">
                        <div class="field">
                            <label class="label">Nachname</label>
                            <div class="control"><input class="input is-small" type="text" name="admin_nachname"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% endif %}

        <div class="field mt-5">
            <button class="button is-primary" type="submit">{{ 'Speichern' if company else 'Firma anlegen' }}</button>
            <a class="button is-light ml-2" href="{{ url_for('superadmin.dashboard') }}">Abbrechen</a>
        </div>
    </form>
</div>
{% endblock %}