<?php $template = $template ?? []; ?>
<div class="enterprise-settings-fields">
    <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', $template['name'] ?? '')) ?>" required>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Code</label>
        <input type="text" name="code" class="form-control text-uppercase" maxlength="30" value="<?= esc(old('code', $template['code'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Subject</label>
        <input type="text" name="subject" class="form-control" value="<?= esc(old('subject', $template['subject'] ?? '')) ?>">
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Default Validity Days</label>
        <input type="number" name="default_validity_days" class="form-control" min="1"
               value="<?= esc(old('default_validity_days', $template['default_validity_days'] ?? '30')) ?>">
    </div>
    <div class="enterprise-field" style="grid-column: 1 / -1;">
        <label class="enterprise-field-label">Intro Text</label>
        <textarea name="intro_text" class="form-control" rows="3"><?= esc(old('intro_text', $template['intro_text'] ?? '')) ?></textarea>
    </div>
    <div class="enterprise-field" style="grid-column: 1 / -1;">
        <label class="enterprise-field-label">Terms Text</label>
        <textarea name="terms_text" class="form-control" rows="3"><?= esc(old('terms_text', $template['terms_text'] ?? '')) ?></textarea>
    </div>
    <div class="enterprise-field" style="grid-column: 1 / -1;">
        <label class="enterprise-field-label">Notes</label>
        <textarea name="notes" class="form-control" rows="2"><?= esc(old('notes', $template['notes'] ?? '')) ?></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', $template['status'] ?? 'active') === $s ? 'selected' : '' ?>><?= ucfirst($s) ?></option>
            <?php endforeach; ?>
        </select>
    </div>
</div>
