@extends('layout.main')

@section('title', 'প্রার্থী বিস্তারিত')

@section('content')
    <div class="min-h-screen bg-gray-50 p-4 sm:p-6">
        <div class="max-w-6xl mx-auto">
            <div class="mb-8">
                <div class="flex items-center justify-between mb-6">
                    <div>
                        <h1 class="text-2xl sm:text-3xl font-bold text-gray-900 mb-2">প্রার্থী বিস্তারিত</h1>
                        <div class="flex items-center gap-3">
                            <a href="{{ route('candidates.index') }}"
                                class="text-green-600 hover:text-green-800 text-sm font-medium">
                                ← প্রার্থী তালিকায় ফিরে যান
                            </a>
                            @if ($candidate->status == 'active')
                                <span class="px-2 py-1 bg-green-100 text-green-800 text-xs font-medium rounded-full">
                                    সক্রিয়
                                </span>
                            @endif
                        </div>
                    </div>
                    <div class="flex items-center gap-2">
                        <a href="{{ route('candidates.edit', $candidate) }}"
                            class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center gap-2">
                            <i class="fas fa-edit"></i>
                            সম্পাদনা
                        </a>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
                <div class="bg-gradient-to-r from-green-50 to-emerald-50 p-6">
                    <div class="flex flex-col md:flex-row items-start md:items-center gap-6">
                        <div class="relative">
                            <div class="w-32 h-32 rounded-xl overflow-hidden border-4 border-white shadow-lg">
                                @if ($candidate->photo)
                                    <img src="{{ asset('storage/' . $candidate->photo) }}"
                                        alt="{{ $candidate->user->name }}" class="w-full h-full object-cover">
                                @else
                                    <div class="w-full h-full bg-gray-200 flex items-center justify-center">
                                        <i class="fas fa-user text-4xl text-gray-400"></i>
                                    </div>
                                @endif
                            </div>

                            @if ($candidate->symbol_photo)
                                <div class="absolute -bottom-2 -right-2 w-16 h-16 bg-white rounded-lg shadow-lg border p-1">
                                    <img src="{{ asset('storage/' . $candidate->symbol_photo) }}"
                                        alt="{{ $candidate->symbol_name }}" class="w-full h-full object-contain">
                                </div>
                            @endif
                        </div>

                        <div class="flex-1">
                            <h2 class="text-2xl font-bold text-gray-900 mb-1">{{ $candidate->user->name ?? 'N/A' }}</h2>
                            <p class="text-lg text-gray-700 mb-2">{{ $candidate->party_name }}</p>

                            <div class="flex flex-wrap items-center gap-3">
                                {{-- <div class="flex items-center gap-2">
                                    <i class="fas fa-landmark text-green-600"></i>
                                    <span class="text-gray-700">{{ $candidate->symbol_name }}</span>
                                </div> --}}
                                <div class="flex items-center gap-2">
                                    <i class="fas fa-map-marker-alt text-green-600"></i>
                                    <span class="text-gray-700">{{ $candidate->seat->name ?? 'N/A' }}</span>
                                </div>

                            </div>

                            @if ($candidate->bio)
                                <p class="mt-3 text-gray-600">{{ $candidate->bio }}</p>
                            @endif
                        </div>
                    </div>
                </div>

                <div class="p-6">
                    <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
                        <div class="space-y-6">
                            <h3 class="text-lg font-semibold text-gray-900 pb-2 border-b border-gray-200">ব্যক্তিগত তথ্য
                            </h3>

                            <div class="space-y-4">
                                {{-- <div class="grid grid-cols-2 gap-4">
                                    <div>
                                        <p class="text-sm text-gray-500 mb-1">পিতার নাম</p>
                                        <p class="font-medium text-gray-900">{{ $candidate->father_name }}</p>
                                    </div>
                                    <div>
                                        <p class="text-sm text-gray-500 mb-1">মাতার নাম</p>
                                        <p class="font-medium text-gray-900">{{ $candidate->mother_name }}</p>
                                    </div>
                                </div> --}}


                                <div class="grid grid-cols-2 gap-4">
                                    @php
                                        $dobBn = \Carbon\Carbon::parse($candidate->date_of_birth)
                                            ->locale('bn')
                                            ->translatedFormat('d F Y');

                                        $dobBn = strtr($dobBn, [
                                            '0' => '০',
                                            '1' => '১',
                                            '2' => '২',
                                            '3' => '৩',
                                            '4' => '৪',
                                            '5' => '৫',
                                            '6' => '৬',
                                            '7' => '৭',
                                            '8' => '৮',
                                            '9' => '৯',
                                        ]);
                                    @endphp

                                    <div>
                                        <p class="text-sm text-gray-500 mb-1">জন্ম তারিখ</p>
                                        <p class="font-medium text-gray-900">{{ $dobBn }}</p>
                                    </div>

                                    <div>
                                        <p class="text-sm text-gray-500 mb-1">বয়স</p>
                                        @php
                                            use Carbon\Carbon;

                                            $age = Carbon::parse($candidate->date_of_birth)->age;

                                            $bnDigits = strtr((string) $age, [
                                                '0' => '০',
                                                '1' => '১',
                                                '2' => '২',
                                                '3' => '৩',
                                                '4' => '৪',
                                                '5' => '৫',
                                                '6' => '৬',
                                                '7' => '৭',
                                                '8' => '৮',
                                                '9' => '৯',
                                            ]);
                                        @endphp

                                        <p class="font-medium text-gray-900">
                                            {{ $bnDigits }} বছর
                                        </p>

                                    </div>
                                </div>

                                <div>
                                    <p class="text-sm text-gray-500 mb-1">এনআইডি নম্বর</p>
                                    <p
                                        class="font-medium text-gray-900 font-mono bg-gray-50 px-3 py-2 rounded border border-gray-200">
                                        {{ $candidate->nid_number }}
                                    </p>
                                </div>

                                {{-- <div class="grid grid-cols-2 gap-4">
                                    <div>
                                        <p class="text-sm text-gray-500 mb-1">মোবাইল নম্বর</p>
                                        <p class="font-medium text-gray-900">{{ $candidate->phone }}</p>
                                    </div>
                                    <div>
                                        <p class="text-sm text-gray-500 mb-1">ইমেইল</p>
                                        <p class="font-medium text-gray-900">{{ $candidate->email }}</p>
                                    </div>
                                </div> --}}

                                {{-- <div>
                                    <p class="text-sm text-gray-500 mb-1">ঠিকানা</p>
                                    <p class="font-medium text-gray-900">{{ $candidate->address }}</p>
                                </div> --}}
                            </div>
                        </div>

                        <div class="space-y-6">
                            <h3 class="text-lg font-semibold text-gray-900 pb-2 border-b border-gray-200">নির্বাচনী তথ্য
                            </h3>

                            <div class="space-y-4">
                                <div>
                                    <p class="text-sm text-gray-500 mb-1">নির্বাচনী সীট</p>
                                    <p class="font-medium text-gray-900">{{ $candidate->seat->name ?? 'N/A' }}</p>
                                    <p class="text-sm text-gray-600">{{ $candidate->seat->constituency ?? '' }}</p>
                                </div>

                                <div>
                                    <p class="text-sm text-gray-500 mb-1">প্রতীক নাম</p>
                                    <p class="font-medium text-gray-900">{{ $candidate->symbol_name }}</p>
                                </div>

                                <div>
                                    <p class="text-sm text-gray-500 mb-1">শিক্ষাগত যোগ্যতা</p>
                                    <p class="font-medium text-gray-900">{{ $candidate->education }}</p>
                                </div>

                                @if ($candidate->previous_experience)
                                    <div>
                                        <p class="text-sm text-gray-500 mb-1">পূর্ববর্তী অভিজ্ঞতা</p>
                                        <ul class="list-disc list-inside space-y-1 text-gray-900">
                                            @foreach (json_decode($candidate->previous_experience, true) as $exp)
                                                <li>{{ $exp }}</li>
                                            @endforeach
                                        </ul>
                                    </div>
                                @endif


                            </div>
                        </div>
                    </div>

                    @if ($candidate->election_manifesto)
                        <div class="mt-8 pt-6 border-t border-gray-200">
                            <h3 class="text-lg font-semibold text-gray-900 mb-4">নির্বাচনী ইশতেহার</h3>
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <p class="text-gray-700 whitespace-pre-line">{{ $candidate->election_manifesto }}</p>
                            </div>
                        </div>
                    @endif
                </div>
            </div>
        </div>
    </div>
@endsection
