<div class="invoice-modern">
    <div class="grid gap-5 lg:grid-cols-12">
        <div class="lg:col-span-4 xl:col-span-3">
            <?= isset($invoice_sidebar_html) ? $invoice_sidebar_html : '' ?>
        </div>

        <section class="lg:col-span-8 xl:col-span-9">
            <div class="rounded-2xl border border-slate-200 bg-white shadow-sm dark:border-slate-700 dark:bg-slate-900">
                <div class="border-b border-slate-200 px-5 py-4 dark:border-slate-700">
                    <h3 class="text-sm font-semibold text-slate-900 dark:text-slate-100"><?= lang('email_invoice') ?></h3>
                </div>
                <div class="p-5">
                    <form method="post" action="<?= base_url() ?>admin/invoice/send_invoice_email/<?= $invoice_info->invoices_id ?>" class="space-y-4">
                        <input type="hidden" name="ref" value="<?= $invoice_info->reference_no ?>">
                        <?php
                        $client_info = $this->invoice_model->check_by(array('client_id' => $invoice_info->client_id), 'tbl_client');
                        $client_name_hidden = !empty($client_info->name) ? ucfirst((string) $client_info->name) : '-';
                        ?>
                        <input type="hidden" name="client_name" value="<?= html_escape($client_name_hidden) ?>">
                        <input type="hidden" name="currency" value="<?= $invoice_info->currency; ?>">
                        <input type="hidden" name="amount" value="<?= ($this->invoice_model->calculate_to('invoice_due', $invoice_info->invoices_id)) ?>">

                        <?php
                        $email_template = email_templates(array('email_group' => 'invoice_message'), $invoice_info->client_id);
                        $message = $email_template->template_body;
                        $subject = $email_template->subject;
                        ?>

                        <div class="max-w-2xl">
                            <?= form_input_group('subject', lang('subject'), $subject . ' ' . $invoice_info->reference_no, 'text', false) ?>
                        </div>

                        <div>
                            <?= form_editor('message', lang('message'), $message, false, array('class' => 'textarea_', 'data-height' => '320px')); ?>
                        </div>

                        <div>
                            <button type="submit"
                                class="submit inline-flex items-center rounded-lg bg-slate-900 px-4 py-2 text-sm font-semibold text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white"><?= lang('send') ?></button>
                        </div>
                    </form>
                </div>
            </div>
        </section>
    </div>
</div>
