<style>
    .sup_form {
        padding: 20px;
        font-family: 'Segoe UI', Arial, sans-serif;
        background: #f0f4ff;
        min-height: 100%;
    }

    .sup_card {
        background: rgba(255, 255, 255, 0.75);
        backdrop-filter: blur(12px);
        border: 1px solid rgba(255, 255, 255, 0.9);
        border-radius: 14px;
        padding: 22px 26px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
        margin-bottom: 16px;
    }

    .sup_section_title {
        font-size: 12px;
        font-weight: 700;
        color: #0f3460;
        text-transform: uppercase;
        letter-spacing: 0.8px;
        margin-bottom: 16px;
        padding-bottom: 8px;
        border-bottom: 2px solid rgba(15, 52, 96, 0.2);
    }

    .sup_grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 12px 20px;
    }

    .sup_grid.full {
        grid-template-columns: 1fr;
    }

    .sup_group {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .sup_group label {
        font-size: 11px;
        font-weight: 700;
        color: #666;
        text-transform: uppercase;
        letter-spacing: 0.4px;
    }

    .sup_group label.required::after {
        content: ' *';
        color: #dc3545;
    }

    .sup_group input[type=text],
    .sup_group textarea {
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 9px 12px;
        font-size: 13px;
        color: #333;
        outline: none;
        transition: all 0.2s;
        background: white;
        font-family: 'Segoe UI', Arial, sans-serif;
        width: 100%;
        box-sizing: border-box;
    }

    .sup_group input:focus,
    .sup_group textarea:focus {
        border-color: #0f3460;
        box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.12);
    }

    .sup_group textarea {
        resize: vertical;
        min-height: 70px;
    }

    .sup_submit_btn {
        background: linear-gradient(135deg, #0f3460, #16213e);
        color: white;
        border: none;
        border-radius: 10px;
        padding: 12px 32px;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
        box-shadow: 0 4px 14px rgba(15, 52, 96, 0.4);
        transition: all 0.2s;
        width: 100%;
        margin-top: 4px;
        letter-spacing: 0.3px;
        font-family: 'Segoe UI', Arial, sans-serif;
    }

    .sup_submit_btn:hover {
        background: linear-gradient(135deg, #1a4a7a, #0f3460);
        box-shadow: 0 6px 20px rgba(15, 52, 96, 0.5);
        transform: translateY(-1px);
    }

    #error_message_box {
        background: rgba(220, 53, 69, 0.08);
        border: 1px solid rgba(220, 53, 69, 0.2);
        border-radius: 8px;
        padding: 10px 14px;
        margin-bottom: 14px;
        color: #dc3545;
        font-size: 12px;
        list-style: none;
    }

    #error_message_box li {
        margin-left: 12px;
        list-style: disc;
    }

    /* ── Responsive ── */
    @media (max-width: 768px) {

        .sup_form {
            padding: 12px;
        }

        .sup_card {
            padding: 14px 16px;
            margin-bottom: 12px;
        }

        .sup_grid {
            grid-template-columns: 1fr !important;
        }

        .sup_group.sup_grid {
            grid-template-columns: 1fr !important;
        }

        .sup_group input[type=text],
        .sup_group textarea {
            font-size: 14px;
            padding: 10px 12px;
        }

        .sup_submit_btn {
            padding: 12px;
            font-size: 14px;
        }
    }

    @media (max-width: 480px) {

        .sup_form {
            padding: 8px;
        }

        .sup_card {
            padding: 12px;
        }

        .sup_section_title {
            font-size: 11px;
        }

        .sup_group label {
            font-size: 10px;
        }
    }
</style>

<?php echo form_open('suppliers/save/' . $person_info->person_id, array('id' => 'supplier_form')); ?>

<div class="sup_form">

    <ul id="error_message_box" style="display:none;"></ul>

    <!-- Company Info -->
    <div class="sup_card">
        <div class="sup_section_title">🏭 <?php echo $this->lang->line('suppliers_basic_information'); ?></div>
        <div class="sup_grid">
            <div class="sup_group sup_grid" style="grid-column:1/-1;grid-template-columns:1fr 1fr;gap:12px 20px;">
                <div class="sup_group">
                    <label class="required"><?php echo $this->lang->line('suppliers_company_name'); ?></label>
                    <?php echo form_input(array('name' => 'company_name', 'id' => 'company_name_input', 'value' => $person_info->company_name)); ?>
                </div>
                <div class="sup_group">
                    <label><?php echo $this->lang->line('suppliers_account_number'); ?></label>
                    <?php echo form_input(array('name' => 'account_number', 'id' => 'account_number', 'value' => $person_info->account_number)); ?>
                </div>
            </div>
            <div class="sup_group">
                <label class="required"><?php echo $this->lang->line('common_first_name'); ?></label>
                <?php echo form_input(array('name' => 'first_name', 'id' => 'first_name', 'value' => $person_info->first_name)); ?>
            </div>
            <div class="sup_group">
                <label class="required"><?php echo $this->lang->line('common_last_name'); ?></label>
                <?php echo form_input(array('name' => 'last_name', 'id' => 'last_name', 'value' => $person_info->last_name)); ?>
            </div>
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_email'); ?></label>
                <?php echo form_input(array('name' => 'email', 'id' => 'email', 'value' => $person_info->email)); ?>
            </div>
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_phone_number'); ?></label>
                <?php echo form_input(array('name' => 'phone_number', 'id' => 'phone_number', 'value' => $person_info->phone_number)); ?>
            </div>
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_address_1'); ?></label>
                <?php echo form_input(array('name' => 'address_1', 'id' => 'address_1', 'value' => $person_info->address_1)); ?>
            </div>
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_address_2'); ?></label>
                <?php echo form_input(array('name' => 'address_2', 'id' => 'address_2', 'value' => $person_info->address_2)); ?>
            </div>
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_city'); ?></label>
                <?php echo form_input(array('name' => 'city', 'id' => 'city', 'value' => $person_info->city)); ?>
            </div>
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_state'); ?></label>
                <?php echo form_input(array('name' => 'state', 'id' => 'state', 'value' => $person_info->state)); ?>
            </div>
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_zip'); ?></label>
                <?php echo form_input(array('name' => 'zip', 'id' => 'zip', 'value' => $person_info->zip)); ?>
            </div>
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_country'); ?></label>
                <?php echo form_input(array('name' => 'country', 'id' => 'country', 'value' => $person_info->country)); ?>
            </div>
        </div>
        <div class="sup_grid full" style="margin-top:12px;">
            <div class="sup_group">
                <label><?php echo $this->lang->line('common_comments'); ?></label>
                <?php echo form_textarea(array('name' => 'comments', 'id' => 'comments', 'rows' => 3, 'cols' => 17, 'value' => $person_info->comments)); ?>
            </div>
        </div>

        <button type="submit" class="sup_submit_btn" style="margin-top:20px;">
            💾 <?php echo $this->lang->line('common_submit'); ?>
        </button>
    </div>

</div>

<?php echo form_close(); ?>

<script type='text/javascript'>
    $(document).ready(function() {
        $('#supplier_form').validate({
            submitHandler: function(form) {
                $(form).ajaxSubmit({
                    success: function(response) {
                        tb_remove();
                        post_person_form_submit(response);
                    },
                    dataType: 'json'
                });
            },
            errorLabelContainer: "#error_message_box",
            wrapper: "li",
            rules: {
                company_name: "required",
                first_name: "required",
                last_name: "required",
                email: "email"
            },
            messages: {
                company_name: "<?php echo $this->lang->line('suppliers_company_name_required'); ?>",
                last_name: "<?php echo $this->lang->line('common_last_name_required'); ?>",
                email: "<?php echo $this->lang->line('common_email_invalid_format'); ?>"
            },
            showErrors: function(errorMap, errorList) {
                $('#error_message_box').show();
                this.defaultShowErrors();
            }
        });
    });
</script>