<style>
    table {
        width: 100%;
        border-collapse: collapse;
        font-size: 8pt;
    }
    th, td {
        border: 1px solid #000;
        padding: 4px;
        text-align: center;
    }
    th {
        background-color: #eee;
    }
    .print-title {
        text-align: center;
        font-size: 14pt;
        margin-bottom: 10px;
    }
    .print-date {
        text-align: right;
        font-size: 8pt;
        margin-bottom: 10px;
    }
    .text-danger {
        color: red;
    }
    .text-success {
        color: green;
    }
    .text-warning {
        color: orange;
    }
</style>

<div class="print-title">Condominio IBIZA-Cto Sierra Morena 152 - Reporte de Deudores de Conceptos Especiales</div>
<div class="print-date">Fecha de generación: <?= date('d/m/Y H:i') ?></div>

<?php if (empty($conceptDebtors['debtors'])): ?>
    <p>No hay deudores de conceptos especiales registrados.</p>
<?php else: ?>
    <?php foreach ($conceptDebtors['debtors'] as $concept): ?>
    <h5 style="font-size: 10pt; margin-top: 15px; margin-bottom: 5px;">
        <?= htmlspecialchars($concept['concept_name']) ?>
        <span style="color: orange; margin-left: 10px;">$<?= number_format($concept['total_due'], 2) ?> adeudado</span>
    </h5>
    <small style="font-size: 7pt; margin-bottom: 5px;">
        Esperado: $<?= number_format($concept['total_expected'], 2) ?> |
        Recaudado: $<?= number_format($concept['total_collected'], 2) ?> |
        Pendiente: $<?= number_format($concept['total_due'], 2) ?>
    </small>
    <table>
        <thead>
            <tr style="background-color: #fff3cd;">
                <th>Casa</th>
                <th>Propietario</th>
                <th>Monto Esperado</th>
                <th>Pagado</th>
                <th>Adeuda</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($concept['house_debtors'] as $house): ?>
                <tr>
                    <td><strong><?= $house['house_number'] ?></strong></td>
                    <td><?= htmlspecialchars($house['owner_name'] ?? '-') ?></td>
                    <td class="text-end">$<?= number_format($house['expected'], 2) ?></td>
                    <td class="text-end">$<?= number_format($house['paid'], 2) ?></td>
                    <td class="text-end fw-bold text-warning">$<?= number_format($house['due'], 2) ?></td>
                </tr>
            <?php endforeach; ?>
        </tbody>
        <tfoot>
            <tr style="background-color: #343a40; color: #fff;">
                <th colspan="4" style="text-align: right;">Total Concepto:</th>
                <th style="text-align: right;">$<?= number_format($concept['total_due'], 2) ?></th>
            </tr>
        </tfoot>
    </table>
    <?php endforeach; ?>

    <div style="margin-top: 20px; text-align: right; font-size: 10pt;">
        <h5 style="margin-bottom: 5px;">Total General Adeudado en Todos los Conceptos</h5>
        <h3 style="color: orange; margin-top: 0px;">$<?= number_format($conceptDebtors['total_due'], 2) ?></h3>
    </div>
<?php endif; ?>
