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

<div class="space-y-6">
    <form action="<?php echo base_url() ?>admin/settings/save_proposals" 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('proposals_settings') ?></h3>
                    <p class="text-sm text-muted-foreground"><?= lang('manage') . ' ' . lang('proposals_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('proposal_prefix', lang('proposal_prefix'), config_item('proposal_prefix'), 'text', true, array('class' => 'max-w-xs')) ?>
                    <?= form_input_group('proposal_start_no', lang('proposal_start_no'), config_item('proposal_start_no'), 'text', true, array('class' => 'max-w-xs')) ?>
                </div>

                <div class="space-y-2">
                    <label class="text-sm font-medium text-foreground"><?= lang('proposal') . ' ' . lang('number_format') ?></label>
                    <input type="text" name="proposal_number_format" class="w-full rounded-lg border border-border bg-input px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-secondary/30 max-w-lg" value="<?php
                    if (empty(config_item('proposal_number_format'))) {
                        echo '[' . config_item('proposal_prefix') . ']' . '[yyyy][mm][dd][number]';
                    } else {
                        echo config_item('proposal_number_format');
                    }
                    ?>">
                    <p class="text-xs text-muted-foreground">ex [<?= config_item('proposal_prefix') ?>] = <?= lang('proposal_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('proposal_start_no')) ?>)'</p>
                </div>

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

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