<section class="quick-search-section" id="form-cari" aria-label="Form pencarian cepat kendaraan">
    <div class="container">
        <form class="quick-search-card" action="{{ route('search') }}" method="post">
            @csrf
            <div class="field-group">
                <label for="lokasi">Lokasi</label>
                <select id="lokasi" name="lokasi">
                    <option value="">-- Pilih Lokasi --</option>
                    @foreach($lokasiOptions as $kota)
                        <option value="{{ $kota }}">{{ $kota }}</option>
                    @endforeach
                </select>
            </div>

            <div class="field-group">
                <label for="tanggal-sewa">Tanggal Mulai</label>
                <input type="date" id="tanggal-sewa" name="tanggal_sewa" value="{{ date('Y-m-d') }}" min="{{ date('Y-m-d') }}">
            </div>

            <div class="field-group">
                <label for="tanggal-selesai">Tanggal Selesai</label>
                <input type="date" id="tanggal-selesai" name="tanggal_selesai" value="{{ date('Y-m-d', strtotime('+1 day')) }}" min="{{ date('Y-m-d', strtotime('+1 day')) }}">
            </div>

            <script>
                document.getElementById('tanggal-sewa').addEventListener('change', function () {
                    var mulai = this.value;
                    var selesaiInput = document.getElementById('tanggal-selesai');
                    var nextDay = new Date(mulai);
                    nextDay.setDate(nextDay.getDate() + 1);
                    var minSelesai = nextDay.toISOString().split('T')[0];
                    selesaiInput.min = minSelesai;
                    if (selesaiInput.value <= mulai) {
                        selesaiInput.value = minSelesai;
                    }
                });
            </script>

            <div class="field-group">
                <label for="jenis">Jenis Kendaraan</label>
                <select id="jenis" name="jenis_kendaraan">
                    <option value="">-- Pilih Jenis --</option>
                    @foreach($vehicleCategories as $category)
                        <option value="{{ $category }}">{{ $category }}</option>
                    @endforeach
                </select>
            </div>

            <div class="field-group field-submit">
                <button type="submit" class="btn btn-primary full-width">Cari</button>
            </div>
        </form>
    </div>
</section>
