<div class="row justify-content-center">
<div class="col-12">
<div class="card-box">

    <div class="card-box-header">
        <h5>
            <i class="fa-solid fa-user-plus" style="color:#7c3aed;"></i>
            <?php if(!empty($customerdata)) echo 'Edit Customer'; else echo 'Add New Customer'; ?>
        </h5>
        <a href="<?php echo site_url('customer'); ?>" class="btn btn-sm" style="background:#f1f5f9;color:#374151;">
            <i class="fa-solid fa-arrow-left me-1"></i> Back
        </a>
    </div>

    <form method="post" id="Form">

        <input type="hidden" name="id" id="id" value="<?php if(!empty($customerdata)) echo $customerdata[0]->id; ?>">

        <div class="form-row row g-3">

            <div class="col-md-6">
                <label class="form-label">Customer Name <span class="required-star">*</span></label>
                <div class="input-group">
                    <input type="text" name="customer_name" id="customer_name" class="form-control"
                           value="<?php if(!empty($customerdata)) echo $customerdata[0]->customer_name; ?>"
                           placeholder="Full Name" autofocus>
                </div>
            </div>

            <div class="col-md-2">
                <label class="form-label">Status</label>
    <select name="status" id="status" class="form-select select2 select2-no-search">
        <!--<option value="">-- Select Status --</option>-->
        <option value="1" <?php if(!empty($customerdata) && $customerdata[0]->status == 1) echo 'selected'; ?>>Active</option>
        <option value="0" <?php if(!empty($customerdata) && $customerdata[0]->status == 0) echo 'selected'; ?>>Inactive</option>
    </select>
            </div>

            <div class="col-md-4">
                <label class="form-label">Mobile <span class="required-star">*</span></label>
                <div class="input-group">
                    <span class="input-group-text"><i class="fa-solid fa-phone"></i></span>
                    <input type="tel" name="mobile" id="mobile" class="form-control"
                           value="<?php if(!empty($customerdata)) echo $customerdata[0]->mobile; ?>"
                           placeholder="10-digit mobile"
                           onKeyPress="if(this.value.length==10) return false;">
                </div>
                <span id="mobileerror" style="color:red;"></span>
            </div>

            <div class="col-md-4">
                <label class="form-label">Email</label>
                <div class="input-group">
                    <span class="input-group-text"><i class="fa-solid fa-envelope"></i></span>
                    <input type="email" name="email" id="email" class="form-control"
                           value="<?php if(!empty($customerdata)) echo $customerdata[0]->email; ?>"
                           placeholder="email@example.com">
                </div>
            </div>

            <div class="col-md-2">
                <label class="form-label">GST No</label>
                <div class="input-group">
                    <input type="text" name="gst_no" id="gst_no" class="form-control"
                           value="<?php if(!empty($customerdata)) echo $customerdata[0]->gst_no; ?>"
                           placeholder="e.g. 27AAAAA0000A1Z5"
                           style="text-transform:uppercase;" maxlength="15">
                </div>
            </div>

            <div class="col-12">
                <label class="form-label">Address</label>
                <textarea name="address" id="address" class="form-control" rows="3"
                          placeholder="Full address..."><?php if(!empty($customerdata)) echo $customerdata[0]->address; ?></textarea>
            </div>

        </div>

        <div class="d-flex gap-2 mt-4">
            <button type="button" id="btn_savee" class="btn btn-primary px-4">
                <i class="fa-solid fa-floppy-disk me-1"></i> Save
            </button>
            <a href="<?php echo site_url('customer'); ?>" class="btn" style="background:#f1f5f9;color:#374151;">Cancel</a>
        </div>

    </form>
</div>
</div>
</div>