{% extends "layout.html" %}
{% block content %}
<div class="max-w-2xl">
<h1 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">
{% if is_edit %}Edit{% else %}New{% endif %} {{ resource_name }}
</h1>
<form method="post"
action="{% if is_edit %}{{ mount | safe }}/{{ base_path | safe }}/update/{{ item_id | safe }}{% else %}{{ mount | safe }}/{{ base_path | safe }}/create{% endif %}"
class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm p-6 space-y-5">
<input type="hidden" name="_csrf" value="{{ csrf_token }}">
{% for field in fields %}
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5" for="{{ field.name }}">{{ field.label }}</label>
{% if field.field_type == "textarea" %}
<textarea id="{{ field.name }}" name="{{ field.name }}" rows="4"
class="w-full px-3 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 text-sm focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">{{ record[field.name] | default(value="") }}</textarea>
{% elif field.field_type == "checkbox" %}
<input type="checkbox" id="{{ field.name }}" name="{{ field.name }}" value="true"
{% if record[field.name] %}checked{% endif %}
class="h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-indigo-600 focus:ring-indigo-500">
{% else %}
<input type="{{ field.field_type }}" id="{{ field.name }}" name="{{ field.name }}"
value="{{ record[field.name] | default(value='') }}"
class="w-full px-3 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 text-sm focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition">
{% endif %}
</div>
{% endfor %}
<div class="flex items-center gap-3 pt-2">
<button type="submit" class="inline-flex items-center px-5 py-2.5 rounded-lg text-sm font-semibold text-white bg-gradient-to-r from-indigo-600 to-fuchsia-600 shadow hover:opacity-95 transition">Save</button>
<a href="{{ mount | safe }}/{{ base_path | safe }}/list" class="inline-flex items-center px-5 py-2.5 rounded-lg text-sm font-medium border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700 transition">Cancel</a>
</div>
</form>
</div>
{% endblock content %}