<?php $site = $site ?? []; ?>
<div class="enterprise-field enterprise-field--full">
    <label class="enterprise-field-label">Destination Site <span class="text-danger">*</span></label>
    <select name="transport_location_id" class="form-select" required>
        <option value="">Select transport location…</option>
        <?php foreach ($locations as $location): ?>
            <option value="<?= (int) $location['id'] ?>"
                <?= (int) old('transport_location_id', $site['transport_location_id'] ?? 0) === (int) $location['id'] ? 'selected' : '' ?>>
                <?= esc($location['name']) ?> (<?= esc(ucfirst($location['location_type'])) ?>)
            </option>
        <?php endforeach; ?>
    </select>
    <div class="form-text">Only locations with map coordinates are listed. Add the work site under Transport → Locations first if missing.</div>
</div>
<div class="enterprise-field enterprise-field--full">
    <label class="enterprise-field-label">Default Shift</label>
    <select name="default_shift_id" class="form-select">
        <option value="">None — use each employee's shift assignment</option>
        <?php foreach ($shifts as $shift): ?>
            <option value="<?= (int) $shift['id'] ?>"
                <?= (int) old('default_shift_id', $site['default_shift_id'] ?? 0) === (int) $shift['id'] ? 'selected' : '' ?>>
                <?= esc($shift['name']) ?> (<?= esc(substr($shift['start_time'], 0, 5)) ?>–<?= esc(substr($shift['end_time'], 0, 5)) ?>)
            </option>
        <?php endforeach; ?>
    </select>
    <div class="form-text">Fallback shift for employees without a personal shift assignment.</div>
</div>
<div class="enterprise-field enterprise-field--full">
    <label class="enterprise-field-label">Status</label>
    <select name="status" class="form-select">
        <?php foreach (['active', 'inactive'] as $s): ?>
            <option value="<?= $s ?>" <?= old('status', $site['status'] ?? 'active') === $s ? 'selected' : '' ?>>
                <?= esc(ucfirst($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="2"><?= esc(old('notes', $site['notes'] ?? '')) ?></textarea>
</div>
