@extends('layouts.app')

@section('title', $country->name)

@section('content')
    @include('layouts.partials.page_header', [
        'title' => $country->name,
        'breadcrumbs' => [
            ['label' => 'Home', 'url' => route('home')],
            ['label' => 'Countries', 'url' => route('countries.index')],
            ['label' => $country->name, '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">{{ $country->code }}</span>
                            </div>
                            <h2 class="section-title__title title-animation">{{ $country->name }}</h2>
                        </div>

                        <p class="about-one__text">{{ $country->description ?? 'Explore study opportunities, universities, scholarships, and admission guidance for this destination.' }}</p>

                        <div class="row g-4 mb-4">
                            <div class="col-md-4">
                                <div class="courses-two__single">
                                    <div class="courses-two__content text-center">
                                        <div class="courses-two__doller"><p>{{ $country->universities_count ?? 0 }}</p></div>
                                        <p class="courses-two__text">Universities</p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="courses-two__single">
                                    <div class="courses-two__content text-center">
                                        <div class="courses-two__doller"><p>{{ $country->scholarships_count ?? 0 }}</p></div>
                                        <p class="courses-two__text">Scholarships</p>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="courses-two__single">
                                    <div class="courses-two__content text-center">
                                        <div class="courses-two__doller"><p>{{ $country->admission_guides_count ?? 0 }}</p></div>
                                        <p class="courses-two__text">Guides</p>
                                    </div>
                                </div>
                            </div>
                        </div>

                        @if($country->is_popular)
                            <div class="course-grid__discount course-grid__single mb-4">
                                <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">Popular Destination</h4>
                                <p class="course-grid__discount-text">This country is one of the most searched destinations in our network.</p>
                                <div class="course-grid__discount-coupon">
                                    <a href="{{ route('universities.index', ['country' => $country->id]) }}" class="thm-btn">Browse Universities</a>
                                </div>
                            </div>
                        @endif
                    </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">Country Profile</h3>
                                    <div class="course-grid__title-shape-1">
                                        <img src="{{ asset('images/shapes/course-grid-title-shape-1.png') }}" alt="">
                                    </div>
                                </div>
                                <div class="text-center mb-3">
                                    @if($country->flag_path)
                                        <img src="{{ asset('storage/'.$country->flag_path) }}" alt="{{ $country->name }}" style="max-height: 84px;">
                                    @else
                                        <div class="mx-auto d-flex align-items-center justify-content-center rounded-circle bg-light" style="width: 84px; height: 84px;">{{ strtoupper(substr($country->name, 0, 2)) }}</div>
                                    @endif
                                </div>
                                <ul class="list-unstyled course-grid__list-item">
                                    <li>Code: {{ $country->code }}</li>
                                    <li>Status: {{ $country->is_active ? 'Active' : 'Inactive' }}</li>
                                    <li>Popular: {{ $country->is_popular ? 'Yes' : 'No' }}</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 Choosing?</h4>
                                <p class="course-grid__discount-text">We can recommend universities and scholarships in this destination.</p>
                                <div class="course-grid__discount-coupon">
                                    <a href="{{ route('contact') }}" class="thm-btn">Contact Us</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            @if($country->universities->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">Universities</span>
                        </div>
                        <h2 class="section-title__title title-animation">Top institutions in {{ $country->name }}</h2>
                    </div>

                    <div class="row">
                        @foreach($country->universities as $university)
                            <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>#{{ $university->ranking ?? 'N/A' }}</p>
                                            </div>
                                            <div class="courses-two__review">
                                                <p>{{ $university->programs_count ?? 0 }} Programs</p>
                                            </div>
                                        </div>
                                        <h3 class="courses-two__title">
                                            <a href="{{ route('universities.show', $university->slug ?? $university->id) }}">{{ $university->name }}</a>
                                        </h3>
                                        <p class="courses-two__text">{{ \Illuminate\Support\Str::limit($university->description ?? 'University profile and admission options.', 120) }}</p>
                                        <div class="courses-two__btn-box mt-3">
                                            <a href="{{ route('universities.show', $university->slug ?? $university->id) }}" class="thm-btn-two">
                                                <span>View University</span>
                                                <i class="icon-angles-right"></i>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    </div>
                </section>
            @endif

            @if($country->scholarships->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">Scholarships</span>
                        </div>
                        <h2 class="section-title__title title-animation">Funding opportunities in {{ $country->name }}</h2>
                    </div>

                    <div class="row">
                        @foreach($country->scholarships as $scholarship)
                            <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>{{ $scholarship->is_fully_funded ? 'Fully Funded' : '$'.number_format((float) $scholarship->amount) }}</p>
                                            </div>
                                            <div class="courses-two__review">
                                                <p>{{ ucfirst($scholarship->program_level) }}</p>
                                            </div>
                                        </div>
                                        <h3 class="courses-two__title">
                                            <a href="{{ route('scholarships.show', $scholarship->slug) }}">{{ $scholarship->title }}</a>
                                        </h3>
                                        <p class="courses-two__text">{{ \Illuminate\Support\Str::limit($scholarship->meta_description ?? $scholarship->description, 120) }}</p>
                                        <div class="courses-two__btn-box mt-3">
                                            <a href="{{ route('scholarships.show', $scholarship->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
