<div class="mt-4">
    <div class="flex justify-between items-center mb-3">
        <div>
            <span class="text-sm font-bold text-cyber-accent">{{ count }} serveurs proposes</span>
            <span class="text-xs text-gray-500 ml-2">Scope: {{ scope }}</span>
        </div>
    </div>

    <form method="POST" action="/campaigns/create" class="space-y-3">
        <input type="hidden" name="year" value="{{ year }}">
        <input type="hidden" name="week_number" value="{{ week }}">
        <div>
            <label class="text-xs text-gray-500">Label campagne</label>
            <input type="text" name="label" value="Patch S{{ '%02d' % week }} {{ year }} — {{ scope }}" class="w-full">
        </div>

        <div class="overflow-x-auto" style="max-height:400px; overflow-y:auto">
            <table class="w-full table-cyber text-xs">
                <thead><tr>
                    <th class="p-1 w-8"><input type="checkbox" checked onclick="this.closest('table').querySelectorAll('input[type=checkbox]').forEach(c => c.checked = this.checked)"></th>
                    <th class="text-left p-1">Hostname</th>
                    <th class="p-1">Domaine</th>
                    <th class="p-1">Env</th>
                    <th class="p-1">OS</th>
                    <th class="p-1">Tier</th>
                    <th class="p-1">Connexion</th>
                    <th class="p-1">Licence</th>
                </tr></thead>
                <tbody>
                {% for s in servers %}
                <tr class="{% if s.licence_support == 'obsolete' %}bg-red-900/10{% elif s.licence_support == 'els' %}bg-yellow-900/10{% endif %}">
                    <td class="p-1 text-center"><input type="checkbox" name="include_{{ s.id }}" checked></td>
                    <td class="p-1 font-mono text-cyber-accent">{{ s.hostname }}</td>
                    <td class="p-1 text-center">{{ s.domaine or '-' }}</td>
                    <td class="p-1 text-center"><span class="badge {% if s.environnement == 'Production' %}badge-green{% else %}badge-yellow{% endif %}">{{ (s.environnement or '-')[:6] }}</span></td>
                    <td class="p-1 text-center">{{ s.os_family or '-' }}</td>
                    <td class="p-1 text-center"><span class="badge {% if s.tier == 'tier0' %}badge-red{% elif s.tier == 'tier1' %}badge-yellow{% else %}badge-blue{% endif %}">{{ s.tier }}</span></td>
                    <td class="p-1 text-center">{{ s.ssh_method or '-' }}</td>
                    <td class="p-1 text-center"><span class="badge {% if s.licence_support == 'active' %}badge-green{% elif s.licence_support == 'obsolete' %}badge-red{% else %}badge-yellow{% endif %}">{{ s.licence_support }}</span></td>
                </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>

        <p class="text-xs text-gray-600">Decochez les serveurs a exclure. Vous pourrez aussi exclure/reporter individuellement apres creation.</p>
        <button type="submit" class="btn-primary px-6 py-2 text-sm">Créer la campagne ({{ count }} serveurs)</button>
    </form>
</div>
