{% extends 'admin/base.html.twig' %}

{% block title %}Modifier {{ user.companyName }}{% endblock %}

{% block body %}
<div class="mb-8">
    <h1 class="text-3xl font-black uppercase tracking-tighter italic heading-page">Modifier l'organisateur</h1>
    <p class="font-bold text-gray-500 italic">{{ user.companyName }} — {{ user.email }}</p>
</div>

<form method="post" action="{{ path('app_admin_edit_organizer', {id: user.id}) }}" enctype="multipart/form-data">
    <div class="flex flex-wrap gap-6 mb-8">
        <div class="flex-1 min-w-[300px]">
            <div class="admin-card">
                <h2 class="text-sm font-black uppercase tracking-widest mb-4">Informations personnelles</h2>
                <div class="flex flex-col gap-4">
                    <div class="flex gap-4">
                        <div class="flex-1">
                            <label for="edit_last_name" class="admin-form-label font-black uppercase text-gray-400">Nom</label>
                            <input type="text" id="edit_last_name" name="last_name" value="{{ user.lastName }}" required
                                class="admin-form-input-lg">
                        </div>
                        <div class="flex-1">
                            <label for="edit_first_name" class="admin-form-label font-black uppercase text-gray-400">Prenom</label>
                            <input type="text" id="edit_first_name" name="first_name" value="{{ user.firstName }}" required
                                class="admin-form-input-lg">
                        </div>
                    </div>
                    <div>
                        <label for="edit_email" class="admin-form-label font-black uppercase text-gray-400">Email</label>
                        <input type="email" id="edit_email" name="email" value="{{ user.email }}" required
                            class="admin-form-input-lg">
                    </div>
                    <div>
                        <label for="edit_phone" class="admin-form-label font-black uppercase text-gray-400">Telephone</label>
                        <input type="tel" id="edit_phone" name="phone" value="{{ user.phone }}"
                            class="admin-form-input-lg">
                    </div>
                </div>
            </div>
        </div>

        <div class="flex-1 min-w-[300px]">
            <div class="admin-card">
                <h2 class="text-sm font-black uppercase tracking-widest mb-4">Informations entreprise</h2>
                <div class="flex flex-col gap-4">
                    <div>
                        <label for="edit_company" class="admin-form-label font-black uppercase text-gray-400">Raison sociale</label>
                        <input type="text" id="edit_company" name="company_name" value="{{ user.companyName }}" required
                            class="admin-form-input-lg">
                    </div>
                    <div>
                        <label for="edit_siret" class="admin-form-label font-black uppercase text-gray-400">SIRET</label>
                        <input type="text" id="edit_siret" name="siret" value="{{ user.siret }}" maxlength="14" pattern="[0-9]{14}"
                            class="admin-form-input-lg">
                    </div>
                    <div>
                        <label for="edit_address" class="admin-form-label font-black uppercase text-gray-400">Adresse</label>
                        <input type="text" id="edit_address" name="address" value="{{ user.address }}"
                            class="admin-form-input-lg">
                    </div>
                    <div class="flex gap-4">
                        <div class="flex-1">
                            <label for="edit_postal" class="admin-form-label font-black uppercase text-gray-400">Code postal</label>
                            <input type="text" id="edit_postal" name="postal_code" value="{{ user.postalCode }}" maxlength="5" pattern="[0-9]{5}"
                                class="admin-form-input-lg">
                        </div>
                        <div class="flex-2">
                            <label for="edit_city" class="admin-form-label font-black uppercase text-gray-400">Ville</label>
                            <input type="text" id="edit_city" name="city" value="{{ user.city }}"
                                class="admin-form-input-lg">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="flex flex-wrap gap-6 mb-8">
        <div class="flex-1 min-w-[300px]">
            <div class="admin-card-yellow">
                <h2 class="text-sm font-black uppercase tracking-widest mb-4">Offre et commission</h2>
                <div class="flex gap-4">
                    <div class="flex-1">
                        <label for="edit_offer" class="admin-form-label font-black uppercase">Offre</label>
                        <select id="edit_offer" name="offer" class="admin-form-select">
                            <option value="free" {{ user.offer == 'free' ? 'selected' : '' }}>Gratuit</option>
                            <option value="basic" {{ user.offer == 'basic' ? 'selected' : '' }}>Basique</option>
                            <option value="custom" {{ user.offer == 'custom' ? 'selected' : '' }}>Sur-mesure</option>
                        </select>
                    </div>
                    <div class="flex-1">
                        <label for="edit_commission" class="admin-form-label font-black uppercase">Taux de commission (%)</label>
                        <input type="number" id="edit_commission" name="commission_rate" value="{{ user.commissionRate ?? 3 }}" step="0.1" min="0" max="100"
                            class="admin-form-input-lg bg-white">
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="flex flex-wrap gap-6 mb-8">
        <div class="flex-1 min-w-[300px]">
            <div class="admin-card">
                <h2 class="text-sm font-black uppercase tracking-widest mb-4">Logo</h2>
                <div class="flex items-center gap-6">
                    {% if user.logoName %}
                        <div class="shrink-0">
                            <img src="{{ vich_uploader_asset(user, 'logoFile') }}" alt="Logo {{ user.companyName }}" class="w-24 h-24 object-contain border-2 border-gray-900">
                        </div>
                    {% else %}
                        <div class="w-24 h-24 border-2 border-dashed border-gray-300 flex items-center justify-center shrink-0">
                            <span class="text-xs text-gray-400 font-bold uppercase">Aucun logo</span>
                        </div>
                    {% endif %}
                    <div class="flex-1">
                        <label for="edit_logo" class="admin-form-label font-black uppercase text-gray-400">Changer le logo</label>
                        <input type="file" id="edit_logo" name="logo" accept="image/*" class="admin-form-input-lg">
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="flex gap-3">
        <button type="submit"
            class="admin-btn-lg font-black uppercase text-sm tracking-widest hover:bg-green-500 hover:text-black transition-all">
            Enregistrer
        </button>
        <a href="{{ path('app_admin_organizers', {tab: 'approved'}) }}"
            class="admin-btn-lg-outline inline-flex items-center font-black uppercase text-sm tracking-widest bg-white hover:bg-gray-100 transition-all">
            Annuler
        </a>
    </div>
</form>
{% endblock %}
