@extends('layouts.app')

@section('title', $scholarship->title)

@section('content')
    @include('layouts.partials.page_header', [
        'title' => $scholarship->title,
        'breadcrumbs' => [
            ['label' => 'Home', 'url' => route('home')],
            ['label' => 'Scholarships', 'url' => route('scholarships.index')],
            ['label' => $scholarship->title, 'url' => ''],
        ]
    ])

    <section class="about-one" style="padding: 80px 0 40px;">
        <div class="container">
            <div class="row">
                <div class="col-xl-8">
                    <div class="about-one__right">
                        <div class="section-title text-left sec-title-animation animation-style2">
                            <div class="section-title__tagline-box">
                                <div class="section-title__tagline-shape"></div>
                                <span class="section-title__tagline">{{ $scholarship->scholarship_type ?? ucfirst($scholarship->program_level) }}</span>
                            </div>
                            <h2 class="section-title__title title-animation">{{ $scholarship->title }}</h2>
                        </div>

                        <p class="about-one__text">
                            {{ $scholarship->meta_description ?? 'Scholarship support for students looking to study at a partner university.' }}
                        </p>

                        <div class="courses-two__single mb-4">
                            <div class="courses-two__content">
                                <div class="courses-two__doller-and-review">
                                    <div class="courses-two__doller">
                                        <p>{{ $scholarship->is_fully_funded ? 'Fully Funded' : '$'.number_format((float) $scholarship->amount) }}</p>
                                    </div>
                                    <div class="courses-two__review">
                                        <p><i class="icon-star"></i> {{ ucfirst($scholarship->program_level) }}</p>
                                    </div>
                                </div>

                                <ul class="courses-two__meta list-unstyled">
                                    <li>
                                        <div class="icon"><span class="icon-book"></span></div>
                                        <p>{{ $scholarship->country->name ?? 'Country' }}</p>
                                    </li>
                                    <li>
                                        <div class="icon"><span class="icon-clock"></span></div>
                                        <p>{{ $scholarship->deadline?->format('M d, Y') }}</p>
                                    </li>
                                    <li>
                                        <div class="icon"><span class="icon-chart-simple"></span></div>
                                        <p>{{ $scholarship->scholarship_type ?? 'Scholarship' }}</p>
                                    </li>
                                </ul>
                            </div>
                        </div>

                        <div class="blog-details__text-content">
                            <h3 class="blog-details__title-1">About this scholarship</h3>
                            <p>{!! nl2br(e($scholarship->description)) !!}</p>
                        </div>

                        <div class="blog-details__text-content mt-4">
                            <h3 class="blog-details__title-1">Eligibility</h3>
                            <p>{!! nl2br(e($scholarship->eligibility)) !!}</p>
                        </div>

                        @if($scholarship->exams->count())
                            <div class="course-grid__categories course-grid__single mt-4">
                                <div class="course-grid__title-box">
                                    <h3 class="course-grid__title">Required Exams</h3>
                                    <div class="course-grid__title-shape-1">
                                        <img src="{{ asset('images/shapes/course-grid-title-shape-1.png') }}" alt="">
                                    </div>
                                </div>
                                <div class="d-flex flex-wrap gap-2">
                                    @foreach($scholarship->exams as $exam)
                                        <span class="badge bg-light text-dark border px-3 py-2">
                                            {{ $exam->name }}@if($exam->pivot?->minimum_score) - Min {{ $exam->pivot->minimum_score }}@endif
                                        </span>
                                    @endforeach
                                </div>
                            </div>
                        @endif

                        @if($scholarship->university)
                            <div class="courses-two__single mt-4">
                                <div class="courses-two__content">
                                    <div class="courses-two__doller-and-review">
                                        <div class="courses-two__doller">
                                            <p>{{ $scholarship->university->name }}</p>
                                        </div>
                                        <div class="courses-two__review">
                                            <p>{{ $scholarship->university->country->name ?? 'University' }}</p>
                                        </div>
                                    </div>
                                    <p class="courses-two__text">
                                        {{ \Illuminate\Support\Str::limit($scholarship->university->description ?? 'Partner university profile and program options.', 180) }}
                                    </p>
                                    <div class="courses-two__btn-box mt-3">
                                        <a href="{{ route('universities.show', $scholarship->university->slug ?? $scholarship->university->id) }}" class="thm-btn-two">
                                            <span>View University</span>
                                            <i class="icon-angles-right"></i>
                                        </a>
                                    </div>
                                </div>
                            </div>
                        @endif

                        <div class="d-flex flex-wrap gap-3 mt-4">
                            @auth
                                @if(auth()->user()->isStudent() && $applicationProgram)
                                    <a href="{{ route('portal.apply', ['program' => $applicationProgram->id]) }}" class="thm-btn">
                                        <span class="icon-angles-right"></span> Apply With This University
                                    </a>
                                @else
                                    <a href="{{ route('contact') }}" class="thm-btn">
                                        <span class="icon-angles-right"></span> Book Consultation
                                    </a>
                                @endif
                            @else
                                <a href="{{ route('login') }}" class="thm-btn">
                                    <span class="icon-angles-right"></span> Login to Apply
                                </a>
                            @endauth
                            <a href="{{ route('scholarships.index') }}" class="thm-btn-two">
                                <span>Back to Scholarships</span>
                                <i class="icon-angles-right"></i>
                            </a>
                        </div>
                    </div>
                </div>

                <div class="col-xl-4">
                    <div class="course-grid__left">
                        <div class="course-grid__sidebar">
                            <div class="course-grid__search course-grid__single">
                                <div class="course-grid__title-box">
                                    <h3 class="course-grid__title">Quick Facts</h3>
                                    <div class="course-grid__title-shape-1">
                                        <img src="{{ asset('images/shapes/course-grid-title-shape-1.png') }}" alt="">
                                    </div>
                                </div>
                                <ul class="list-unstyled course-grid__list-item">
                                    <li>Deadline: {{ $scholarship->deadline?->format('M d, Y') }}</li>
                                    <li>Level: {{ ucfirst($scholarship->program_level) }}</li>
                                    <li>Status: {{ ucfirst($scholarship->status) }}</li>
                                    <li>Funding: {{ $scholarship->is_fully_funded ? 'Fully funded' : '$'.number_format((float) $scholarship->amount) }}</li>
                                </ul>
                            </div>

                            <div class="course-grid__discount course-grid__single">
                                <div class="course-grid__discount-shape-bg" style="background-image: url({{ asset('images/shapes/course-grid-discount-shape-bg.png') }});"></div>
                                <h4 class="course-grid__discount-title">Need Help Applying?</h4>
                                <p class="course-grid__discount-text">We can help with eligibility, documents, and university selection.</p>
                                <div class="course-grid__discount-img">
                                    <img src="{{ asset('images/resources/course-grid-discount-img-1.png') }}" alt="">
                                </div>
                                <div class="course-grid__discount-coupon">
                                    <a href="{{ route('contact') }}" class="thm-btn">Talk to an Advisor</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            @if($related->count())
                <section class="courses-one mt-5" style="padding-top: 0;">
                    <div class="section-title text-center sec-title-animation animation-style1">
                        <div class="section-title__tagline-box">
                            <div class="section-title__tagline-shape"></div>
                            <span class="section-title__tagline">Related Scholarships</span>
                        </div>
                        <h2 class="section-title__title title-animation">More funding options</h2>
                    </div>

                    <div class="row">
                        @foreach($related as $item)
                            <div class="col-xl-4 col-md-6">
                                <div class="courses-two__single">
                                    <div class="courses-two__content">
                                        <div class="courses-two__doller-and-review">
                                            <div class="courses-two__doller">
                                                <p>{{ $item->is_fully_funded ? 'Fully Funded' : '$'.number_format((float) $item->amount) }}</p>
                                            </div>
                                            <div class="courses-two__review">
                                                <p>{{ ucfirst($item->program_level) }}</p>
                                            </div>
                                        </div>
                                        <h3 class="courses-two__title">
                                            <a href="{{ route('scholarships.show', $item->slug) }}">{{ $item->title }}</a>
                                        </h3>
                                        <p class="courses-two__text">{{ \Illuminate\Support\Str::limit($item->meta_description ?? $item->description, 120) }}</p>
                                        <div class="courses-two__btn-box mt-3">
                                            <a href="{{ route('scholarships.show', $item->slug) }}" class="thm-btn-two">
                                                <span>View Scholarship</span>
                                                <i class="icon-angles-right"></i>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    </div>
                </section>
            @endif
        </div>
    </section>
@endsection
