<?php $__env->startSection('title', $category->name . ' — Placeo'); ?>

<?php
    $params = array_merge(request()->query(), ['category' => $category->slug]);
    $pointsUrl = route('feed.points', $params);
    $mapCenter = [$currentCity?->lat ?? 55.751244, $currentCity?->lng ?? 37.618423];
?>

<?php $__env->startSection('content'); ?>
<div class="mx-auto max-w-6xl">

    
    <nav class="mb-3 flex flex-wrap items-center gap-1 text-sm text-muted">
        <a href="<?php echo e(route('home')); ?>" class="hover:text-brand-600">Главная</a>
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $breadcrumbs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $crumb): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
            <span>›</span><a href="<?php echo e(category_url($crumb)); ?>" class="hover:text-brand-600"><?php echo e($crumb->name); ?></a>
        <?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; ?>
        <span>›</span><span class="text-gray-800"><?php echo e($category->name); ?></span>
    </nav>

    <h1 class="mb-4 text-2xl font-bold text-gray-900"><?php echo e($cityScope ? "{$category->name} в городе {$cityScope->name}" : $category->name); ?></h1>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($cityScope): ?>
        <p class="-mt-2 mb-4 text-sm text-muted">Объявления раздела «<?php echo e($category->name); ?>» в городе <?php echo e($cityScope->name); ?> — местные предложения показываются первыми.</p>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <form method="GET" action="<?php echo e(category_url($category)); ?>" x-data="{ view: '<?php echo e($view); ?>', sidebar: false }">
        <input type="hidden" name="view" :value="view">
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($currentCity): ?><input type="hidden" name="city" value="<?php echo e($currentCity->id); ?>"><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

        
        <button type="button" @click="sidebar = !sidebar"
                class="btn-ghost mb-3 flex w-full items-center justify-center gap-2 lg:hidden">
            <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.8">
                <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M6 12h12m-9 5.25h6" />
            </svg>
            <span x-text="sidebar ? 'Скрыть разделы и фильтры' : 'Разделы и фильтры'"></span>
        </button>

        <div class="grid gap-6 lg:grid-cols-[260px_1fr]">

            
            <aside class="space-y-5" :class="sidebar ? 'block' : 'hidden lg:block'">
                
                <div class="card p-4">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($parent): ?>
                        <a href="<?php echo e(category_url($parent)); ?>" class="mb-2 flex items-center gap-1 text-sm font-medium text-brand-600 hover:underline">
                            ‹ <?php echo e($parent->name); ?>

                        </a>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <ul class="space-y-1 text-sm">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $siblings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sib): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                            <li>
                                <a href="<?php echo e(category_url($sib)); ?>"
                                   class="block rounded px-2 py-1 <?php echo e($sib->id === $category->id ? 'bg-brand-100 font-semibold text-brand-800' : 'text-gray-700 hover:bg-gray-50'); ?>">
                                    <?php echo e($sib->name); ?>

                                </a>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($sib->id === $category->id && $children->isNotEmpty()): ?>
                                    <ul class="ml-3 mt-1 space-y-0.5 border-l border-gray-100 pl-2">
                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $children; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                            <li><a href="<?php echo e(category_url($child)); ?>" class="block rounded px-2 py-1 text-gray-600 hover:bg-gray-50"><?php echo e($child->name); ?></a></li>
                                        <?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; ?>
                                    </ul>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            </li>
                        <?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; ?>
                    </ul>
                </div>

                
                <div class="card space-y-4 p-4">
                    <h3 class="text-sm font-semibold text-gray-800">Фильтры</h3>

                    <div>
                        <label class="mb-1 block text-xs text-muted">Цена, ₽</label>
                        <div class="flex items-center gap-2">
                            <input type="number" name="price_min" value="<?php echo e(request('price_min')); ?>" placeholder="от" class="input px-2 py-1.5 text-sm">
                            <input type="number" name="price_max" value="<?php echo e(request('price_max')); ?>" placeholder="до" class="input px-2 py-1.5 text-sm">
                        </div>
                    </div>

                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $filters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $filter): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <div>
                            <label class="mb-1 block text-xs text-muted"><?php echo e($filter->label); ?></label>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($filter->type === 'select' || $filter->type === 'bool'): ?>
                                <select name="attr[<?php echo e($filter->key); ?>]" onchange="this.form.submit()" class="input px-2 py-1.5 text-sm">
                                    <option value="">Любой</option>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = ($filter->type === 'bool' ? ['Да','Нет'] : ($filter->options ?? [])); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                        <option value="<?php echo e($opt); ?>" <?php if(request("attr.{$filter->key}") === (string)$opt): echo 'selected'; endif; ?>><?php echo e($opt); ?><?php echo e($filter->unit ? ' '.$filter->unit : ''); ?></option>
                                    <?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; ?>
                                </select>
                            <?php elseif($filter->type === 'number'): ?>
                                <div class="flex items-center gap-2">
                                    <input type="number" inputmode="decimal" name="attr[<?php echo e($filter->key); ?>][min]" value="<?php echo e(request("attr.{$filter->key}.min")); ?>" placeholder="от" class="input px-2 py-1.5 text-sm">
                                    <input type="number" inputmode="decimal" name="attr[<?php echo e($filter->key); ?>][max]" value="<?php echo e(request("attr.{$filter->key}.max")); ?>" placeholder="до" class="input px-2 py-1.5 text-sm">
                                </div>
                            <?php else: ?>
                                <input type="text" name="attr[<?php echo e($filter->key); ?>]" value="<?php echo e(request("attr.{$filter->key}")); ?>" class="input px-2 py-1.5 text-sm">
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    <?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; ?>

                    <button type="submit" class="btn-brand w-full py-2 text-sm">Применить</button>
                </div>
            </aside>

            
            <div>
                
                <div class="card mb-4 flex flex-wrap items-center justify-between gap-3 p-3">
                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($currentCity): ?>
                        <label class="flex items-center gap-2 text-sm text-gray-700">
                            <input type="checkbox" name="city_first" value="1" onchange="this.form.submit()" <?php if(request('city_first')): echo 'checked'; endif; ?>
                                   class="rounded border-gray-300 text-brand-500 focus:ring-brand-300">
                            Сначала из города <?php echo e($currentCity->name); ?>

                        </label>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                    <div class="ml-auto flex items-center gap-3">
                        <select name="sort" onchange="this.form.submit()" class="input w-auto px-2 py-1.5 text-sm">
                            <option value="" <?php if(!request('sort')): echo 'selected'; endif; ?>>Сначала новые</option>
                            <option value="price_asc" <?php if(request('sort')==='price_asc'): echo 'selected'; endif; ?>>Дешевле</option>
                            <option value="price_desc" <?php if(request('sort')==='price_desc'): echo 'selected'; endif; ?>>Дороже</option>
                        </select>

                        
                        <div class="flex overflow-hidden rounded-full border border-gray-200">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = ['grid' => '▦', 'list' => '☰', 'map' => '📍']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mode => $icon): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                <button type="button" @click="view='<?php echo e($mode); ?>'; $nextTick(() => $root.submit())"
                                        class="px-3 py-1.5 text-sm transition"
                                        :class="view === '<?php echo e($mode); ?>' ? 'bg-brand-500 text-white' : 'bg-white text-gray-600 hover:bg-gray-50'"><?php echo e($icon); ?></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>
                </div>

                
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($view === 'map'): ?>
                    <div x-data="feedMap('<?php echo e($pointsUrl); ?>', <?php echo e($mapCenter[0]); ?>, <?php echo e($mapCenter[1]); ?>)" class="relative" @keydown.escape.window="full && toggleFull()">
                        <div x-ref="map"
                             class="h-[70vh] w-full overflow-hidden rounded-xl border border-gray-200"
                             :class="full ? '!fixed !inset-0 !z-[1000] !h-screen !w-screen !rounded-none' : ''"></div>
                        
                        <button type="button" @click="toggleFull()"
                                class="z-[1001] grid h-10 w-10 place-items-center rounded-lg bg-white text-gray-700 shadow-md ring-1 ring-gray-200 hover:bg-gray-50"
                                :class="full ? 'fixed right-4 top-4' : 'absolute right-3 top-3'"
                                :title="full ? 'Свернуть карту' : 'На весь экран'">
                            <svg x-show="!full" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.8">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9m11.25-5.25h-4.5m4.5 0v4.5m0-4.5L15 9M3.75 20.25h4.5m-4.5 0v-4.5m0 4.5L9 15m11.25 5.25h-4.5m4.5 0v-4.5m0 4.5L15 15" />
                            </svg>
                            <svg x-show="full" x-cloak class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.8">
                                <path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
                            </svg>
                        </button>
                    </div>
                <?php else: ?>
                    <?php echo $__env->make('partials.feed', ['ads' => $ads, 'view' => $view, 'nextUrl' => $nextUrl], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </div>
    </form>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\laragon\www\placeo\resources\views/category/show.blade.php ENDPATH**/ ?>