<?php 
$created = can_action('72', 'created');
$edited = can_action('72', 'edited');
$deleted = can_action('72', 'deleted');
$office_hours = config_item('office_hours');
?>
<?= message_box('success'); ?>
<?= message_box('error'); ?>

<div class="space-y-6">
    <div class="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
        <div>
            <h2 class="text-2xl font-semibold text-foreground"><?= lang('leave_management') ?></h2>
            <p class="text-sm text-muted-foreground"><?= lang('manage') . ' ' . lang('leave_management') ?></p>
        </div>
        <div>
            <a href="<?= base_url('admin/leave_management/apply_leave') ?>" class="inline-flex items-center gap-2 rounded-lg bg-indigo-600 px-3 py-2 text-xs font-semibold text-white shadow-sm hover:bg-indigo-500">
                <i data-lucide="plus" class="h-4 w-4"></i>
                <span><?= lang('apply') . ' ' . lang('leave') ?></span>
            </a>
        </div>
    </div>

    <div class="rounded-2xl border border-border bg-card shadow-sm">
        <div class="border-b border-border px-4 py-3">
            <div class="flex flex-wrap items-center gap-2">
                <a href="<?= base_url('admin/leave_management') ?>"
                   class="inline-flex items-center gap-2 rounded-lg px-3 py-2 text-xs font-semibold <?= $active == 1 ? 'bg-indigo-600 text-white shadow-sm' : 'border border-border bg-card text-foreground hover:bg-muted' ?>">
                    <?= lang('pending') . ' ' . lang('approval') ?>
                </a>
                <a href="<?= base_url('admin/leave_management/my_leave') ?>"
                   class="inline-flex items-center gap-2 rounded-lg px-3 py-2 text-xs font-semibold <?= $active == 2 ? 'bg-indigo-600 text-white shadow-sm' : 'border border-border bg-card text-foreground hover:bg-muted' ?>">
                    <?= lang('my_leave') ?>
                </a>
                <?php if (!empty(admin_head())) { ?>
                    <a href="<?= base_url('admin/leave_management/all_leave') ?>"
                       class="inline-flex items-center gap-2 rounded-lg px-3 py-2 text-xs font-semibold <?= $active == 3 ? 'bg-indigo-600 text-white shadow-sm' : 'border border-border bg-card text-foreground hover:bg-muted' ?>">
                        <?= lang('all_leave') ?>
                    </a>
                <?php } ?>
                <a href="<?= base_url('admin/leave_management/leave_report') ?>"
                   class="inline-flex items-center gap-2 rounded-lg px-3 py-2 text-xs font-semibold <?= $active == 4 ? 'bg-indigo-600 text-white shadow-sm' : 'border border-border bg-card text-foreground hover:bg-muted' ?>">
                    <?= lang('leave_report') ?>
                </a>
            </div>
        </div>
        <div class="p-4">
            <script type="text/javascript">
                $(document).ready(function() {
                    list = base_url + "admin/leave_management/all_leaveList";
                });
            </script>
            <div class="table-responsive">
                <table class="table table-striped pending_approval_" id="DataTables" cellspacing="0" width="100%">
                    <thead>
                    <tr>
                        <th><?= lang('name') ?></th>
                        <th><?= lang('leave_category') ?></th>
                        <th><?= lang('date') ?></th>
                        <th><?= lang('duration') ?></th>
                        <th><?= lang('status') ?></th>
                        <?php $show_custom_fields = custom_form_table(17, null);
                        if (!empty($show_custom_fields)) {
                            foreach ($show_custom_fields as $c_label => $v_fields) {
                                if (!empty($c_label)) {
                                    ?>
                                    <th><?= $c_label ?> </th>
                                <?php }
                            }
                        }
                        ?>
                        <?php if (!empty(admin_head())) { ?>
                            <th class="col-options no-sort text-right"><?= lang('action') ?></th>
                        <?php } ?>
                    </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
</div>
