@extends('pemerintah.main')

@section('content')
    <!-- Page Title -->
    <div class="page-title-area">
        <div class="d-table">
            <div class="d-table-cell">
                <div class="container">
                    <div class="title-item">
                        <h2 class="text-wrap w-100">Program</h2> <!-- Tambahkan w-100 -->
                        <ul>
                            <li>
                                <a>Beranda</a>
                            </li>
                            <li>
                                <i class='bx bx-chevrons-right'></i>
                            </li>
                            <li>
                                <span>Program</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End Page Title -->

    <!-- Services -->
    <section class="service-area two pt-100 pb-70">
        <div class="container">
            <div class="row">

                <!-- Search Bar -->
                <div class="search-bar mb-4">
                    <form action="{{ route('investor.search') }}" method="GET">
                        <div class="input-group">
                            <input type="text" class="form-control" name="search" placeholder="Cari Program..."
                                aria-label="Cari Program" value="{{ request('search') }}">
                            <!-- Menampilkan kembali kata kunci pencarian -->
                            <div class="input-group-append">
                                <button class="btn btn-primary" type="submit">Cari</button>
                            </div>
                        </div>
                    </form>
                </div>



                <!-- Projects Section -->
                <div class="col-md-15">
                    <div class="projects-area bg-white p-4 rounded" style="border: 1px solid #ccc">
                        <div class="section-title">
                            <span class="sub-title">Rekomendasi Program</span>
                            <h2>Berdasarkan Preferensi Masukan Anda</h2>
                        </div>

                        @if (isset($message))
                            <div class="alert alert-warning">
                                {{ $message }}
                            </div>
                        @endif


                        <div class="row" id="projects-container">
                            @if (isset($projects) && $projects->count())
                                @foreach ($projects as $project)
                                    <div class="col-sm-6 col-lg-4 mb-4 project-item"
                                        data-category="{{ $project->category }}">
                                        <div class="service-item"
                                            style="border: 1px solid #ccc; padding: 15px; border-radius: 5px;">
                                            <img src="{{ asset('storage/' . $project->foto_proyek) }}"
                                                class="rounded-circle" alt="{{ $project->judul_project }}"
                                                style="width: 50px; height: 50px; border: 2px solid #007bff; padding: 2px; margin-right: 10px;">
                                            <h3 class="mt-3">
                                                <a>{{ $project->judul_project }}</a>
                                            </h3>
                                            <p>{!! Str::words($project->latar_belakang, 100) !!}</p>
                                            <a class="service-link"
                                                href="{{ $project->kategori === 'Pelatihan'
                                                    ? route('permohonanpelatihan.show', $project->id)
                                                    : ($project->kategori === 'Pendanaan'
                                                        ? route('permohonanpendanaan.show', $project->id)
                                                        : ($project->kategori === 'Riset'
                                                            ? route('permohonanriset.show', $project->id)
                                                            : ($project->kategori === 'Project Investor'
                                                                ? route('permohonanproyek-investor.show', $project->id)
                                                                : '#'))) }}">
                                                Selengkapnya
                                                <i class='bx bx-right-arrow-alt'></i>
                                            </a>


                                        </div>
                                    </div>
                                @endforeach
                            @else
                                <p>Data Rekomendasi tidak ditemukan. Silahkan perbarui preferensi anda di profil</p>
                            @endif
                        </div>

                    </div>
                    @if (isset($projects) && $projects->count())
                        <div class="pagination-wrapper mt-3">
                            {{ $projects->links() }}
                        </div>
                    @endif
                </div>
            </div>
        </div>
    </section>
@endsection
