{% 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 "Attendance Records" %}</h1>
        <a href="{% url 'hr:attendance_add' %}" class="btn btn-primary shadow-sm">
            <i class="bi bi-plus-lg me-1"></i> {% trans "Add Attendance" %}
        </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 "Date" %}</th>
                            <th>{% trans "Employee" %}</th>
                            <th>{% trans "Check In" %}</th>
                            <th>{% trans "Check Out" %}</th>
                            <th class="text-center">{% trans "Actions" %}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for att in attendances %}
                        <tr>
                            <td>{{ att.date }}</td>
                            <td>{{ att.employee }}</td>
                            <td>{{ att.check_in|default:"--" }}</td>
                            <td>{{ att.check_out|default:"--" }}</td>
                            <td class="text-center">
                                <a href="{% url 'hr:attendance_edit' att.pk %}" class="btn btn-sm btn-outline-primary">
                                    <i class="bi bi-pencil"></i>
                                </a>
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="5" class="text-center">{% trans "No attendance records found." %}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            
            {% if is_paginated %}
            <nav aria-label="Page navigation" class="mt-4">
              <ul class="pagination justify-content-center">
                {% if page_obj.has_previous %}
                  <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">{% trans "Previous" %}</a></li>
                {% endif %}
                <li class="page-item disabled"><span class="page-link">{% trans "Page" %} {{ page_obj.number }} {% trans "of" %} {{ page_obj.paginator.num_pages }}</span></li>
                {% if page_obj.has_next %}
                  <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">{% trans "Next" %}</a></li>
                {% endif %}
              </ul>
            </nav>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}