<?php $stage = $stage ?? []; ?>
<div class="enterprise-settings-fields enterprise-settings-fields--single">
    <div class="enterprise-field">
        <label class="enterprise-field-label">Name <span class="text-danger">*</span></label>
        <input type="text" name="name" class="form-control" value="<?= esc(old('name', $stage['name'] ?? '')) ?>" required>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Code <span class="text-danger">*</span></label>
        <input type="text" name="code" class="form-control text-uppercase" maxlength="20" value="<?= esc(old('code', $stage['code'] ?? '')) ?>" required>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Sort Order</label>
        <input type="number" name="sort_order" class="form-control" value="<?= esc(old('sort_order', $stage['sort_order'] ?? '0')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Default Probability (%)</label>
        <input type="number" name="default_probability" class="form-control" min="0" max="100"
               value="<?= esc(old('default_probability', $stage['default_probability'] ?? '0')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Flags</label>
        <div class="d-flex gap-3 pt-1">
            <label class="form-check-label">
                <input type="checkbox" name="is_won" value="1" class="form-check-input"
                    <?= old('is_won', $stage['is_won'] ?? 0) ? 'checked' : '' ?>> Won stage
            </label>
            <label class="form-check-label">
                <input type="checkbox" name="is_lost" value="1" class="form-check-input"
                    <?= old('is_lost', $stage['is_lost'] ?? 0) ? 'checked' : '' ?>> Lost stage
            </label>
        </div>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Description</label>
        <textarea name="description" class="form-control" rows="3"><?= esc(old('description', $stage['description'] ?? '')) ?></textarea>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Status</label>
        <select name="status" class="form-select">
            <?php foreach (['active', 'inactive'] as $s): ?>
                <option value="<?= $s ?>" <?= old('status', $stage['status'] ?? 'active') === $s ? 'selected' : '' ?>><?= ucfirst($s) ?></option>
            <?php endforeach; ?>
        </select>
    </div>
</div>
