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

<?php
$can_do = can_do(111);
$country_options = array();
$current_country = $this->config->item('company_country');
if (!empty($current_country)) {
    $country_options[$current_country] = $current_country;
}
if (!empty($countries)) {
    foreach ($countries as $country) {
        if (!isset($country_options[$country->value])) {
            $country_options[$country->value] = $country->value;
        }
    }
}
?>

<div class="space-y-6">
    <div class="rounded-2xl border border-border bg-card shadow-sm">
        <?php if (!empty($can_do)) { ?>
            <form role="form" id="form" action="<?php echo base_url(); ?>admin/settings/save_settings" method="post"
                  class="space-y-6 p-6">
                <input type="hidden" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>">
                <div class="flex items-center justify-between border-b border-border pb-4">
                    <div>
                        <h3 class="text-lg font-semibold text-foreground"><?= lang('company_details') ?></h3>
                        <p class="text-sm text-muted-foreground"><?= lang('manage') . ' ' . lang('company_details') ?></p>
                    </div>
                </div>

                <input type="hidden" name="settings" value="<?= $load_setting ?>">
                <input type="hidden" name="languages" value="<?php
                if (!empty($translations)) {
                    echo implode(",", $translations);
                }
                ?>">

                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <?= form_input_group('company_name', lang('company_name'), $this->config->item('company_name'), 'text', true); ?>
                    <?= form_input_group('company_legal_name', lang('company_legal_name'), $this->config->item('company_legal_name'), 'text', true); ?>
                    <?= form_input_group('contact_person', lang('contact_person'), $this->config->item('contact_person')); ?>
                    <?= form_input_group('company_city', lang('city'), $this->config->item('company_city')); ?>
                    <?= form_input_group('company_zip_code', lang('zip_code'), $this->config->item('company_zip_code')); ?>
                    <?= form_input_group('company_phone', lang('company_phone'), $this->config->item('company_phone')); ?>
                    <?= form_input_group('company_email', lang('company_email'), $this->config->item('company_email'), 'email'); ?>
                    <?= form_input_group('company_domain', lang('company_domain'), $this->config->item('company_domain')); ?>
                    <?= form_input_group('company_vat', lang('company_vat'), $this->config->item('company_vat')); ?>
                    <?= form_select_group('company_country', lang('country'), $country_options, $current_country, false, array('class' => 'select_box', 'style' => 'width:100%')); ?>
                </div>

                <?= form_editor('company_address', lang('company_address'), $this->config->item('company_address'), true); ?>

                <div class="flex justify-end gap-2 pt-2">
                    <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>
            </form>
        <?php } else { ?>
            <div class="p-6 text-sm text-muted-foreground"><?= lang('nothing_to_display'); ?></div>
        <?php } ?>
    </div>
</div>
