<div>
    <div class="mb-6">
        <h1 class="text-2xl font-bold text-gray-900">Impostazioni</h1>
    </div>

    <div class="mb-6 bg-white rounded-xl shadow-sm border border-gray-200 p-4 max-w-lg">
        <p class="text-sm font-medium text-gray-700 mb-3">Import / Export dati XML</p>
        <div class="flex flex-wrap gap-2">
            <a href="{{ route('xml.exchange') }}" class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-amber-600 rounded-lg hover:bg-amber-700 transition">
                Import XML
            </a>
            <a href="{{ route('xml.exchange') }}" class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-emerald-600 rounded-lg hover:bg-emerald-700 transition">
                Export XML
            </a>
        </div>
        <p class="text-xs text-gray-500 mt-2">I pulsanti aprono la sezione XML Exchange con gli strumenti di conversione, import e export.</p>
    </div>

    <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6 max-w-lg">
        @if (session()->has('success'))
            <div x-data="{ show: true }" x-show="show" x-init="setTimeout(() => show = false, 3000)" x-transition.duration.500ms
                 class="mb-4 rounded-lg bg-green-50 p-4 text-sm text-green-700 border border-green-200">
                {{ session('success') }}
            </div>
        @endif

        <form wire:submit="save" class="space-y-5">
            <div>
                <label for="congregazione_nome" class="block text-sm font-medium text-gray-700">Nome Congregazione *</label>
                <input wire:model="congregazione_nome" type="text" id="congregazione_nome" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm" required>
                @error('congregazione_nome') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>

            <div>
                <label for="giorni_giacenza_da_assegnare" class="block text-sm font-medium text-gray-700">Soglia Da Assegnare (giorni)</label>
                <p class="text-xs text-gray-500 mb-1">Dopo quanti giorni dal rientro un territorio compare nella lista "da assegnare".</p>
                <input wire:model="giorni_giacenza_da_assegnare" type="number" min="1" max="730" id="giorni_giacenza_da_assegnare" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
                @error('giorni_giacenza_da_assegnare') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>

            <div>
                <label for="giorni_giacenza_prioritari" class="block text-sm font-medium text-gray-700">Soglia Priorità (giorni)</label>
                <p class="text-xs text-gray-500 mb-1">Dopo quanti giorni dal rientro un territorio diventa prioritario automaticamente.</p>
                <input wire:model="giorni_giacenza_prioritari" type="number" min="1" max="730" id="giorni_giacenza_prioritari" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
                @error('giorni_giacenza_prioritari') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>

            <div>
                <label for="giorni_per_smarrito" class="block text-sm font-medium text-gray-700">Soglia Rientro (giorni)</label>
                <p class="text-xs text-gray-500 mb-1">Dopo quanti giorni dall'assegnazione un territorio appare nella lista "da rientrare".</p>
                <input wire:model="giorni_per_smarrito" type="number" min="30" max="365" id="giorni_per_smarrito" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
                @error('giorni_per_smarrito') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>

            <div>
                <label for="home_limit_list" class="block text-sm font-medium text-gray-700">Limite Liste Home</label>
                <p class="text-xs text-gray-500 mb-1">Numero massimo di elementi mostrati nelle liste rapide in dashboard.</p>
                <input wire:model="home_limit_list" type="number" min="1" max="100" id="home_limit_list" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
                @error('home_limit_list') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>

            <div>
                <label for="audit_retention_days" class="block text-sm font-medium text-gray-700">Conservazione Audit (giorni)</label>
                <p class="text-xs text-gray-500 mb-1">I log più vecchi di questo periodo verranno cancellati automaticamente.</p>
                <input wire:model="audit_retention_days" type="number" min="30" max="3650" id="audit_retention_days" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
                @error('audit_retention_days') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
            </div>

            <div class="pt-4">
                <button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 transition">Salva Impostazioni</button>
            </div>
        </form>
    </div>
</div>
