<?php
$approved = false;
if ($status == '2') {
    $approved = true;
}
?>
<style type="text/css">
    #myModal {
        z-index: 1051 !important;
    }
</style>
<div class="rounded-2xl border border-slate-200 bg-white text-slate-900 shadow-xl dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100">
    <div class="space-y-5 p-5">
        <form id="form_validation"
              action="<?php echo base_url() ?>admin/leave_management/set_action/<?php if (!empty($application_info->leave_application_id)) echo $application_info->leave_application_id; ?>"
              method="post" data-modal-refresh-page="1">

            <div class="rounded-2xl border border-slate-200 bg-slate-50/80 p-4 dark:border-slate-700 dark:bg-slate-800/60">
                <div class="mb-3 flex items-start justify-between gap-3">
                    <div>
                        <label class="text-sm font-semibold text-slate-900 dark:text-slate-100"><?= lang('remarks') ?></label>
                        <p class="mt-1 text-xs text-slate-500 dark:text-slate-400"><?= lang('give_comment') ?></p>
                    </div>
                    <span class="inline-flex items-center rounded-full px-2.5 py-1 text-[11px] font-semibold <?= !empty($approved) ? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-950/50 dark:text-emerald-300' : 'bg-amber-100 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300' ?>">
                        <?= !empty($approved) ? lang('approved') : lang('approval') ?>
                    </span>
                </div>
                <textarea name="comment" rows="5"
                          class="w-full rounded-xl border border-slate-300 bg-white px-4 py-3 text-sm text-slate-700 placeholder:text-slate-400 shadow-sm transition focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/15 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-100 dark:placeholder:text-slate-500 dark:focus:border-indigo-400 dark:focus:ring-indigo-400/20"
                          placeholder="<?= lang('remarks') ?>"><?= html_escape($application_info->comments) ?></textarea>
            </div>
            <!-- Hidden Inputs -->
            <input type="hidden" name="application_status" value="<?php echo $status ?>">
            <input type="hidden" name="approve_by" value="<?php echo $this->session->userdata('user_id') ?>">
            <input type="hidden" name="user_id" value="<?php echo $application_info->user_id; ?>">
            <input type="hidden" name="leave_category_id" value="<?php echo $application_info->leave_category_id; ?>">
            <input type="hidden" name="leave_start_date" value="<?php echo $application_info->leave_start_date; ?>">
            <?php
            if (empty($application_info->leave_end_date)) {
                $application_info->leave_end_date = $application_info->leave_start_date;
            }
            ?>
            <input type="hidden" name="leave_end_date" value="<?php echo $application_info->leave_end_date; ?>">

            <div class="flex items-center justify-end gap-2 border-t border-slate-200 pt-4 dark:border-slate-700">
                <button type="button" class="inline-flex items-center rounded-xl border border-slate-300 bg-white px-4 py-2 text-xs font-semibold text-slate-700 transition hover:bg-slate-50 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700" data-dismiss="modal"><?= lang('close') ?></button>
                <button type="submit" <?php
                if (!empty($approved)) {
                    ?>
                    onclick="return confirm('<?= lang('delete_leave_alert') ?>')"
                <?php }
                ?> class="inline-flex items-center rounded-xl bg-indigo-600 px-4 py-2 text-xs font-semibold text-white shadow-sm transition hover:bg-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/20 dark:bg-indigo-500 dark:hover:bg-indigo-400"><?= lang('update') ?></button>
            </div>
        </form>
    </div>
</div>
