{% extends "layouts/base.html" %}
{% load i18n %}

{% block title %}{% if form.instance.pk %}{% trans "Edit Checklist Item" %}{% else %}{% trans "New Checklist Item" %}{% endif %} - PX360{% endblock %}

{% block extra_css %}
<style>
    .page-header-gradient {
        background: linear-gradient(135deg, #005696 0%, #0069a8 50%, #007bbd 100%);
        color: white;
        padding: 1.5rem 2rem;
        border-radius: 1rem;
        margin-bottom: 1.5rem;
        box-shadow: 0 10px 15px -3px rgba(0, 86, 150, 0.2);
    }

    .form-section {
        background: #fff;
        border: 2px solid #e2e8f0;
        border-radius: 1rem;
        padding: 1.5rem;
        margin-bottom: 1.5rem;
        transition: all 0.3s ease;
    }
    .form-section:hover {
        border-color: #005696;
        box-shadow: 0 4px 12px rgba(0, 86, 150, 0.1);
    }

    .form-label {
        display: block;
        font-size: 0.875rem;
        font-weight: 600;
        color: #1e293b;
        margin-bottom: 0.5rem;
    }

    .form-control, .form-select {
        width: 100%;
        padding: 0.75rem 1rem;
        border: 2px solid #e2e8f0;
        border-radius: 0.75rem;
        font-size: 0.875rem;
        transition: all 0.2s ease;
    }
    .form-control:focus, .form-select:focus {
        outline: none;
        border-color: #005696;
        box-shadow: 0 0 0 3px rgba(0, 86, 150, 0.1);
    }

    .hh-btn-primary {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        background: #005696;
        color: white;
        border-radius: 0.75rem;
        font-weight: 600;
        transition: all 0.2s ease;
        border: none;
        cursor: pointer;
    }
    .hh-btn-primary:hover {
        background: #007bbd;
    }

    .hh-btn-secondary {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        background: white;
        color: #64748b;
        border: 2px solid #e2e8f0;
        border-radius: 0.75rem;
        font-weight: 600;
        transition: all 0.2s ease;
    }
    .hh-btn-secondary:hover {
        background: #f1f5f9;
        border-color: #005696;
    }
</style>
{% endblock %}

{% block content %}
<div class="p-6 md:p-8 bg-gradient-to-br from-slate-50 to-blue-50 min-h-screen">
    <!-- Page Header -->
    <div class="page-header-gradient flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
        <div>
            <nav aria-label="breadcrumb" class="mb-2">
                <ol class="flex items-center gap-2 text-sm text-white/80">
                    <li><a href="{% url 'accounts:acknowledgements:ack_checklist_list' %}" class="hover:text-white transition">{% trans "Checklist Items" %}</a></li>
                    <li><i data-lucide="chevron-right" class="w-4 h-4"></i></li>
                    <li class="text-white">{% if form.instance.pk %}{% trans "Edit" %}{% else %}{% trans "Create" %}{% endif %}</li>
                </ol>
            </nav>
            <h1 class="text-2xl font-bold flex items-center gap-2">
                <i data-lucide="{% if form.instance.pk %}edit{% else %}plus{% endif %}" class="w-8 h-8"></i>
                {% if form.instance.pk %}{% trans "Edit Checklist Item" %}{% else %}{% trans "New Checklist Item" %}{% endif %}
            </h1>
        </div>
        <a href="{% url 'accounts:acknowledgements:ack_checklist_list' %}" class="inline-flex items-center gap-2 px-4 py-2 bg-white/20 text-white rounded-lg hover:bg-white/30 transition">
            <i data-lucide="arrow-left" class="w-4 h-4"></i>
            {% trans "Back to List" %}
        </a>
    </div>

    <!-- Form Section -->
    <div class="max-w-4xl mx-auto">
        <div class="form-section">
            <div class="flex items-center gap-2 mb-4 pb-3 border-b border-slate-100">
                <i data-lucide="file-text" class="w-5 h-5 text-purple-600"></i>
                <h2 class="text-lg font-bold text-slate-800">{% trans "Checklist Item Details" %}</h2>
            </div>
            <form method="post" class="space-y-6">
                {% csrf_token %}
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <label class="form-label" for="{{ form.category.id_for_label }}">
                            {% trans "Category" %} *
                        </label>
                        {{ form.category }}
                        {% if form.category.errors %}
                        <p class="mt-1 text-sm text-red-500">{{ form.category.errors.0 }}</p>
                        {% endif %}
                    </div>
                    
                    <div>
                        <label class="form-label" for="{{ form.code.id_for_label }}">
                            {% trans "Code" %}
                        </label>
                        {{ form.code }}
                        {% if form.code.errors %}
                        <p class="mt-1 text-sm text-red-500">{{ form.code.errors.0 }}</p>
                        {% endif %}
                    </div>
                </div>
                
                <div>
                    <label class="form-label" for="{{ form.text_en.id_for_label }}">
                        {% trans "Text (English)" %} *
                    </label>
                    {{ form.text_en }}
                    {% if form.text_en.errors %}
                    <p class="mt-1 text-sm text-red-500">{{ form.text_en.errors.0 }}</p>
                    {% endif %}
                </div>
                
                <div>
                    <label class="form-label" for="{{ form.text_ar.id_for_label }}">
                        {% trans "Text (Arabic)" %}
                    </label>
                    {{ form.text_ar }}
                    {% if form.text_ar.errors %}
                    <p class="mt-1 text-sm text-red-500">{{ form.text_ar.errors.0 }}</p>
                    {% endif %}
                </div>
                
                <div>
                    <label class="form-label" for="{{ form.description_en.id_for_label }}">
                        {% trans "Description (English)" %}
                    </label>
                    {{ form.description_en }}
                    {% if form.description_en.errors %}
                    <p class="mt-1 text-sm text-red-500">{{ form.description_en.errors.0 }}</p>
                    {% endif %}
                </div>
                
                <div>
                    <label class="form-label" for="{{ form.description_ar.id_for_label }}">
                        {% trans "Description (Arabic)" %}
                    </label>
                    {{ form.description_ar }}
                    {% if form.description_ar.errors %}
                    <p class="mt-1 text-sm text-red-500">{{ form.description_ar.errors.0 }}</p>
                    {% endif %}
                </div>
                
                <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                    <div>
                        <label class="form-label" for="{{ form.order.id_for_label }}">
                            {% trans "Display Order" %}
                        </label>
                        {{ form.order }}
                        {% if form.order.errors %}
                        <p class="mt-1 text-sm text-red-500">{{ form.order.errors.0 }}</p>
                        {% endif %}
                    </div>
                    
                    <div class="flex items-center">
                        <div class="mt-6">
                            <div class="flex items-center gap-3">
                                {{ form.requires_signature }}
                                <label class="text-sm text-slate-700" for="{{ form.requires_signature.id_for_label }}">
                                    {% trans "Requires Signature" %}
                                </label>
                            </div>
                        </div>
                    </div>
                    
                    <div class="flex items-center">
                        <div class="mt-6">
                            <div class="flex items-center gap-3">
                                {{ form.is_active }}
                                <label class="text-sm text-slate-700" for="{{ form.is_active.id_for_label }}">
                                    {% trans "Active" %}
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="flex justify-end gap-3 pt-6 border-t border-slate-100">
                    <a href="{% url 'accounts:acknowledgements:ack_checklist_list' %}" class="hh-btn hh-btn-secondary">
                        {% trans "Cancel" %}
                    </a>
                    <button type="submit" class="hh-btn hh-btn-primary">
                        <i data-lucide="save" class="w-4 h-4"></i>
                        {% trans "Save Item" %}
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    lucide.createIcons();
});
</script>
{% endblock %}
