{{define "apps_new.html"}}
{{template "partials/header.html" .}}

<h1>Nouvelle Application</h1>

<form method="post" action="/admin/apps/new">
    <input type="hidden" name="csrf_token" value="{{.CSRFToken}}">

    <!-- Informations générales -->
    <article>
        <header><strong>Informations</strong></header>

        <label for="app_name">Nom de l'application *</label>
        <input type="text" id="app_name" name="app_name" required
               pattern="[a-z][a-z0-9_]*" placeholder="monapp"
               aria-describedby="app_name_help">
        <small id="app_name_help">Lettres minuscules, chiffres et underscore uniquement</small>

        <label for="version">Version</label>
        <input type="text" id="version" name="version" value="1.0" placeholder="1.0">

        <label for="base_path">Base Path *</label>
        <input type="text" id="base_path" name="base_path" value="/api" required placeholder="/api">
    </article>

    <!-- Hosts -->
    <article>
        <header><strong>Hosts</strong></header>

        <label for="hosts">Domaines (un par ligne) *</label>
        <textarea id="hosts" name="hosts" rows="3" required
                  placeholder="monapp.example.com&#10;monapp.sogoms.com"></textarea>
    </article>

    <!-- Database -->
    <article>
        <header><strong>Base de donn&eacute;es</strong></header>

        <div class="grid">
            <div>
                <label for="db_host">Host *</label>
                <input type="text" id="db_host" name="db_host" required placeholder="127.0.0.1">
            </div>
            <div>
                <label for="db_port">Port *</label>
                <input type="number" id="db_port" name="db_port" value="3306" required>
            </div>
        </div>

        <div class="grid">
            <div>
                <label for="db_user">Utilisateur *</label>
                <input type="text" id="db_user" name="db_user" required placeholder="monapp_user">
            </div>
            <div>
                <label for="db_name">Base *</label>
                <input type="text" id="db_name" name="db_name" required placeholder="monapp">
            </div>
        </div>

        <label for="db_password">Mot de passe *</label>
        <input type="password" id="db_password" name="db_password" required>
    </article>

    <!-- Auth -->
    <article>
        <header><strong>Authentification JWT</strong></header>

        <label for="jwt_expiry">Dur&eacute;e du token</label>
        <select id="jwt_expiry" name="jwt_expiry">
            <option value="1h">1 heure</option>
            <option value="12h">12 heures</option>
            <option value="24h" selected>24 heures</option>
            <option value="168h">7 jours</option>
            <option value="720h">30 jours</option>
        </select>
        <small>Le secret JWT sera g&eacute;n&eacute;r&eacute; automatiquement</small>
    </article>

    <!-- Actions -->
    <div class="grid">
        <a href="/admin/apps" role="button" class="secondary outline">Annuler</a>
        <button type="submit">Cr&eacute;er l'application</button>
    </div>
</form>

{{template "partials/footer.html" .}}
{{end}}
