{% extends 'base.html' %}
{% load i18n %}

{% block content %}
<div class="container-fluid">
    <div class="d-sm-flex align-items-center justify-content-between mb-4">
        <h1 class="h3 mb-0 text-gray-800">{% trans "Departments" %}</h1>
        <a href="{% url 'hr:department_add' %}" class="btn btn-primary shadow-sm">
            <i class="bi bi-plus-lg me-1"></i> {% trans "Add New Department" %}
        </a>
    </div>

    <div class="card shadow mb-4">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered table-hover" width="100%" cellspacing="0">
                    <thead class="table-light">
                        <tr>
                            <th>{% trans "Name (English)" %}</th>
                            <th>{% trans "Name (Arabic)" %}</th>
                            <th>{% trans "Employees" %}</th>
                            <th class="text-center">{% trans "Actions" %}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for department in departments %}
                        <tr>
                            <td>{{ department.name_en }}</td>
                            <td>{{ department.name_ar }}</td>
                            <td>{{ department.employees.count }}</td>
                            <td class="text-center">
                                <a href="{% url 'hr:department_edit' department.pk %}" class="btn btn-sm btn-outline-primary">
                                    <i class="bi bi-pencil"></i>
                                </a>
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="4" class="text-center">{% trans "No departments found." %}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}