<?php
use Livewire\Component;
use App\Models\ReporterApplication;
?>

<div class="max-content">

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($viewing): ?>
        <!-- Detail Panel -->
        <div class="mb-6">
            <button wire:click="closeView" class="flex items-center gap-2 text-sm font-semibold text-gray-500 hover:text-gray-900 transition-colors mb-6">
                <i class="fa-solid fa-arrow-left"></i> All Applications
            </button>

            <div class="flex flex-col lg:flex-row gap-8">
                <!-- Main Info -->
                <div class="flex-1 space-y-6">
                    <!-- Personal -->
                    <div class="card p-6">
                        <h3 class="text-xs font-bold uppercase tracking-widest text-gray-400 mb-4">Personal Details</h3>
                        <div class="grid grid-cols-2 gap-4 text-sm">
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Full Name</span><span class="font-semibold text-gray-900"><?php echo e($viewing->full_name); ?></span></div>
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Gender</span><span class="font-semibold text-gray-900"><?php echo e(ucfirst($viewing->gender ?? '—')); ?></span></div>
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Date of Birth</span><span class="font-semibold text-gray-900"><?php echo e($viewing->dob ? $viewing->dob->format('d M Y') : '—'); ?></span></div>
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Mobile</span><span class="font-semibold text-gray-900"><?php echo e($viewing->mobile_number); ?></span></div>
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">WhatsApp</span><span class="font-semibold text-gray-900"><?php echo e($viewing->whatsapp_number ?? '—'); ?></span></div>
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Email</span><span class="font-semibold text-gray-900"><?php echo e($viewing->email ?? '—'); ?></span></div>
                            <div class="col-span-2"><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Address</span><span class="font-semibold text-gray-900"><?php echo e($viewing->address ?? '—'); ?></span></div>
                        </div>
                    </div>

                    <!-- Education & Reporting -->
                    <div class="card p-6">
                        <h3 class="text-xs font-bold uppercase tracking-widest text-gray-400 mb-4">Education & Reporting</h3>
                        <div class="grid grid-cols-2 gap-4 text-sm">
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Qualification</span><span class="font-semibold text-gray-900"><?php echo e($viewing->highest_qualification ?? '—'); ?></span></div>
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">School / College</span><span class="font-semibold text-gray-900"><?php echo e($viewing->school_college_name ?? '—'); ?></span></div>
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Applying For</span><span class="font-semibold text-gray-900"><?php echo e($viewing->applying_for ? implode(', ', $viewing->applying_for) : '—'); ?></span></div>
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Area</span><span class="font-semibold text-gray-900"><?php echo e($viewing->area ?? '—'); ?></span></div>
                        </div>
                    </div>

                    <!-- Experience & Skills -->
                    <div class="card p-6">
                        <h3 class="text-xs font-bold uppercase tracking-widest text-gray-400 mb-4">Experience & Skills</h3>
                        <div class="grid grid-cols-2 gap-4 text-sm">
                            <div><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Has Experience</span><span class="font-semibold text-gray-900"><?php echo e($viewing->has_experience ? 'Yes' : 'No'); ?></span></div>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($viewing->has_experience): ?>
                                <div class="col-span-2"><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Details</span><span class="font-semibold text-gray-900"><?php echo e($viewing->experience_details ?? '—'); ?></span></div>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            <div class="col-span-2"><span class="text-gray-400 text-[11px] uppercase font-bold block mb-0.5">Skills</span><span class="font-semibold text-gray-900"><?php echo e($viewing->skills ? implode(', ', $viewing->skills) : '—'); ?></span></div>
                        </div>
                        <div class="flex flex-wrap gap-3 mt-4">
                            <span class="px-3 py-1 rounded-full text-[11px] font-bold <?php echo e($viewing->has_smartphone ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-400'); ?>">Smartphone</span>
                            <span class="px-3 py-1 rounded-full text-[11px] font-bold <?php echo e($viewing->has_microphone ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-400'); ?>">Microphone</span>
                            <span class="px-3 py-1 rounded-full text-[11px] font-bold <?php echo e($viewing->has_internet ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-400'); ?>">Internet</span>
                            <span class="px-3 py-1 rounded-full text-[11px] font-bold <?php echo e($viewing->availability_daily ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-400'); ?>">Daily Available</span>
                        </div>
                    </div>

                    <!-- Documents -->
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($viewing->photo_path || $viewing->id_proof_path): ?>
                        <div class="card p-6">
                            <h3 class="text-xs font-bold uppercase tracking-widest text-gray-400 mb-4">Documents</h3>
                            <div class="flex gap-4">
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($viewing->photo_path): ?>
                                    <a href="<?php echo e(Storage::url($viewing->photo_path)); ?>" target="_blank" class="flex items-center gap-2 text-sm font-semibold hover:underline" style="color: #99BC85;">
                                        <i class="fa-solid fa-image"></i> View Photo
                                    </a>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($viewing->id_proof_path): ?>
                                    <a href="<?php echo e(Storage::url($viewing->id_proof_path)); ?>" target="_blank" class="flex items-center gap-2 text-sm font-semibold hover:underline" style="color: #99BC85;">
                                        <i class="fa-solid fa-id-card"></i> View ID Proof
                                    </a>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            </div>
                        </div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>

                <!-- Action Sidebar -->
                <div class="w-full lg:w-72 space-y-6">
                    <!-- Status -->
                    <div class="card p-6">
                        <h3 class="text-xs font-bold uppercase tracking-widest text-gray-400 mb-4">Update Status</h3>
                        <div class="space-y-2">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = ['pending' => 'Pending', 'interview' => 'Interview', 'selected' => 'Selected', 'rejected' => 'Rejected']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $val => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                <button wire:click="updateStatus(<?php echo e($viewing->id); ?>, '<?php echo e($val); ?>')"
                                    wire:loading.attr="disabled"
                                    class="w-full text-left px-4 py-2.5 rounded-md text-sm font-semibold transition-colors
                                    <?php echo e($viewing->status === $val ? 'bg-sage text-white' : 'bg-gray-50 text-gray-700 hover:bg-gray-100'); ?>"
                                    style="<?php echo e($viewing->status === $val ? 'background-color:#99BC85;' : ''); ?>">
                                    <span wire:loading.remove wire:target="updateStatus(<?php echo e($viewing->id); ?>, '<?php echo e($val); ?>')"><?php echo e($label); ?></span>
                                    <span wire:loading wire:target="updateStatus(<?php echo e($viewing->id); ?>, '<?php echo e($val); ?>')">Updating...</span>
                                </button>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                        </div>
                    </div>

                    <!-- Remarks -->
                    <div class="card p-6">
                        <h3 class="text-xs font-bold uppercase tracking-widest text-gray-400 mb-4">Admin Remarks</h3>
                        <textarea wire:model="remarksInput" rows="4" class="input-field w-full resize-none text-sm" placeholder="Internal notes..."></textarea>
                        <button wire:click="saveRemarks" wire:loading.attr="disabled" class="mt-3 w-full py-2 bg-gray-900 text-white text-xs font-bold rounded-md hover:bg-gray-700 transition-colors">
                            <span wire:loading.remove wire:target="saveRemarks">Save Remarks</span>
                            <span wire:loading wire:target="saveRemarks">Saving...</span>
                        </button>
                    </div>

                    <!-- Meta -->
                    <div class="card p-6 text-xs text-gray-400 space-y-1">
                        <p>Applied on: <span class="font-semibold text-gray-600"><?php echo e($viewing->created_at->format('d M Y, h:i A')); ?></span></p>
                    </div>
                </div>
            </div>
        </div>

    <?php else: ?>
        <!-- List View -->
        <header class="flex flex-col items-start sm:flex-row sm:justify-between sm:items-center gap-4 mb-10">
            <div>
                <h1 class="text-2xl font-semibold tracking-tight text-gray-900">Reporter Applications</h1>
                <p class="text-sm text-gray-500 mt-1">Manage all reporter job applications submitted via the website.</p>
            </div>
            <!-- Filter Tabs -->
            <div class="flex flex-wrap gap-1 p-1 bg-gray-100 rounded-lg">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = ['all' => 'All', 'pending' => 'Pending', 'interview' => 'Interview', 'selected' => 'Selected', 'rejected' => 'Rejected']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $val => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                    <button wire:click="$set('filter', '<?php echo e($val); ?>')"
                        class="px-3 py-1.5 text-xs font-semibold rounded-md transition-all <?php echo e($filter === $val ? 'bg-white shadow-sm' : 'text-gray-500 hover:text-gray-700'); ?>">
                        <?php echo e($label); ?>

                        <span class="ml-1 text-[10px] font-bold <?php echo e($filter === $val ? 'text-gray-700' : 'text-gray-400'); ?>"><?php echo e($counts[$val]); ?></span>
                    </button>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
            </div>
        </header>

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(session()->has('message')): ?>
            <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4 text-sm"><?php echo e(session('message')); ?></div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

        <div class="card">
            <div class="overflow-x-auto">
                <table>
                    <thead>
                        <tr>
                            <th class="px-6 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Applicant</th>
                            <th class="px-6 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Applying For</th>
                            <th class="px-6 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Area</th>
                            <th class="px-6 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
                            <th class="px-6 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
                            <th class="px-6 py-3 bg-gray-50 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $applications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $app): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                            <tr class="hover:bg-gray-50/50 transition-colors">
                                <td class="px-6 py-4 whitespace-nowrap">
                                    <div class="font-semibold text-gray-900 text-sm"><?php echo e($app->full_name); ?></div>
                                    <div class="text-[11px] text-gray-400"><?php echo e($app->mobile_number); ?></div>
                                </td>
                                <td class="px-6 py-4 text-sm text-gray-600">
                                    <?php echo e($app->applying_for ? implode(', ', $app->applying_for) : '—'); ?>

                                </td>
                                <td class="px-6 py-4 text-sm text-gray-600"><?php echo e($app->area ?? '—'); ?></td>
                                <td class="px-6 py-4 whitespace-nowrap text-xs text-gray-500"><?php echo e($app->created_at->format('d M Y')); ?></td>
                                <td class="px-6 py-4 whitespace-nowrap">
                                    <?php
                                        $statusMap = [
                                            'pending'   => 'pending',
                                            'interview' => 'warning',
                                            'selected'  => 'success',
                                            'rejected'  => 'secondary',
                                        ];
                                        $labelMap = [
                                            'pending'   => 'Pending',
                                            'interview' => 'Interview',
                                            'selected'  => 'Selected',
                                            'rejected'  => 'Rejected',
                                        ];
                                    ?>
                                    <span class="status-badge <?php echo e($statusMap[$app->status] ?? 'secondary'); ?>">
                                        <?php echo e($labelMap[$app->status] ?? $app->status); ?>

                                    </span>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap text-right">
                                    <button wire:click="openApplication(<?php echo e($app->id); ?>)" class="text-xs font-semibold px-2 hover:underline" style="color: #99BC85;">View</button>
                                </td>
                            </tr>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                            <tr>
                                <td colspan="6" class="px-6 py-10 text-center text-gray-400 text-sm">No applications found.</td>
                            </tr>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

</div><?php /**PATH D:\02-my freelance\00-DR_Padhi\DR_PADHI\storage\framework/views/livewire/views/cf104398.blade.php ENDPATH**/ ?>