<div class="page-title mb-4">
    <h5><i class="fas fa-truck-plus me-2 text-gold"></i>Add New Supplier</h5>
</div>

<div class="glass-card p-0">
    <div class="card-header">
        <div class="card-header-left">
            <i class="fas fa-truck card-icon"></i>
            <h6 class="card-title">Supplier Information</h6>
        </div>
        <div>
            <span class="text-muted small"><span class="text-danger">*</span> Required fields</span>
        </div>
    </div>
    <div class="card-body">
        <form method="POST" action="<?= url('suppliers/store') ?>">
            <?= csrf_field() ?>

            <div class="row g-3">
                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Company Name <span class="text-danger">*</span></label>
                        <input type="text" name="name" class="form-control bg-transparent <?= errorClass('name') ?>"
                               value="<?= e(old('name')) ?>" required maxlength="255">
                        <?= errorMsg('name') ?>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Contact Person</label>
                        <input type="text" name="contact_person" class="form-control bg-transparent <?= errorClass('contact_person') ?>"
                               value="<?= e(old('contact_person')) ?>" maxlength="255">
                        <?= errorMsg('contact_person') ?>
                    </div>
                </div>
            </div>

            <div class="row g-3">
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Email</label>
                        <input type="email" name="email" class="form-control bg-transparent <?= errorClass('email') ?>"
                               value="<?= e(old('email')) ?>" maxlength="255">
                        <?= errorMsg('email') ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Phone</label>
                        <input type="text" name="phone" class="form-control bg-transparent <?= errorClass('phone') ?>"
                               value="<?= e(old('phone')) ?>" maxlength="20">
                        <?= errorMsg('phone') ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Mobile</label>
                        <input type="text" name="mobile" class="form-control bg-transparent <?= errorClass('mobile') ?>"
                               value="<?= e(old('mobile')) ?>" maxlength="20">
                        <?= errorMsg('mobile') ?>
                    </div>
                </div>
            </div>

            <div class="row g-3">
                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Address</label>
                        <textarea name="address" class="form-control bg-transparent <?= errorClass('address') ?>"
                                  rows="2" maxlength="500"><?= e(old('address')) ?></textarea>
                        <?= errorMsg('address') ?>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">City</label>
                        <input type="text" name="city" class="form-control bg-transparent <?= errorClass('city') ?>"
                               value="<?= e(old('city')) ?>" maxlength="100">
                        <?= errorMsg('city') ?>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="mb-3">
                        <label class="form-label">State</label>
                        <input type="text" name="state" class="form-control bg-transparent <?= errorClass('state') ?>"
                               value="<?= e(old('state')) ?>" maxlength="100">
                        <?= errorMsg('state') ?>
                    </div>
                </div>
            </div>

            <div class="row g-3">
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Tax ID</label>
                        <input type="text" name="tax_id" class="form-control bg-transparent <?= errorClass('tax_id') ?>"
                               value="<?= e(old('tax_id')) ?>" maxlength="100">
                        <?= errorMsg('tax_id') ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <label class="form-label">Payment Terms</label>
                        <select name="payment_terms" class="form-select bg-transparent <?= errorClass('payment_terms') ?>">
                            <option value="">Select Terms</option>
                            <option value="immediate" <?= old('payment_terms') === 'immediate' ? 'selected' : '' ?>>Immediate</option>
                            <option value="net_15" <?= old('payment_terms') === 'net_15' ? 'selected' : '' ?>>Net 15</option>
                            <option value="net_30" <?= old('payment_terms') === 'net_30' ? 'selected' : '' ?>>Net 30</option>
                            <option value="net_45" <?= old('payment_terms') === 'net_45' ? 'selected' : '' ?>>Net 45</option>
                            <option value="net_60" <?= old('payment_terms') === 'net_60' ? 'selected' : '' ?>>Net 60</option>
                            <option value="cod" <?= old('payment_terms') === 'cod' ? 'selected' : '' ?>>Cash on Delivery</option>
                            <option value="advance" <?= old('payment_terms') === 'advance' ? 'selected' : '' ?>>Advance Payment</option>
                        </select>
                        <?= errorMsg('payment_terms') ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="mb-3">
                        <div class="form-check mt-4">
                            <input type="checkbox" name="is_active" class="form-check-input" value="1"
                                   id="is_active" <?= old('is_active', '1') == '1' ? 'checked' : '' ?>>
                            <label class="form-check-label" for="is_active">Active</label>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row g-3">
                <div class="col-md-12">
                    <div class="mb-3">
                        <label class="form-label">Notes</label>
                        <textarea name="notes" class="form-control bg-transparent <?= errorClass('notes') ?>"
                                  rows="3" maxlength="2000"><?= e(old('notes')) ?></textarea>
                        <?= errorMsg('notes') ?>
                    </div>
                </div>
            </div>

            <div class="mt-4 d-flex gap-2">
                <button type="submit" class="btn btn-gold">
                    <i class="fas fa-save me-1"></i>Save Supplier
                </button>
                <a href="<?= url('suppliers') ?>" class="btn btn-outline-secondary">
                    <i class="fas fa-times me-1"></i>Cancel
                </a>
            </div>
        </form>
    </div>
</div>
