<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>
<div class="page-header"><div><h1><i class="bi bi-plus-circle me-2 text-primary"></i>Add Facility</h1></div></div>
<?= form_open(base_url('facilities/store')) ?>
<div class="row g-3"><div class="col-lg-8"><div class="fm-form-section"><h6>Facility Information</h6><div class="row g-3">
<div class="col-md-8"><label class="form-label">Facility Name *</label><input type="text" name="name" class="form-control" value="<?= old('name') ?>" required></div>
<div class="col-md-4"><label class="form-label">Code</label><input type="text" name="code" class="form-control" value="<?= old('code') ?>" placeholder="Auto-generated"></div>
<div class="col-12"><label class="form-label">Address</label><input type="text" name="address" class="form-control" value="<?= old('address') ?>"></div>
<div class="col-md-6"><label class="form-label">City *</label><input type="text" name="city" class="form-control" value="<?= old('city','Doha') ?>" required></div>
<div class="col-md-6"><label class="form-label">Country</label><input type="text" name="country" class="form-control" value="<?= old('country','Qatar') ?>"></div>
<div class="col-md-6"><label class="form-label">Facility Manager</label><select name="manager_id" class="form-select"><option value="">— None —</option><?php foreach($managers as $m): ?><option value="<?= $m['id'] ?>"><?= esc($m['name']) ?></option><?php endforeach; ?></select></div>
<div class="col-md-3"><label class="form-label">Area (sqm)</label><input type="number" name="area_sqm" step="0.01" class="form-control" value="<?= old('area_sqm') ?>"></div>
<div class="col-md-3"><label class="form-label">Floors</label><input type="number" name="floors" class="form-control" value="<?= old('floors',1) ?>"></div>
<div class="col-md-6"><label class="form-label">Latitude</label><input type="number" name="latitude" step="0.000001" class="form-control" value="<?= old('latitude') ?>"></div>
<div class="col-md-6"><label class="form-label">Longitude</label><input type="number" name="longitude" step="0.000001" class="form-control" value="<?= old('longitude') ?>"></div>
</div></div></div>
<div class="col-lg-4"><div class="fm-form-section"><h6>Actions</h6><button type="submit" class="btn btn-fm-primary w-100 mb-2">Add Facility</button><a href="<?= base_url('facilities') ?>" class="btn btn-fm-outline w-100">Cancel</a></div></div></div>
<?= form_close() ?>
<?= $this->endSection() ?>
