{% extends 'base.html' %}
{% from 'macros.html' import render_messages, render_pagination %}

{% block content %}
<div class="container">
    {{ render_messages() }}
    
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2>{{ _('Cuentas de Vacaciones') }}</h2>
        <a href="{{ url_for('vacation.account_new') }}" class="btn btn-primary">
            <i class="bi bi-plus-lg me-1"></i>{{ _('Nueva Cuenta') }}
        </a>
    </div>

    <div class="card">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>{{ _('Empleado') }}</th>
                            <th>{{ _('Código') }}</th>
                            <th>{{ _('Política') }}</th>
                            <th>{{ _('Balance Actual') }}</th>
                            <th>{{ _('Unidad') }}</th>
                            <th>{{ _('Última Acumulación') }}</th>
                            <th>{{ _('Estado') }}</th>
                            <th>{{ _('Acciones') }}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for account in accounts %}
                        <tr>
                            <td>{{ account.empleado.primer_nombre }} {{ account.empleado.primer_apellido }}</td>
                            <td><strong>{{ account.empleado.codigo_empleado }}</strong></td>
                            <td>{{ account.policy.nombre }}</td>
                            <td>
                                <span class="badge bg-primary">{{ account.current_balance }}</span>
                            </td>
                            <td>{{ account.policy.unit_type }}</td>
                            <td>{{ account.last_accrual_date.strftime('%Y-%m-%d') if account.last_accrual_date else '-' }}</td>
                            <td>
                                {% if account.activo %}
                                    <span class="badge bg-success">{{ _('Activa') }}</span>
                                {% else %}
                                    <span class="badge bg-warning">{{ _('Inactiva') }}</span>
                                {% endif %}
                            </td>
                            <td>
                                <a href="{{ url_for('vacation.account_detail', account_id=account.id) }}" 
                                   class="btn btn-sm btn-outline-info" title="{{ _('Ver Detalles') }}">
                                    <i class="bi bi-eye"></i>
                                </a>
                            </td>
                        </tr>
                        {% else %}
                        <tr>
                            <td colspan="8" class="text-center text-muted">{{ _('No hay cuentas registradas.') }}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            {{ render_pagination(pagination, 'vacation.account_index') }}
        </div>
    </div>
</div>
{% endblock %}
