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

{% block content %}
<div class="container">
    {{ render_messages() }}
    {{ render_form_errors(form) }}
    
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2>{{ titulo }}</h2>
        <a href="{{ url_for('vacation.policy_index') }}" class="btn btn-secondary">
            <i class="bi bi-arrow-left me-1"></i>{{ _('Volver') }}
        </a>
    </div>

    <div class="card">
        <div class="card-body">
            <form method="POST" action="">
                {{ form.hidden_tag() }}
                
                <h5 class="mb-3">{{ _('Información General') }}</h5>
                <div class="row">
                    <div class="col-md-4">
                        {{ render_field(form.codigo) }}
                    </div>
                    <div class="col-md-8">
                        {{ render_field(form.nombre) }}
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-12">
                        {{ render_field(form.descripcion) }}
                    </div>
                </div>
                
                <div class="alert alert-info">
                    <i class="bi bi-info-circle me-2"></i>
                    <strong>{{ _('Asociación de Política:') }}</strong> {{ _('Las políticas pueden asociarse a una Planilla específica (recomendado para multi-país) o a una Empresa completa. Una instalación puede tener varias planillas con distintas reglas de vacaciones.') }}
                </div>
                
                <div class="row">
                    <div class="col-md-6">
                        {{ render_field(form.planilla_id) }}
                    </div>
                    <div class="col-md-6">
                        {{ render_field(form.empresa_id) }}
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-12">
                        {{ render_field(form.activo) }}
                    </div>
                </div>

                <hr class="my-4">
                
                <h5 class="mb-3">{{ _('Configuración de Acumulación') }}</h5>
                <div class="row">
                    <div class="col-md-4">
                        {{ render_field(form.accrual_method) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.accrual_rate) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.accrual_frequency) }}
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-6">
                        {{ render_field(form.accrual_basis) }}
                    </div>
                    <div class="col-md-6">
                        {{ render_field(form.min_service_days) }}
                    </div>
                </div>

                <hr class="my-4">
                
                <h5 class="mb-3">{{ _('Límites de Balance') }}</h5>
                <div class="row">
                    <div class="col-md-4">
                        {{ render_field(form.max_balance) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.carryover_limit) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.allow_negative) }}
                    </div>
                </div>

                <hr class="my-4">
                
                <h5 class="mb-3">{{ _('Reglas de Vencimiento') }}</h5>
                <div class="row">
                    <div class="col-md-4">
                        {{ render_field(form.expiration_rule) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.expiration_months) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.expiration_date) }}
                    </div>
                </div>

                <hr class="my-4">
                
                <h5 class="mb-3">{{ _('Configuración de Uso') }}</h5>
                <div class="row">
                    <div class="col-md-4">
                        {{ render_field(form.unit_type) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.payout_on_termination) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.accrue_during_leave) }}
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-4">
                        {{ render_field(form.count_weekends) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.count_holidays) }}
                    </div>
                    <div class="col-md-4">
                        {{ render_field(form.partial_units_allowed) }}
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-12">
                        {{ render_field(form.rounding_rule) }}
                    </div>
                </div>
                
                <div class="mt-4">
                    {{ form.submit(class="btn btn-primary") }}
                    <a href="{{ url_for('vacation.policy_index') }}" class="btn btn-secondary">{{ _('Cancelar') }}</a>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}
