@extends('layouts.app')

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

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

                        <p class="about-one__text">{{ $exam->short_description ?? 'Exam overview and preparation details.' }}</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>{{ $exam->fee ? '$'.number_format((float) $exam->fee) : 'No fee listed' }}</p>
                                    </div>
                                    <div class="courses-two__review">
                                        <p>{{ ucfirst($exam->type) }}</p>
                                    </div>
                                </div>
                                <ul class="courses-two__meta list-unstyled">
                                    <li>
                                        <div class="icon"><span class="icon-clock"></span></div>
                                        <p>{{ $exam->duration ? $exam->duration.' min' : 'Flexible' }}</p>
                                    </li>
                                    <li>
                                        <div class="icon"><span class="icon-book"></span></div>
                                        <p>{{ $exam->validity_months ? $exam->validity_months.' months valid' : 'No expiry' }}</p>
                                    </li>
                                    <li>
                                        <div class="icon"><span class="icon-comment"></span></div>
                                        <p>{{ $exam->views }} views</p>
                                    </li>
                                </ul>
                            </div>
                        </div>

                        <div class="blog-details__text-content">
                            <h3 class="blog-details__title-1">Full Description</h3>
                            <p>{!! nl2br(e($exam->full_description ?? $exam->short_description ?? '')) !!}</p>
                        </div>

                        @if($exam->sections)
                            <div class="course-grid__categories course-grid__single mt-4">
                                <div class="course-grid__title-box">
                                    <h3 class="course-grid__title">Sections</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($exam->sections as $section)
                                        <span class="badge bg-light text-dark border px-3 py-2">{{ $section }}</span>
                                    @endforeach
                                </div>
                            </div>
                        @endif

                        <div class="d-flex flex-wrap gap-3 mt-4">
                            @if($exam->website_url)
                                <a href="{{ $exam->website_url }}" target="_blank" rel="noopener" class="thm-btn">
                                    <span class="icon-angles-right"></span> Official Website
                                </a>
                            @endif
                            @if($exam->registration_url)
                                <a href="{{ $exam->registration_url }}" target="_blank" rel="noopener" class="thm-btn-two">
                                    <span>Register</span>
                                    <i class="icon-angles-right"></i>
                                </a>
                            @endif
                            @if($exam->sample_paper_url)
                                <a href="{{ $exam->sample_paper_url }}" target="_blank" rel="noopener" class="thm-btn-two">
                                    <span>Sample Paper</span>
                                    <i class="icon-angles-right"></i>
                                </a>
                            @endif
                        </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">Key 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>Type: {{ ucfirst($exam->type) }}</li>
                                    <li>Code: {{ $exam->code }}</li>
                                    <li>Passing Score: {{ $exam->passing_score ?? 'N/A' }}</li>
                                    <li>Total Score: {{ $exam->total_score ?? 'N/A' }}</li>
                                    <li>Popular: {{ $exam->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 Prep Help?</h4>
                                <p class="course-grid__discount-text">We can guide you toward universities and scholarships that accept this exam.</p>
                                <div class="course-grid__discount-coupon">
                                    <a href="{{ route('contact') }}" class="thm-btn">Contact Us</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 Exams</span>
                        </div>
                        <h2 class="section-title__title title-animation">Other exams you may need</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->code }}</p>
                                            </div>
                                            <div class="courses-two__review">
                                                <p>{{ ucfirst($item->type) }}</p>
                                            </div>
                                        </div>
                                        <h3 class="courses-two__title">
                                            <a href="{{ route('exams.show', $item->slug) }}">{{ $item->name }}</a>
                                        </h3>
                                        <p class="courses-two__text">{{ \Illuminate\Support\Str::limit($item->short_description ?? '', 110) }}</p>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    </div>
                </section>
            @endif
        </div>
    </section>
@endsection
