<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>

<?= view('bookings/_wizard_steps', ['step' => 1]) ?>

<div class="row justify-content-center">
    <div class="col-lg-7">
        <div class="card">
            <div class="card-header d-flex align-items-center gap-2">
                <i class="bi bi-search" style="color: var(--brand);"></i> Search Availability
            </div>
            <div class="card-body">
                <p class="text-muted small mb-4">Pick your dates (and optionally a room type) to see which rooms are free to book.</p>

                <form action="<?= site_url('bookings/search') ?>" method="get">
                    <div class="row g-3 mb-1">
                        <div class="col-md-6">
                            <label class="form-label small fw-semibold" for="check_in">Check-in</label>
                            <div class="input-group icon-input-group">
                                <span class="input-group-text"><i class="bi bi-calendar-event"></i></span>
                                <input type="date" class="form-control" id="check_in" name="check_in" value="<?= esc($checkIn) ?>" required>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label small fw-semibold" for="check_out">Check-out</label>
                            <div class="input-group icon-input-group">
                                <span class="input-group-text"><i class="bi bi-calendar-check"></i></span>
                                <input type="date" class="form-control" id="check_out" name="check_out" value="<?= esc($checkOut) ?>" required>
                            </div>
                        </div>
                    </div>

                    <div class="mb-4 mt-3">
                        <label class="form-label small fw-semibold" for="room_type_id">Room Type <span class="text-muted fw-normal">(optional)</span></label>
                        <div class="input-group icon-input-group">
                            <span class="input-group-text"><i class="bi bi-door-closed"></i></span>
                            <select class="form-select" id="room_type_id" name="room_type_id">
                                <option value="">Any room type</option>
                                <?php foreach ($roomTypes as $type): ?>
                                    <option value="<?= $type->id ?>"><?= esc($type->name) ?> — <?= format_money($type->base_rate) ?>/night</option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                    </div>

                    <button type="submit" class="btn btn-primary"><i class="bi bi-search me-1"></i>Search Available Rooms</button>
                </form>
            </div>
        </div>
    </div>
</div>

<?= $this->endSection() ?>
