{% 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>{{ _('Monedas') }}</h2>
        <a href="{{ url_for('currency.new') }}" class="btn btn-primary">
            <i class="bi bi-plus-lg me-1"></i>{{ _('Nueva Moneda') }}
        </a>
    </div>

    <div class="card">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>{{ _('Código') }}</th>
                            <th>{{ _('Nombre') }}</th>
                            <th>{{ _('Símbolo') }}</th>
                            <th>{{ _('Estado') }}</th>
                            <th>{{ _('Acciones') }}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for currency in currencies %}
                        <tr>
                            <td><strong>{{ currency.codigo }}</strong></td>
                            <td>{{ currency.nombre }}</td>
                            <td>{{ currency.simbolo or '-' }}</td>
                            <td>
                                {% if currency.activo %}
                                    <span class="badge bg-success">{{ _('Activo') }}</span>
                                {% else %}
                                    <span class="badge bg-warning">{{ _('Inactivo') }}</span>
                                {% endif %}
                            </td>
                            <td>
                                <a href="{{ url_for('currency.edit', id=currency.id) }}" class="btn btn-sm btn-outline-primary" title="{{ _('Editar') }}">
                                    <i class="bi bi-pencil"></i>
                                </a>
                                <form action="{{ url_for('currency.delete', id=currency.id) }}" method="POST" class="d-inline" onsubmit="return confirm('{{ _('¿Está seguro de eliminar esta moneda?') }}');">
                                    <button type="submit" class="btn btn-sm btn-outline-danger" title="{{ _('Eliminar') }}">
                                        <i class="bi bi-trash"></i>
                                    </button>
                                </form>
                            </td>
                        </tr>
                        {% else %}
                        <tr>
                            <td colspan="5" class="text-center text-muted">{{ _('No hay monedas registradas.') }}</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            {{ render_pagination(pagination, 'currency.index') }}
        </div>
    </div>
</div>
{% endblock %}
