<?php $__env->startSection('title', 'Paketler — Kolay Abonelik'); ?>
<?php $__env->startSection('content'); ?>
<div class="max-w-6xl mx-auto px-4 py-10">
    <h1 class="text-2xl font-bold mb-6">İnternet & TV Paketleri</h1>

    <form method="GET" class="flex flex-wrap gap-2 mb-8 bg-slate-50 p-4 rounded-lg">
        <select name="company_id" class="border rounded px-3 py-2 text-sm">
            <option value="">Tüm Firmalar</option>
            <?php $__currentLoopData = $companies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($c->id); ?>" <?php if(request('company_id')==$c->id): echo 'selected'; endif; ?>><?php echo e($c->name); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
        <select name="service_type" class="border rounded px-3 py-2 text-sm">
            <option value="">Tüm Hizmet Türleri</option>
            <?php $__currentLoopData = ['internet'=>'İnternet','tv'=>'TV','internet_tv'=>'İnternet + TV','fiber'=>'Fiber','dsl'=>'DSL','mobile_internet'=>'Mobil İnternet']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $val=>$label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($val); ?>" <?php if(request('service_type')===$val): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
        <input type="number" name="price_min" placeholder="Min Fiyat" value="<?php echo e(request('price_min')); ?>" class="border rounded px-3 py-2 text-sm w-28">
        <input type="number" name="price_max" placeholder="Max Fiyat" value="<?php echo e(request('price_max')); ?>" class="border rounded px-3 py-2 text-sm w-28">
        <input type="text" name="speed" placeholder="Hız (örn: 100)" value="<?php echo e(request('speed')); ?>" class="border rounded px-3 py-2 text-sm w-32">
        <label class="flex items-center gap-1 text-sm">
            <input type="checkbox" name="campaign_only" value="1" <?php if(request('campaign_only')): echo 'checked'; endif; ?>> Sadece Kampanyalı
        </label>
        <button class="bg-blue-600 text-white rounded px-4 py-2 text-sm font-medium">Filtrele</button>
    </form>

    <form id="compare-form" method="GET" action="<?php echo e(route('packages.compare')); ?>">
        <div class="grid md:grid-cols-3 gap-6">
            <?php $__currentLoopData = $packages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $package): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="border rounded-lg p-5 hover:shadow-md transition">
                    <label class="flex items-center gap-2 text-xs text-slate-400 mb-2">
                        <input type="checkbox" name="ids[]" value="<?php echo e($package->id); ?>" class="compare-check"> Karşılaştırmaya ekle
                    </label>
                    <a href="<?php echo e(route('packages.show', $package)); ?>" class="block">
                        <p class="text-xs text-blue-600 font-semibold"><?php echo e($package->company->name); ?></p>
                        <h3 class="font-bold text-lg hover:text-blue-600"><?php echo e($package->name); ?></h3>
                        <p class="text-sm text-slate-500"><?php echo e($package->speed); ?> — <?php echo e($package->quota); ?></p>
                        <?php if($package->tv_content): ?><p class="text-xs text-slate-400"><?php echo e($package->tv_content); ?></p><?php endif; ?>
                        <p class="text-2xl font-bold text-blue-600 mt-3"><?php echo e(number_format($package->monthly_fee,2,',','.')); ?> TL<span class="text-sm text-slate-400">/ay</span></p>
                        <?php if($package->campaign): ?><p class="text-xs text-green-600 mt-1"><?php echo e($package->campaign); ?></p><?php endif; ?>
                    </a>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
        <button type="submit" id="compare-btn" class="mt-6 bg-slate-800 text-white rounded px-5 py-2.5 text-sm font-medium hidden">Seçilenleri Karşılaştır</button>
    </form>

    <div class="mt-8"><?php echo e($packages->links()); ?></div>
</div>

<script>
document.addEventListener('change', function (e) {
    if (e.target.classList.contains('compare-check')) {
        const checked = document.querySelectorAll('.compare-check:checked').length;
        document.getElementById('compare-btn').classList.toggle('hidden', checked < 2);
    }
});
document.getElementById('compare-form').addEventListener('submit', function (e) {
    e.preventDefault();
    const ids = Array.from(document.querySelectorAll('.compare-check:checked')).map(c => c.value);
    window.location.href = "<?php echo e(route('packages.compare')); ?>?ids=" + ids.join(',');
});
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.site', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\a-azr\Desktop\kolayabonelik\resources\views/site/packages.blade.php ENDPATH**/ ?>