{% extends 'layouts/base.html' %}
{% load i18n %}
{% load action_icons %}

{% block title %}{% trans "Standard Categories" %}{% endblock %}

{% block content %}
<div class="container-fluid px-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h1 class="h3 mb-0">{% trans "Standard Categories" %}</h1>
            <p class="text-muted mb-0">{% trans "Manage categories to organize standards" %}</p>
        </div>
        <a href="{% url 'standards:category_create' %}" class="btn btn-primary">
            {% action_icon "create" %} {% trans "Add Category" %}
        </a>
    </div>

    <div class="card">
        <div class="card-body">
            {% if categories %}
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th width="10%">{% trans "Order" %}</th>
                            <th>{% trans "Name" %}</th>
                            <th>{% trans "Arabic Name" %}</th>
                            <th>{% trans "Description" %}</th>
                            <th>{% trans "Status" %}</th>
                            <th>{% trans "Actions" %}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for category in categories %}
                        <tr>
                            <td><span class="badge bg-secondary">{{ category.order }}</span></td>
                            <td><strong>{{ category.name }}</strong></td>
                            <td>{{ category.name_ar|default:"-" }}</td>
                            <td class="text-truncate" style="max-width: 200px;">{{ category.description|default:"-" }}</td>
                            <td>
                                {% if category.is_active %}
                                <span class="badge bg-success">{% trans "Active" %}</span>
                                {% else %}
                                <span class="badge bg-secondary">{% trans "Inactive" %}</span>
                                {% endif %}
                            </td>
                            <td>
                                <div class="d-flex gap-1">
                                    <a href="{% url 'standards:category_update' pk=category.pk %}" class="btn btn-sm btn-outline-primary" title="{% trans 'Edit' %}">
                                        {% action_icon "edit" %}
                                    </a>
                                    <a href="{% url 'standards:category_delete' pk=category.pk %}" class="btn btn-sm btn-outline-danger" title="{% trans 'Delete' %}">
                                        {% action_icon "delete" %}
                                    </a>
                                </div>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            {% else %}
            <div class="text-center py-5">
                <span class="text-muted mb-3 d-block">{% action_icon "folder" size=64 %}</span>
                <h5>{% trans "No categories found" %}</h5>
                <p class="text-muted">{% trans "Add your first standard category to organize your standards" %}</p>
                <a href="{% url 'standards:category_create' %}" class="btn btn-primary">
                    {% action_icon "create" %} {% trans "Add Category" %}
                </a>
            </div>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}
