@extends('layouts.site')
@section('title', $page->meta_title ?: $page->title.' | Trading Corporation of Pakistan')
@section('description', $page->meta_description ?: $page->summary)
@section('content')
<x-page-hero :title="$page->title" :eyebrow="$page->eyebrow" :summary="$page->summary" :parent-label="str($page->slug)->contains('/') ? str($page->slug)->before('/')->replace('-', ' ')->title() : null" />
<div @class(['shell', 'page-layout', 'page-layout--single' => $sectionPages->count() <= 1])>
    @if($sectionPages->count() > 1)<aside class="section-nav"><h2>In this section</h2>@foreach($sectionPages as $item)<a href="{{ url($item->slug) }}" @if($item->is($page)) aria-current="page" @endif>{{ $item->title }}</a>@endforeach</aside>@endif
    <article class="content-area">
        @if(session('success'))<div class="alert success" role="status">{{ session('success') }}</div>@endif
        @if($page->body)<div class="rich-text">{!! $page->body !!}</div>@endif
        <x-content-blocks :blocks="$page->blocks ?? []" />

        @if($documents->isNotEmpty())
            @if($page->slug === 'operations/blacklisting-process')
                @php($procedure = $documents->first())
                <div class="toolbar"><h2>Official procedure</h2><a class="text-link" href="{{ route('documents.index') }}">Search all documents &rarr;</a></div>
                <div class="resource-grid resource-grid--featured">
                    @include('pages.partials.document-card', ['document' => $procedure])
                </div>
                @if($documents->count() > 1)
                    <div class="toolbar"><h2>Blacklisted sugar mills and orders</h2><span>{{ $documents->count() - 1 }} official orders</span></div>
                    <div class="resource-grid">
                        @foreach($documents->skip(1) as $document)
                            @include('pages.partials.document-card', ['document' => $document])
                        @endforeach
                    </div>
                @endif
            @else
                <div class="toolbar"><h2>Published documents</h2><a class="text-link" href="{{ route('documents.index') }}">Search all documents &rarr;</a></div>
                <div class="resource-grid">
                    @foreach($documents as $document)
                        @include('pages.partials.document-card', ['document' => $document])
                    @endforeach
                </div>
            @endif
        @endif

        @if($people->isNotEmpty())<div @class(['directory-grid', 'leadership-grid' => in_array($page->template, ['people', 'profile'], true)])>@foreach($people as $person)<article class="directory-card directory-card--person"><div class="profile-card__photo">@if($person->photo)<img src="{{ asset('storage/'.$person->photo) }}" alt="{{ $person->photo_alt ?: 'Portrait of '.$person->name }}">@else<img src="{{ asset('assets/profile-placeholder.svg') }}" alt="">@endif</div><div class="profile-card__content"><h3>{{ $person->name }}</h3><p><strong>{{ $person->designation }}</strong>@if($person->division)<br>{{ $person->division }}@endif</p>@if($person->term_start || $person->term_end)<p class="leadership-term"><span>Term of office</span>{{ $person->term_start?->format('d M Y') ?: 'Not recorded' }} &ndash; {{ $person->term_end?->format('d M Y') ?: 'Present' }}</p>@endif @if($person->biography)<p>{{ $person->biography }}</p>@endif @if($person->phone)<p><strong>Phone</strong><br><a href="tel:{{ preg_replace('/[^+0-9]/', '', $person->phone) }}">{{ $person->phone }}</a></p>@endif @if($person->email)<a href="mailto:{{ $person->email }}">{{ $person->email }}</a>@endif</div></article>@endforeach</div>
        @endif

        @if($offices->isNotEmpty())<div class="directory-grid">@foreach($offices as $office)<article class="directory-card"><span class="pill">{{ str($office->office_type)->title() }}</span><h3>{{ $office->name }}</h3><p>{{ $office->address }}</p>@if($office->phone)<p><strong>Phone</strong><br>{{ $office->phone }}</p>@endif @if($office->email)<a href="mailto:{{ $office->email }}">{{ $office->email }}</a>@endif</article>@endforeach</div>@endif

        @if($portals->isNotEmpty())<div class="resource-grid">@foreach($portals as $portal)<a class="resource-card" href="{{ $portal->url }}" target="_blank" rel="noopener"><small>Official external resource</small><h3>{{ $portal->title }}</h3><p>{{ $portal->description }}</p><span class="text-link">Continue securely &nearr;</span></a>@endforeach</div>@endif

        @if($albums->isNotEmpty())<div class="gallery-grid">@foreach($albums as $album)<article class="gallery-card">@if($album->items->first())<img class="gallery-cover" src="{{ asset('storage/'.$album->items->first()->path) }}" alt="{{ $album->items->first()->alt_text }}">@endif<div><small>{{ $album->event_date?->format('d M Y') }}</small><h3>{{ $album->title }}</h3><p>{{ $album->description }}</p><span>{{ $album->items->count() }} {{ \Illuminate\Support\Str::plural('image', $album->items->count()) }}</span></div></article>@endforeach</div>@endif

        @if(in_array($page->template, ['contact','inquiry']))
            <section class="contact-experience" aria-labelledby="contact-details-title"><div class="contact-panel"><span class="kicker">Direct contact</span><h2 id="contact-details-title">Contact TCP</h2><p>Use the published contact details or send a secure message to the appropriate TCP team.</p><div class="contact-cards"><div class="contact-card"><strong>Telephone</strong><a href="tel:+9221111827000">+92-21-111-TCP(827)-000</a></div><div class="contact-card"><strong>Email</strong><a href="mailto:tcp@tcp.gov.pk">tcp@tcp.gov.pk</a></div><div class="contact-card"><strong>Principal office</strong><span>Finance &amp; Trade Centre,<br>Shahrah-e-Faisal, Karachi</span></div></div></div>
            <form class="form-grid form-surface" action="{{ route('submissions.store') }}" method="post">@csrf<input type="hidden" name="type" value="{{ $page->template }}"><input name="company" tabindex="-1" autocomplete="off" aria-hidden="true" style="position:absolute;left:-9999px">
                <div class="form-heading full"><span class="kicker">Secure form</span><h2>Send an inquiry</h2><p>Fields marked as required must be completed before submission.</p></div>
                <div class="form-group"><label for="name">Name</label><input id="name" name="name" type="text" value="{{ old('name') }}" required>@error('name')<span class="form-error">{{ $message }}</span>@enderror</div>
                <div class="form-group"><label for="email">Email address</label><input id="email" name="email" type="email" value="{{ old('email') }}" required>@error('email')<span class="form-error">{{ $message }}</span>@enderror</div>
                <div class="form-group"><label for="phone">Phone number</label><input id="phone" name="phone" type="tel" value="{{ old('phone') }}"></div>
                <div class="form-group"><label for="subject">Subject</label><input id="subject" name="subject" type="text" value="{{ old('subject') }}" required>@error('subject')<span class="form-error">{{ $message }}</span>@enderror</div>
                <div class="form-group full"><label for="message">Message</label><textarea id="message" name="message" required>{{ old('message') }}</textarea>@error('message')<span class="form-error">{{ $message }}</span>@enderror</div>
                @if(config('services.turnstile.site_key'))<div class="form-group full"><div class="cf-turnstile" data-sitekey="{{ config('services.turnstile.site_key') }}"></div></div>@endif
                <div class="form-group full form-actions"><button class="button-green" type="submit">Submit securely</button><span class="form-note">Submissions are stored securely for official follow-up.</span></div>
            </form></section>
        @endif
    </article>
</div>
@endsection
@if(config('services.turnstile.site_key'))@push('scripts')<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>@endpush @endif
