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

{% block title %}Configuration école | SALSABIL Madrassas{% endblock %}

{% block content %}
    <div class="admin-page-stack">
        <section class="admin-page-header">
            <div>
                <p class="admin-eyebrow">CONFIGURATION</p>
                <h1 class="admin-page-title">Identité publique</h1>
                <p>Modifiez les informations visibles sur la page publique de {{ ecole.nom }}.</p>
            </div>
            {% if ecole.slug %}
                <a class="admin-btn admin-btn-light" href="{{ public_school_url(ecole) }}" target="_blank" rel="noopener">
                    Voir la page publique
                </a>
            {% endif %}
        </section>

        {{ form_start(form, {attr: {class: 'admin-form'}}) }}
            <div class="admin-form-grid">
                <section class="admin-card admin-form-section">
                    <div class="admin-card-head">
                        <div>
                            <h2>Identité visuelle</h2>
                            <p>Logo, favicon et image de couverture utilisés sur la page publique.</p>
                        </div>
                    </div>
                    <div class="admin-upload-preview-grid admin-upload-preview-grid-three">
                        <div class="admin-upload-preview">
                            <span>Logo actuel</span>
                            {% if ecole.logo %}
                                <img class="admin-upload-thumb admin-upload-thumb-logo" src="{{ asset(ecole.logo) }}" alt="Logo de {{ ecole.nom }}">
                            {% else %}
                                <strong>{{ ecole.nom|slice(0, 2)|upper }}</strong>
                                <small>Aucun logo configuré</small>
                            {% endif %}
                        </div>
                        <div class="admin-upload-preview">
                            <span>Favicon actuel</span>
                            {% if ecole.favicon %}
                                <img class="admin-upload-thumb admin-upload-thumb-favicon" src="{{ asset(ecole.favicon) }}" alt="Favicon de {{ ecole.nom }}">
                            {% else %}
                                <strong>{{ ecole.nom|slice(0, 1)|upper }}</strong>
                                <small>Favicon SALSABIL utilisé par défaut</small>
                            {% endif %}
                        </div>
                        <div class="admin-upload-preview">
                            <span>Image hero actuelle</span>
                            {% if ecole.heroImage %}
                                <img class="admin-upload-thumb admin-upload-thumb-hero" src="{{ asset(ecole.heroImage) }}" alt="Image hero de {{ ecole.nom }}">
                            {% else %}
                                <strong>{{ ecole.nom|slice(0, 2)|upper }}</strong>
                                <small>Bloc visuel généré automatiquement</small>
                            {% endif %}
                        </div>
                        <div class="admin-upload-preview">
                            <span>Présentation 1</span>
                            {% if ecole.presentationImage1 %}
                                <img class="admin-upload-thumb admin-upload-thumb-hero" src="{{ asset(ecole.presentationImage1) }}" alt="Image présentation 1 de {{ ecole.nom }}">
                            {% else %}
                                <strong>01</strong>
                                <small>Image à ajouter</small>
                            {% endif %}
                        </div>
                        <div class="admin-upload-preview">
                            <span>Présentation 2</span>
                            {% if ecole.presentationImage2 %}
                                <img class="admin-upload-thumb admin-upload-thumb-hero" src="{{ asset(ecole.presentationImage2) }}" alt="Image présentation 2 de {{ ecole.nom }}">
                            {% else %}
                                <strong>02</strong>
                                <small>Image à ajouter</small>
                            {% endif %}
                        </div>
                        <div class="admin-upload-preview">
                            <span>Présentation 3</span>
                            {% if ecole.presentationImage3 %}
                                <img class="admin-upload-thumb admin-upload-thumb-hero" src="{{ asset(ecole.presentationImage3) }}" alt="Image présentation 3 de {{ ecole.nom }}">
                            {% else %}
                                <strong>03</strong>
                                <small>Image à ajouter</small>
                            {% endif %}
                        </div>
                    </div>
                    <div class="admin-form-three-cols">
                        {{ form_row(form.logoFile) }}
                        {{ form_row(form.faviconFile) }}
                        {{ form_row(form.heroImageFile) }}
                    </div>
                    <div class="admin-form-three-cols">
                        {{ form_row(form.presentationImage1File) }}
                        {{ form_row(form.presentationImage2File) }}
                        {{ form_row(form.presentationImage3File) }}
                    </div>
                </section>

                <section class="admin-card admin-form-section">
                    <div class="admin-card-head">
                        <div>
                            <h2>Textes publics</h2>
                            <p>Ces contenus alimentent le hero, la présentation et l’appel à l’action.</p>
                        </div>
                    </div>
                    <div class="admin-form-two-cols">
                        {{ form_row(form.slogan) }}
                        {{ form_row(form.heroTitle) }}
                    </div>
                    {{ form_row(form.description) }}
                    {{ form_row(form.heroSubtitle) }}
                    <div class="admin-form-two-cols">
                        {{ form_row(form.aboutTitle) }}
                        {{ form_row(form.ctaTitle) }}
                    </div>
                    {{ form_row(form.aboutText) }}
                    {{ form_row(form.ctaText) }}
                </section>

                <section class="admin-card admin-form-section">
                    <div class="admin-card-head">
                        <div>
                            <h2>Documents d’inscription</h2>
                            <p>Règlement, signature et cachet imprimés dans les documents PDF de la madrassa.</p>
                        </div>
                    </div>
                    <div class="admin-upload-preview-grid">
                        <div class="admin-upload-preview">
                            <span>Signature actuelle</span>
                            {% if ecole.imageSignatureAdministration %}
                                <img class="admin-upload-thumb admin-upload-thumb-hero" src="{{ asset(ecole.imageSignatureAdministration) }}" alt="Signature administrative de {{ ecole.nom }}">
                            {% else %}
                                <strong>ADM</strong>
                                <small>Fallback texte : L’administration</small>
                            {% endif %}
                        </div>
                        <div class="admin-upload-preview">
                            <span>Cachet actuel</span>
                            {% if ecole.imageCachetAdministration %}
                                <img class="admin-upload-thumb admin-upload-thumb-hero" src="{{ asset(ecole.imageCachetAdministration) }}" alt="Cachet administratif de {{ ecole.nom }}">
                            {% else %}
                                <strong>PDF</strong>
                                <small>Aucun cachet configuré</small>
                            {% endif %}
                        </div>
                    </div>
                    <div class="admin-form-two-cols">
                        {{ form_row(form.imageSignatureAdministrationFile) }}
                        {{ form_row(form.imageCachetAdministrationFile) }}
                    </div>
                    {{ form_row(form.reglementInterieur) }}
                </section>

                <section class="admin-card admin-form-section">
                    <div class="admin-card-head">
                        <div>
                            <h2>Contacts et couleurs</h2>
                            <p>Coordonnées publiques et palette utilisée dans le thème de la madrassa.</p>
                        </div>
                    </div>
                    <div class="admin-form-three-cols">
                        {{ form_row(form.telephone1) }}
                        {{ form_row(form.telephone2) }}
                        {{ form_row(form.whatsapp) }}
                    </div>
                    <div class="admin-form-two-cols">
                        {{ form_row(form.email) }}
                        {{ form_row(form.adresse) }}
                    </div>
                    <div class="admin-form-two-cols">
                        {{ form_row(form.ville) }}
                        {{ form_row(form.pays) }}
                    </div>
                    <div class="admin-form-three-cols">
                        {{ form_row(form.couleurPrincipale) }}
                        {{ form_row(form.couleurSecondaire) }}
                        {{ form_row(form.couleurAccent) }}
                    </div>
                </section>
            </div>

            <div class="admin-form-actions admin-form-actions-sticky">
                <a class="btn admin-btn admin-btn-secondary" href="{{ path('school_dashboard') }}">Annuler</a>
                <button class="btn admin-btn admin-btn-primary" type="submit">Enregistrer la configuration</button>
            </div>
        {{ form_end(form) }}
    </div>
{% endblock %}
