<?php echo message_box('success') ?>
<?php echo message_box('error') ?>

<div class="space-y-6">
    <form action="<?php echo base_url() ?>admin/settings/save_estimate" enctype="multipart/form-data" method="post" class="space-y-6">
        <div class="rounded-2xl border border-border bg-card shadow-sm">
            <div class="flex items-center justify-between border-b border-border px-6 py-4">
                <div>
                    <h3 class="text-lg font-semibold text-foreground"><?= lang('estimate_settings') ?></h3>
                    <p class="text-sm text-muted-foreground"><?= lang('manage') . ' ' . lang('estimate_settings') ?></p>
                </div>
                <button type="submit" class="inline-flex items-center justify-center gap-2 rounded-lg bg-primary px-6 py-2.5 text-sm font-medium text-primary-foreground shadow-sm hover:bg-primary/90 transition-colors">
                    <i data-lucide="save" class="h-4 w-4"></i>
                    <?= lang('save_changes') ?>
                </button>
            </div>
            <div class="p-6 space-y-6">
                <input type="hidden" name="settings" value="<?= $load_setting ?>">

                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <?= form_input_group('estimate_prefix', lang('estimate_prefix'), config_item('estimate_prefix'), 'text', true, ) ?>
                    <?= form_input_group('estimate_start_no', lang('estimate_start_no'), config_item('estimate_start_no'), 'text', true,) ?>
                </div>

                <div class="space-y-2">
                    <?=
                    form_input_group(
                        'estimate_number_format',
                        lang('estimate') . ' ' . lang('number_format'),
                        empty(config_item('estimate_number_format'))
                            ? '[' . config_item('estimate_prefix') . ']' . '[yyyy][mm][dd][number]'
                            : config_item('estimate_number_format'),
                        'text',
                        false,
                        
                    )
                    ?>
                    <p class="text-xs text-muted-foreground">ex [<?= config_item('estimate_prefix') ?>] = <?= lang('estimate_prefix') ?>,[yyyy] = 'Current Year (<?= date('Y') ?>)'[yy] ='Current Year (<?= date('y') ?>)',[mm] = 'Current Month(<?= date('M') ?>)',[m] = 'Current Month(<?= date('m') ?>)',[dd] = 'Current Date (<?= date('d') ?>)',[number] = 'Invoice Number (<?= sprintf('%04d', config_item('estimate_start_no')) ?>)'</p>
                </div>

                <?= form_checkbox('increment_estimate_number', lang('increment_estimate_number'), config_item('increment_estimate_number') == 'TRUE', false, array('value' => 'TRUE')) ?>
                <?= form_checkbox('show_estimate_tax', lang('show_item_tax'), config_item('show_estimate_tax') == 'TRUE', false, array('value' => 'TRUE')) ?>

                <?= form_editor('estimate_terms', lang('estimate_terms'), config_item('estimate_terms'), false, array('class' => 'textarea')) ?>
                <?= form_editor('estimate_footer', lang('estimate_footer'), config_item('estimate_footer'), false, array('class' => 'textarea')) ?>
            </div>
        </div>
    </form>
</div>
