<form method="post" action="<?php echo base_url() ?>client/mailbox/delete_inbox_mail">
    <div class="rounded-2xl border border-border bg-card shadow-sm">
        <div class="flex flex-wrap items-center justify-between gap-3 border-b border-border px-4 py-3">
            <div class="flex flex-wrap items-center gap-2 text-xs font-semibold">
                <label class="inline-flex h-9 w-9 items-center justify-center rounded-md border border-border bg-card text-foreground hover:bg-muted">
                    <input type="checkbox" id="parent_present" class="h-4 w-4 rounded border-border">
                    <span class="hidden"><?= lang('select_all') ?></span>
                </label>
                <button type="submit" class="inline-flex h-9 w-9 items-center justify-center rounded-md border border-border bg-card text-foreground hover:bg-muted">
                   <i data-lucide="trash" class="h-4 w-4"></i>
                    <span class="hidden"><?= lang('delete') ?></span>
                </button>
                <a href="#" onClick="history.go(0)" class="inline-flex h-9 w-9 items-center justify-center rounded-md border border-border bg-card text-foreground hover:bg-muted">
                    <i data-lucide="refresh-cw" class="h-4 w-4"></i>
                    <span class="hidden"><?= lang('refresh') ?></span>
                </a>
            </div>
            <a href="<?php echo base_url() ?>client/mailbox/index/compose"
               class="inline-flex items-center gap-2 rounded-lg bg-indigo-600 px-4 py-2 text-xs font-semibold text-white shadow-sm hover:bg-indigo-500">
               <i data-lucide="square-pen" class="h-4 w-4"></i>
                <span class="hidden"><?= lang('compose') ?></span>
            </a>
        </div>
        <div class="divide-y divide-border">
            <?php if (!empty($get_inbox_message)): foreach ($get_inbox_message as $v_inbox_msg): ?>
                <?php
                $subject = (strlen($v_inbox_msg->subject) > 50) ? strip_html_tags(mb_substr($v_inbox_msg->subject, 0, 50)) . '...' : $v_inbox_msg->subject;
                $string = (strlen($v_inbox_msg->to) > 50) ? strip_html_tags(mb_substr($v_inbox_msg->to, 0, 50)) . '...' : $v_inbox_msg->to;
                $body = (strlen($v_inbox_msg->message_body) > 100) ? strip_html_tags(mb_substr($v_inbox_msg->message_body, 0, 100)) . '...' : $v_inbox_msg->message_body;
                $uploaded_file = !empty($v_inbox_msg->attach_file) ? json_decode($v_inbox_msg->attach_file) : array();
                $is_unread = $v_inbox_msg->view_status != 1;
                ?>
                <div class="flex flex-col gap-3 px-4 py-4 md:flex-row md:items-start md:justify-between hover:bg-muted/40">
                    <div class="flex items-start gap-3">
                        <input class="child_present mt-1 h-4 w-4 rounded border-border" type="checkbox" name="selected_id[]"
                               value="<?php echo $v_inbox_msg->inbox_id; ?>"/>
                        <a class="mt-0.5 text-yellow" href="<?php echo base_url() ?>client/mailbox/index/added_favourites/<?php echo $v_inbox_msg->inbox_id ?>/<?= $v_inbox_msg->favourites == 1 ? '0' : '1' ?>">
                            <i class="fa fa-lg <?= $v_inbox_msg->favourites == 1 ? 'fa-star' : 'fa-star-o' ?>"></i>
                        </a>
                        <div class="min-w-0">
                            <a class="text-sm <?= $is_unread ? 'font-semibold text-foreground' : 'text-foreground' ?>"
                               href="<?php echo base_url() ?>client/mailbox/index/read_inbox_mail/<?php echo $v_inbox_msg->inbox_id ?>">
                                <?= $subject ?>
                            </a>
                            <div class="text-xs text-muted-foreground <?= $is_unread ? 'font-semibold' : '' ?>"><?= $string ?></div>
                            <div class="flex items-center gap-2 text-xs text-muted-foreground">
                                <span class="truncate max-w-[520px]"><?= $body ?></span>
                                <?php if (!empty($uploaded_file)): ?>
                                    <i data-lucide="paperclip"></i>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                    <div class="text-xs text-muted-foreground"><?= time_ago($v_inbox_msg->message_time); ?></div>
                </div>
            <?php endforeach; ?>
            <?php else: ?>
                <div class="px-4 py-6 text-sm text-muted-foreground"><?= lang('no_data') ?></div>
            <?php endif; ?>
        </div>
    </div>
</form>


