<?php $asset = $asset ?? []; ?>
<div class="enterprise-settings-fields">
    <div class="enterprise-field">
        <label class="enterprise-field-label">Asset Tag</label>
        <input type="text" name="asset_tag" class="form-control text-uppercase" maxlength="50"
               value="<?= esc(old('asset_tag', $asset['asset_tag'] ?? '')) ?>"
               placeholder="Leave blank to auto-generate">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Name <span class="text-danger">*</span></label>
        <input type="text" name="name" class="form-control" maxlength="200" value="<?= esc(old('name', $asset['name'] ?? '')) ?>" required>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Linked Product</label>
        <select name="product_id" class="form-select">
            <option value="">None</option>
            <?php foreach ($products as $p): ?>
                <option value="<?= (int) $p['id'] ?>" <?= (string) old('product_id', $asset['product_id'] ?? '') === (string) $p['id'] ? 'selected' : '' ?>>
                    <?= esc($p['name']) ?> (<?= esc($p['sku']) ?>)
                </option>
            <?php endforeach; ?>
        </select>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Category</label>
        <input type="text" name="category" class="form-control" maxlength="100" value="<?= esc(old('category', $asset['category'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Location</label>
        <input type="text" name="location" class="form-control" maxlength="150" value="<?= esc(old('location', $asset['location'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Serial Number</label>
        <input type="text" name="serial_number" class="form-control" maxlength="100" value="<?= esc(old('serial_number', $asset['serial_number'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Purchase Date</label>
        <input type="date" name="purchase_date" class="form-control" value="<?= esc(old('purchase_date', $asset['purchase_date'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Purchase Cost</label>
        <input type="number" step="0.01" min="0" name="purchase_cost" class="form-control" value="<?= esc(old('purchase_cost', $asset['purchase_cost'] ?? '0')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Status <span class="text-danger">*</span></label>
        <select name="status" class="form-select" required>
            <?php foreach (['active', 'in_repair', 'disposed', 'lost'] as $s): ?>
                <option value="<?= $s ?>" <?= old('status', $asset['status'] ?? 'active') === $s ? 'selected' : '' ?>><?= ucwords(str_replace('_', ' ', $s)) ?></option>
            <?php endforeach; ?>
        </select>
    </div>
    <div class="enterprise-field enterprise-field--full">
        <label class="enterprise-field-label">Notes</label>
        <textarea name="notes" class="form-control" rows="3"><?= esc(old('notes', $asset['notes'] ?? '')) ?></textarea>
    </div>
</div>
