<div>
    <!-- Header Section -->
    <div class="p-6 border-b border-gray-200 dark:border-gray-700">
        <div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
            <div>
                <h3 class="text-lg font-semibold text-gray-900 dark:text-gray-100">
                    Partner Companies Ranking
                </h3>
                <p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
                    Companies ranked by number of UMP students accepted
                </p>
            </div>

            <!-- Search -->
            <div class="w-full sm:w-auto">
                <input
                    type="text"
                    wire:model.live.debounce.300ms="search"
                    placeholder="Search company name..."
                    class="w-full sm:w-64 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent dark:bg-gray-700 dark:text-gray-200"
                />
            </div>
        </div>
    </div>

    <!-- Table -->
    <div class="overflow-x-auto">
        <table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
            <thead class="bg-gray-50 dark:bg-gray-900">
                <tr>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
                        Rank
                    </th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
                        wire:click="sortBy('companyName')">
                        <div class="flex items-center space-x-1">
                            <span>Company Name</span>
                            <?php if($sortField === 'companyName'): ?>
                                <?php if (isset($component)) { $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.heroicon','data' => ['name' => ''.e($sortDirection === 'asc' ? 'arrow-up' : 'arrow-down').'','class' => 'h-4 w-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('heroicon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => ''.e($sortDirection === 'asc' ? 'arrow-up' : 'arrow-down').'','class' => 'h-4 w-4']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $attributes = $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $component = $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
                            <?php endif; ?>
                        </div>
                    </th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
                        wire:click="sortBy('student_count')">
                        <div class="flex items-center space-x-1">
                            <span>Students Accepted</span>
                            <?php if($sortField === 'student_count'): ?>
                                <?php if (isset($component)) { $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.heroicon','data' => ['name' => ''.e($sortDirection === 'asc' ? 'arrow-up' : 'arrow-down').'','class' => 'h-4 w-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('heroicon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => ''.e($sortDirection === 'asc' ? 'arrow-up' : 'arrow-down').'','class' => 'h-4 w-4']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $attributes = $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $component = $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
                            <?php endif; ?>
                        </div>
                    </th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
                        Location
                    </th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
                        wire:click="sortBy('last_accepted')">
                        <div class="flex items-center space-x-1">
                            <span>Last Accepted</span>
                            <?php if($sortField === 'last_accepted'): ?>
                                <?php if (isset($component)) { $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.heroicon','data' => ['name' => ''.e($sortDirection === 'asc' ? 'arrow-up' : 'arrow-down').'','class' => 'h-4 w-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('heroicon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => ''.e($sortDirection === 'asc' ? 'arrow-up' : 'arrow-down').'','class' => 'h-4 w-4']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $attributes = $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $component = $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
                            <?php endif; ?>
                        </div>
                    </th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer"
                        wire:click="sortBy('avg_allowance')">
                        <div class="flex items-center space-x-1">
                            <span>Avg Allowance</span>
                            <?php if($sortField === 'avg_allowance'): ?>
                                <?php if (isset($component)) { $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.heroicon','data' => ['name' => ''.e($sortDirection === 'asc' ? 'arrow-up' : 'arrow-down').'','class' => 'h-4 w-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('heroicon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => ''.e($sortDirection === 'asc' ? 'arrow-up' : 'arrow-down').'','class' => 'h-4 w-4']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $attributes = $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $component = $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
                            <?php endif; ?>
                        </div>
                    </th>
                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
                        Actions
                    </th>
                </tr>
            </thead>
            <tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700">
                <?php $__empty_1 = true; $__currentLoopData = $rankings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $company): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors">
                        <td class="px-6 py-4 whitespace-nowrap">
                            <div class="flex items-center space-x-2">
                                <span class="text-sm font-semibold text-gray-900 dark:text-gray-100">
                                    #<?php echo e($company->rank); ?>

                                </span>
                                <?php if($badge = $this->getRankingBadge($company->rank)): ?>
                                    <span class="px-2 py-1 text-xs rounded-full <?php echo e($badge['class']); ?>">
                                        <?php echo e($badge['icon']); ?> <?php echo e($badge['text']); ?>

                                    </span>
                                <?php endif; ?>
                            </div>
                        </td>
                        <td class="px-6 py-4">
                            <div class="text-sm font-medium text-gray-900 dark:text-gray-100">
                                <?php echo e($company->companyName); ?>

                            </div>
                        </td>
                        <td class="px-6 py-4 whitespace-nowrap">
                            <div class="flex items-center">
                                <span class="text-sm font-semibold text-purple-600 dark:text-purple-400">
                                    <?php echo e($company->student_count); ?>

                                </span>
                                <span class="text-xs text-gray-500 dark:text-gray-400 ml-1">
                                    student<?php echo e($company->student_count !== 1 ? 's' : ''); ?>

                                </span>
                            </div>
                        </td>
                        <td class="px-6 py-4">
                            <div class="text-sm text-gray-900 dark:text-gray-100">
                                <?php if($company->states): ?>
                                    <?php echo e(explode(',', $company->states)[0]); ?>

                                <?php else: ?>
                                    N/A
                                <?php endif; ?>
                            </div>
                            <?php if($company->state_count > 1): ?>
                                <div class="text-xs text-gray-500 dark:text-gray-400">
                                    +<?php echo e($company->state_count - 1); ?> more location<?php echo e($company->state_count - 1 !== 1 ? 's' : ''); ?>

                                </div>
                            <?php endif; ?>
                        </td>
                        <td class="px-6 py-4 whitespace-nowrap">
                            <div class="text-sm text-gray-900 dark:text-gray-100">
                                <?php echo e($company->last_accepted ? \Carbon\Carbon::parse($company->last_accepted)->format('M Y') : 'N/A'); ?>

                            </div>
                        </td>
                        <td class="px-6 py-4 whitespace-nowrap">
                            <div class="text-sm text-gray-900 dark:text-gray-100">
                                <?php if($company->avg_allowance): ?>
                                    RM <?php echo e(number_format($company->avg_allowance, 2)); ?>

                                <?php else: ?>
                                    N/A
                                <?php endif; ?>
                            </div>
                        </td>
                        <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                            <button
                                wire:click="viewCompanyDetails('<?php echo e($company->companyName); ?>')"
                                class="text-purple-600 hover:text-purple-900 dark:text-purple-400 dark:hover:text-purple-300">
                                View Details
                            </button>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="7" class="px-6 py-4 text-center text-gray-500 dark:text-gray-400">
                            No companies found.
                        </td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>

    <!-- Pagination -->
    <div class="p-6 border-t border-gray-200 dark:border-gray-700">
        <?php echo e($rankings->links()); ?>

    </div>

    <!-- Company Detail Modal -->
    <?php if($showDetailModal && $selectedCompany): ?>
        <div class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50"
             wire:click="closeDetailModal">
            <div class="relative top-20 mx-auto p-5 border w-11/12 md:w-3/4 lg:w-1/2 shadow-lg rounded-md bg-white dark:bg-gray-800"
                 wire:click.stop>
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-lg font-semibold text-gray-900 dark:text-gray-100">
                        <?php echo e($selectedCompany['companyName']); ?> - Details
                    </h3>
                    <button wire:click="closeDetailModal" class="text-gray-400 hover:text-gray-600">
                        <?php if (isset($component)) { $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.heroicon','data' => ['name' => 'x-mark','class' => 'h-6 w-6']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('heroicon'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'x-mark','class' => 'h-6 w-6']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $attributes = $__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__attributesOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa)): ?>
<?php $component = $__componentOriginalf8cb93e61e9242dd3f96f53798060bfa; ?>
<?php unset($__componentOriginalf8cb93e61e9242dd3f96f53798060bfa); ?>
<?php endif; ?>
                    </button>
                </div>

                <div class="space-y-4">
                    <!-- Statistics -->
                    <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
                        <div class="bg-purple-50 dark:bg-purple-900/20 p-4 rounded-lg">
                            <div class="text-2xl font-bold text-purple-600 dark:text-purple-400">
                                <?php echo e($selectedCompany['totalStudents']); ?>

                            </div>
                            <div class="text-sm text-gray-600 dark:text-gray-400">Total Students</div>
                        </div>
                        <div class="bg-blue-50 dark:bg-blue-900/20 p-4 rounded-lg">
                            <div class="text-2xl font-bold text-blue-600 dark:text-blue-400">
                                <?php echo e($selectedCompany['acceptanceRate']); ?>%
                            </div>
                            <div class="text-sm text-gray-600 dark:text-gray-400">Acceptance Rate</div>
                        </div>
                        <div class="bg-green-50 dark:bg-green-900/20 p-4 rounded-lg">
                            <div class="text-2xl font-bold text-green-600 dark:text-green-400">
                                <?php echo e($selectedCompany['firstAccepted'] ? \Carbon\Carbon::parse($selectedCompany['firstAccepted'])->format('Y') : 'N/A'); ?>

                            </div>
                            <div class="text-sm text-gray-600 dark:text-gray-400">First Partnership</div>
                        </div>
                        <div class="bg-yellow-50 dark:bg-yellow-900/20 p-4 rounded-lg">
                            <div class="text-2xl font-bold text-yellow-600 dark:text-yellow-400">
                                <?php if($selectedCompany['averageAllowance']): ?>
                                    RM <?php echo e(number_format($selectedCompany['averageAllowance'], 0)); ?>

                                <?php else: ?>
                                    N/A
                                <?php endif; ?>
                            </div>
                            <div class="text-sm text-gray-600 dark:text-gray-400">Avg Allowance</div>
                        </div>
                    </div>

                    <!-- Positions Offered -->
                    <?php if($selectedCompany['positions']->count() > 0): ?>
                        <div>
                            <h4 class="font-semibold text-gray-900 dark:text-gray-100 mb-2">Positions Offered</h4>
                            <div class="flex flex-wrap gap-2">
                                <?php $__currentLoopData = $selectedCompany['positions']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $position): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <span class="px-3 py-1 bg-gray-100 dark:bg-gray-700 rounded-full text-sm">
                                        <?php echo e($position->position); ?> (<?php echo e($position->count); ?>)
                                    </span>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div>
                    <?php endif; ?>

                    <!-- Work Methods -->
                    <?php if($selectedCompany['workMethods']->count() > 0): ?>
                        <div>
                            <h4 class="font-semibold text-gray-900 dark:text-gray-100 mb-2">Work Methods</h4>
                            <div class="flex flex-wrap gap-2">
                                <?php $__currentLoopData = $selectedCompany['workMethods']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $method): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <span class="px-3 py-1 bg-blue-100 dark:bg-blue-900/20 rounded-full text-sm">
                                        <?php echo e($method->methodOfWork); ?> (<?php echo e($method->count); ?>)
                                    </span>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div>
                    <?php endif; ?>

                    <!-- Students List -->
                    <div>
                        <h4 class="font-semibold text-gray-900 dark:text-gray-100 mb-2">
                            Accepted Students (<?php echo e($selectedCompany['students']->count()); ?>)
                        </h4>
                        <div class="max-h-64 overflow-y-auto">
                            <table class="min-w-full text-sm">
                                <thead class="bg-gray-50 dark:bg-gray-900 sticky top-0">
                                    <tr>
                                        <th class="px-4 py-2 text-left">Student</th>
                                        <th class="px-4 py-2 text-left">Position</th>
                                        <th class="px-4 py-2 text-left">Period</th>
                                        <th class="px-4 py-2 text-left">Allowance</th>
                                    </tr>
                                </thead>
                                <tbody class="divide-y divide-gray-200 dark:divide-gray-700">
                                    <?php $__currentLoopData = $selectedCompany['students']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $student): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td class="px-4 py-2"><?php echo e($student['name']); ?></td>
                                            <td class="px-4 py-2"><?php echo e($student['position']); ?></td>
                                            <td class="px-4 py-2">
                                                <?php echo e($student['startDate']); ?> to <?php echo e($student['endDate']); ?>

                                            </td>
                                            <td class="px-4 py-2">
                                                <?php if($student['allowance']): ?>
                                                    RM <?php echo e(number_format($student['allowance'], 2)); ?>

                                                <?php else: ?>
                                                    N/A
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?>
</div><?php /**PATH C:\Users\User\Desktop\Laravel\Internlink\resources\views\livewire\company-ranking-table.blade.php ENDPATH**/ ?>