<?= message_box('success'); ?>
<?= message_box('error');

$eeror_message = $this->session->userdata('error');
if (!empty($eeror_message)) : foreach ($eeror_message as $key => $message) :
?>
        <div class="alert alert-danger">
            <?php echo $message; ?>
        </div>
<?php
    endforeach;
endif;
$this->session->unset_userdata('error');

?>
<?php
$client_summary = isset($client_summary) && is_array($client_summary) ? $client_summary : array();
$client_payments = isset($client_summary['payments_total']) ? (float) $client_summary['payments_total'] : 0;
$client_outstanding = isset($client_summary['outstanding_total']) ? (float) $client_summary['outstanding_total'] : 0;
$client_payable = isset($client_summary['payable_total']) ? (float) $client_summary['payable_total'] : 0;
$perc_paid = isset($client_summary['paid_percent']) ? $client_summary['paid_percent'] : 0;
?>
<div class="mb-5 grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
    <div class="rounded-2xl border border-sky-200 bg-gradient-to-br from-sky-50 to-white p-4 shadow-sm dark:border-sky-800 dark:from-sky-900/30 dark:to-slate-900">
        <p class="text-xs font-semibold uppercase tracking-wide text-sky-700 dark:text-sky-300"><?= lang('paid_amount') ?></p>
        <h3 class="mt-2 text-xl font-bold text-slate-900 dark:text-white">
            <?php
            if (!empty($client_payments)) {
                echo display_money($client_payments, client_currency($client_details->client_id));
            } else {
                echo '0.00';
            }
            ?>
        </h3>
        <a href="<?= base_url() ?>admin/invoice/all_payments" class="mt-3 inline-flex items-center text-xs font-semibold text-sky-700 hover:underline dark:text-sky-300">
            <?= lang('more_info') ?>
        </a>
    </div>

    <div class="rounded-2xl border border-rose-200 bg-gradient-to-br from-rose-50 to-white p-4 shadow-sm dark:border-rose-800 dark:from-rose-900/25 dark:to-slate-900">
        <p class="text-xs font-semibold uppercase tracking-wide text-rose-700 dark:text-rose-300"><?= lang('due_amount') ?></p>
        <h3 class="mt-2 text-xl font-bold text-slate-900 dark:text-white">
            <?php
            if ($client_outstanding > 0) {
                echo display_money($client_outstanding, client_currency($client_details->client_id));
            } else {
                echo '0.00';
            }
            ?>
        </h3>
        <a href="<?= base_url() ?>admin/invoice/manage_invoice" class="mt-3 inline-flex items-center text-xs font-semibold text-rose-700 hover:underline dark:text-rose-300">
            <?= lang('more_info') ?>
        </a>
    </div>

    <div class="rounded-2xl border border-emerald-200 bg-gradient-to-br from-emerald-50 to-white p-4 shadow-sm dark:border-emerald-800 dark:from-emerald-900/25 dark:to-slate-900">
        <p class="text-xs font-semibold uppercase tracking-wide text-emerald-700 dark:text-emerald-300"><?= lang('invoice_amount') ?></p>
        <h3 class="mt-2 text-xl font-bold text-slate-900 dark:text-white">
            <?php
            if ($client_payable > 0) {
                echo display_money($client_payable, client_currency($client_details->client_id));
            } else {
                echo '0.00';
            }
            ?>
        </h3>
        <a href="<?= base_url() ?>admin/invoice/manage_invoice" class="mt-3 inline-flex items-center text-xs font-semibold text-emerald-700 hover:underline dark:text-emerald-300">
            <?= lang('more_info') ?>
        </a>
    </div>

    <div class="rounded-2xl border border-violet-200 bg-gradient-to-br from-violet-50 to-white p-4 shadow-sm dark:border-violet-800 dark:from-violet-900/25 dark:to-slate-900">
        <p class="text-xs font-semibold uppercase tracking-wide text-violet-700 dark:text-violet-300"><?= lang('paid') . ' ' . lang('percentage') ?></p>
        <h3 class="mt-2 text-xl font-bold text-slate-900 dark:text-white"><?= $perc_paid ?>%</h3>
        <a href="<?= base_url() ?>admin/invoice/all_payments" class="mt-3 inline-flex items-center text-xs font-semibold text-violet-700 hover:underline dark:text-violet-300">
            <?= lang('more_info') ?>
        </a>
    </div>
</div>
<?php
$this->load->view('admin/common/tabs');
?>
