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

{% block title %}Modifier {{ revendeur.codeRevendeur }} - Administration - Association E-Cosplay{% endblock %}

{% block admin_content %}
<div class="page-container">
    <div class="flex items-center justify-between mb-8">
        <h1 class="text-2xl font-bold heading-page">Modifier le revendeur</h1>
        <a href="{{ path('app_admin_revendeurs_index') }}" class="px-4 py-2 glass font-bold uppercase text-xs tracking-widest hover:bg-gray-900 hover:text-white transition-all">Retour</a>
    </div>

    {% for type, messages in app.flashes %}
        {% for message in messages %}
            <div class="mb-6 p-4 glass font-medium text-sm {{ type == 'success' ? 'border-green-300 text-green-800' : 'border-red-300 text-red-800' }}">
                {{ message }}
            </div>
        {% endfor %}
    {% endfor %}

    <div class="mb-4 px-4 py-3 glass bg-gray-900 text-[#fabf04] font-bold text-sm tracking-widest inline-block">{{ revendeur.codeRevendeur }}</div>

    <form method="post" action="{{ path('app_admin_revendeurs_edit', {id: revendeur.id}) }}" class="flex flex-col gap-6">

        <section class="glass p-6">
            <h2 class="text-sm font-bold uppercase tracking-wider mb-4">Entreprise</h2>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                <div>
                    <label for="raisonSociale" class="block text-xs font-bold uppercase tracking-wider mb-2">Raison sociale</label>
                    <input type="text" id="raisonSociale" name="raisonSociale" value="{{ revendeur.raisonSociale }}" placeholder="Nom de l'entreprise"
                           class="w-full px-4 py-3 input-glass text-sm font-medium">
                </div>
                <div>
                    <label for="siret" class="block text-xs font-bold uppercase tracking-wider mb-2">SIRET</label>
                    <input type="text" id="siret" name="siret" value="{{ revendeur.siret }}" maxlength="14" placeholder="12345678901234"
                           class="w-full px-4 py-3 input-glass text-sm font-medium">
                </div>
                <div>
                    <label for="phone" class="block text-xs font-bold uppercase tracking-wider mb-2">Telephone</label>
                    <input type="tel" id="phone" name="phone" value="{{ revendeur.phone }}" placeholder="06 12 34 56 78"
                           class="w-full px-4 py-3 input-glass text-sm font-medium">
                </div>
            </div>
            <div class="mt-4">
                <label for="email" class="block text-xs font-bold uppercase tracking-wider mb-2">Email</label>
                <input type="email" id="email" name="email" value="{{ revendeur.email }}" placeholder="email@exemple.fr"
                       class="w-full px-4 py-3 input-glass text-sm font-medium">
            </div>
        </section>

        <section class="glass p-6">
            <h2 class="text-sm font-bold uppercase tracking-wider mb-4">Adresse</h2>
            <div class="flex flex-col gap-4">
                <div>
                    <label for="address" class="block text-xs font-bold uppercase tracking-wider mb-2">Adresse</label>
                    <input type="text" id="address" name="address" value="{{ revendeur.address }}" placeholder="Numero et rue"
                           class="w-full px-4 py-3 input-glass text-sm font-medium">
                </div>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <label for="zipCode" class="block text-xs font-bold uppercase tracking-wider mb-2">Code postal</label>
                        <input type="text" id="zipCode" name="zipCode" value="{{ revendeur.zipCode }}" maxlength="10" placeholder="02800"
                               class="w-full px-4 py-3 input-glass text-sm font-medium">
                    </div>
                    <div>
                        <label for="city" class="block text-xs font-bold uppercase tracking-wider mb-2">Ville</label>
                        <input type="text" id="city" name="city" value="{{ revendeur.city }}" placeholder="Saint-Quentin"
                               class="w-full px-4 py-3 input-glass text-sm font-medium">
                    </div>
                </div>
            </div>
        </section>

        <section class="glass p-6">
            <h2 class="text-sm font-bold uppercase tracking-wider mb-4">Options</h2>
            <label for="rev-edit-isUseStripe" class="flex items-center gap-2 cursor-pointer">
                <input type="checkbox" id="rev-edit-isUseStripe" name="isUseStripe" value="1" {{ revendeur.isUseStripe ? 'checked' }} class="accent-[#fabf04]">
                <span class="text-xs font-bold">Activer Stripe Connect</span>
            </label>
            {% if revendeur.stripeConnectId %}
                <p class="text-xs text-gray-400 mt-2">Stripe Connect ID : <span class="font-mono">{{ revendeur.stripeConnectId }}</span></p>
            {% endif %}
        </section>

        <button type="submit"
                class="self-start px-6 py-3 btn-gold text-sm font-bold uppercase tracking-wider text-gray-900">
            Enregistrer
        </button>
    </form>
</div>
{% endblock %}
