@model Rs_system.Models.RegistroCulto
@{
    ViewData["Title"] = "Detalles del Registro";
}

<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h4 class="mb-1">Detalles del Registro</h4>
        <p class="text-muted mb-0">@Model.Fecha.ToString("dddd, dd 'de' MMMM 'de' yyyy")</p>
    </div>
    <div>
        <a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-outline-primary me-2">
            <i class="bi bi-pencil me-1"></i> Editar
        </a>
        <a asp-action="Index" class="btn btn-outline-secondary">
            <i class="bi bi-arrow-left me-1"></i> Volver
        </a>
    </div>
</div>

<div class="row">
    <!-- Left Column: Summary -->
    <div class="col-lg-4">
        <div class="card-custom">
            <h6 class="mb-3"><i class="bi bi-info-circle me-2"></i>Información General</h6>
            
            <dl class="mb-0">
                <dt class="text-muted">Fecha</dt>
                <dd>@Model.Fecha.ToString("dd/MM/yyyy")</dd>
                
                <dt class="text-muted">Observaciones</dt>
                <dd>@(string.IsNullOrEmpty(Model.Observaciones) ? "Sin observaciones" : Model.Observaciones)</dd>
                
                <dt class="text-muted">Registrado por</dt>
                <dd>@(Model.CreadoPor ?? "Sistema")</dd>
                
                <dt class="text-muted">Fecha de Registro</dt>
                <dd>@Model.CreadoEn.ToString("dd/MM/yyyy HH:mm")</dd>
            </dl>
        </div>

        <!-- Summary Card -->
        <div class="card-custom mt-3">
            <h6 class="mb-3"><i class="bi bi-calculator me-2"></i>Resumen</h6>
            
            <div class="d-flex justify-content-between mb-2">
                <span>Total Ofrendas:</span>
                <strong>$ @Model.TotalOfrendas.ToString("N2")</strong>
            </div>
            <div class="d-flex justify-content-between mb-2">
                <span>Total Descuentos:</span>
                <strong class="text-warning">$ @Model.TotalDescuentos.ToString("N2")</strong>
            </div>
            <hr>
            <div class="d-flex justify-content-between">
                <span class="fw-bold">Monto Neto:</span>
                <strong class="text-success fs-5">$ @Model.MontoNeto.ToString("N2")</strong>
            </div>
        </div>
    </div>

    <!-- Right Column: Offerings Detail -->
    <div class="col-lg-8">
        <div class="card-custom">
            <h6 class="mb-3"><i class="bi bi-cash-stack me-2"></i>Detalle de Ofrendas</h6>
            
            @if (!Model.Ofrendas.Any())
            {
                <div class="text-center text-muted py-4">
                    <i class="bi bi-inbox fs-1 d-block mb-2"></i>
                    No hay ofrendas registradas
                </div>
            }
            else
            {
                @foreach (var ofrenda in Model.Ofrendas)
                {
                    <div class="card mb-3">
                        <div class="card-header bg-light d-flex justify-content-between align-items-center py-2">
                            <span class="fw-semibold">@ofrenda.Concepto</span>
                            <span class="badge bg-primary">$ @ofrenda.Monto.ToString("N2")</span>
                        </div>
                        <div class="card-body py-2">
                            @if (ofrenda.Descuentos.Any())
                            {
                                <table class="table table-sm mb-0">
                                    <thead>
                                        <tr class="text-muted">
                                            <th>Descuento</th>
                                            <th class="text-end">Monto</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach (var descuento in ofrenda.Descuentos)
                                        {
                                            <tr>
                                                <td>@descuento.Concepto</td>
                                                <td class="text-end text-warning">-$ @descuento.Monto.ToString("N2")</td>
                                            </tr>
                                        }
                                    </tbody>
                                    <tfoot>
                                        <tr class="border-top">
                                            <th>Neto</th>
                                            <th class="text-end text-success">$ @ofrenda.MontoNeto.ToString("N2")</th>
                                        </tr>
                                    </tfoot>
                                </table>
                            }
                            else
                            {
                                <p class="text-muted mb-0 small">Sin descuentos aplicados</p>
                            }
                        </div>
                    </div>
                }
            }
        </div>
    </div>
</div>
