<x-layouts.tenant pageTitle="Editar plantilla">
    <x-page-header :title="'Editar: '.$template->title" subtitle="Modifica el contenido de esta plantilla de consentimiento.">
        <x-btn href="{{ route('tenant.consent-templates.index') }}" variant="secondary">Cancelar</x-btn>
    </x-page-header>

    <form method="POST" action="{{ route('tenant.consent-templates.update', $template) }}" class="space-y-6">
        @csrf @method('PUT')

        <x-card>
            <div class="space-y-4">
                <label class="block">
                    <span class="text-sm font-medium text-gray-700">Título <span class="text-red-500">*</span></span>
                    <input type="text" name="title" value="{{ old('title', $template->title) }}" required
                           class="mt-1 w-full rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">
                </label>
                <label class="block">
                    <span class="text-sm font-medium text-gray-700">Contenido <span class="text-red-500">*</span></span>
                    <textarea name="content" rows="15" required
                              class="mt-1 w-full rounded-lg border-gray-300 text-sm focus:border-indigo-500 focus:ring-indigo-500">{{ old('content', $template->content) }}</textarea>
                </label>
                <div class="flex flex-col sm:flex-row gap-4">
                    <label class="flex items-center gap-2 cursor-pointer">
                        <input type="checkbox" name="requires_signature" value="1" @checked(old('requires_signature', $template->requires_signature))
                               class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
                        <span class="text-sm text-gray-700">Requiere firma del paciente</span>
                    </label>
                    <label class="flex items-center gap-2 cursor-pointer">
                        <input type="checkbox" name="is_active" value="1" @checked(old('is_active', $template->is_active))
                               class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
                        <span class="text-sm text-gray-700">Plantilla activa</span>
                    </label>
                </div>
            </div>
        </x-card>

        <div class="flex justify-end gap-3">
            <x-btn href="{{ route('tenant.consent-templates.index') }}" variant="secondary">Cancelar</x-btn>
            <x-btn type="submit" variant="primary">Actualizar plantilla</x-btn>
        </div>
    </form>
</x-layouts.tenant>
