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

{% block title %}{{ title }} - {% trans "Observation Categories" %} - PX360{% endblock %}

{% block content %}
<div class="container-fluid">
    <!-- Breadcrumb -->
    <nav aria-label="breadcrumb" class="mb-3">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{% url 'observations:observation_list' %}">{% trans "Observations" %}</a></li>
            <li class="breadcrumb-item"><a href="{% url 'observations:category_list' %}">{% trans "Categories" %}</a></li>
            <li class="breadcrumb-item active">{{ title }}</li>
        </ol>
    </nav>

    <div class="row justify-content-center">
        <div class="col-lg-6">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">
                        <i class="bi bi-tag me-2"></i>{{ title }}
                    </h5>
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        
                        <div class="mb-3">
                            <label class="form-label">{% trans "Name (English)" %} <span class="text-danger">*</span></label>
                            {{ form.name_en }}
                            {% if form.name_en.errors %}
                            <div class="text-danger small mt-1">{{ form.name_en.errors.0 }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">{% trans "Name (Arabic)" %}</label>
                            {{ form.name_ar }}
                            {% if form.name_ar.errors %}
                            <div class="text-danger small mt-1">{{ form.name_ar.errors.0 }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">{% trans "Description" %}</label>
                            {{ form.description }}
                            {% if form.description.errors %}
                            <div class="text-danger small mt-1">{{ form.description.errors.0 }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">{% trans "Icon" %}</label>
                                {{ form.icon }}
                                <div class="form-text">
                                    {% trans "Bootstrap icon class, e.g., bi-exclamation-triangle" %}
                                    <br>
                                    <a href="https://icons.getbootstrap.com/" target="_blank">{% trans "Browse icons" %}</a>
                                </div>
                                {% if form.icon.errors %}
                                <div class="text-danger small mt-1">{{ form.icon.errors.0 }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">{% trans "Sort Order" %}</label>
                                {{ form.sort_order }}
                                <div class="form-text">{% trans "Lower numbers appear first" %}</div>
                                {% if form.sort_order.errors %}
                                <div class="text-danger small mt-1">{{ form.sort_order.errors.0 }}</div>
                                {% endif %}
                            </div>
                        </div>
                        
                        <div class="mb-4">
                            <div class="form-check">
                                {{ form.is_active }}
                                <label class="form-check-label" for="id_is_active">
                                    {% trans "Active" %}
                                </label>
                            </div>
                            <div class="form-text">{% trans "Inactive categories won't appear in the public form" %}</div>
                        </div>
                        
                        <hr>
                        
                        <div class="d-flex justify-content-between">
                            <a href="{% url 'observations:category_list' %}" class="btn btn-outline-secondary">
                                <i class="bi bi-arrow-left me-1"></i>{% trans "Cancel" %}
                            </a>
                            <button type="submit" class="btn btn-primary">
                                <i class="bi bi-check-circle me-1"></i>{% trans "Save Category" %}
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
