<?php $shift = $shift ?? []; ?>
<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', $shift['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="10" value="<?= esc(old('code', $shift['code'] ?? '')) ?>" required>
    </div>
    <div class="row g-3">
        <div class="col-md-6">
            <div class="enterprise-field">
                <label class="enterprise-field-label">Start Time <span class="text-danger">*</span></label>
                <input type="time" name="start_time" class="form-control" value="<?= esc(old('start_time', isset($shift['start_time']) ? substr($shift['start_time'], 0, 5) : '08:00')) ?>" required>
            </div>
        </div>
        <div class="col-md-6">
            <div class="enterprise-field">
                <label class="enterprise-field-label">End Time <span class="text-danger">*</span></label>
                <input type="time" name="end_time" class="form-control" value="<?= esc(old('end_time', isset($shift['end_time']) ? substr($shift['end_time'], 0, 5) : '17:00')) ?>" required>
            </div>
        </div>
    </div>
    <div class="row g-3">
        <div class="col-md-4">
            <div class="enterprise-field">
                <label class="enterprise-field-label">Late Grace (min)</label>
                <input type="number" name="grace_period_minutes" class="form-control" min="0" value="<?= esc(old('grace_period_minutes', $shift['grace_period_minutes'] ?? 15)) ?>">
            </div>
        </div>
        <div class="col-md-4">
            <div class="enterprise-field">
                <label class="enterprise-field-label">Early Exit Grace (min)</label>
                <input type="number" name="early_exit_grace_minutes" class="form-control" min="0" value="<?= esc(old('early_exit_grace_minutes', $shift['early_exit_grace_minutes'] ?? 0)) ?>">
            </div>
        </div>
        <div class="col-md-4">
            <div class="enterprise-field">
                <label class="enterprise-field-label">OT After (min)</label>
                <input type="number" name="overtime_after_minutes" class="form-control" min="0" value="<?= esc(old('overtime_after_minutes', $shift['overtime_after_minutes'] ?? 30)) ?>">
            </div>
        </div>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Break Duration (min)</label>
        <input type="number" name="break_minutes" class="form-control" min="0" value="<?= esc(old('break_minutes', $shift['break_minutes'] ?? 60)) ?>">
    </div>
    <div class="enterprise-field">
        <div class="form-check">
            <input class="form-check-input" type="checkbox" name="auto_punch" value="1" id="auto_punch"
                <?= old('auto_punch', $shift['auto_punch'] ?? 1) ? 'checked' : '' ?>>
            <label class="form-check-label" for="auto_punch">Enable daily auto-punch for assigned employees</label>
        </div>
        <small class="text-muted">When enabled, the system fills attendance from shift times if no manual punch exists.</small>
    </div>
    <div class="enterprise-field">
        <label class="enterprise-field-label">Description</label>
        <textarea name="description" class="form-control" rows="2"><?= esc(old('description', $shift['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', $shift['status'] ?? 'active') === $s ? 'selected' : '' ?>><?= ucfirst($s) ?></option>
            <?php endforeach; ?>
        </select>
    </div>
</div>
