{{-- resources/views/customer/agency/sections/categories.blade.php --}}
<section class="categories-section" style="background: white;">
    <div class="container">
        @if($section->title || $section->subtitle)
            <div style="text-align: center; margin-bottom: 4rem;">
                @if($section->subtitle)
                    <p style="color: var(--accent); font-weight: 600; font-size: 1rem; margin-bottom: 0.5rem;">
                        {{ $section->subtitle }}
                    </p>
                @endif

                @if($section->title)
                    <h2 style="font-size: 2.75rem; font-weight: 800; color: #111827;">
                        {{ $section->title }}
                    </h2>
                @endif
            </div>
        @endif

        @php
            $categories = \App\Models\Product\ProductCategory::where('agency_id', $agency->id)
                ->active()
                ->public()
                ->whereNull('parent_id')
                ->withCount('products')
                ->orderBy('sort_order')
                ->limit($section->getConfig('category_limit', 8))
                ->get();
        @endphp

        <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem;">
            @foreach($categories as $category)
                <a href=""
                   style="text-decoration: none; display: block; position: relative; border-radius: 20px; overflow: hidden; height: 320px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); transition: all 0.3s;">

                    @if($category->image)
                        <img src="{{ asset('storage/' . $category->image) }}"
                             alt="{{ $category->name }}"
                             style="width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s;">
                    @else
                        <div style="width: 100%; height: 100%; background: linear-gradient(135deg, {{ '#' . str_pad(dechex(mt_rand(0, 16777215)), 6, '0', STR_PAD_LEFT) }}, {{ '#' . str_pad(dechex(mt_rand(0, 16777215)), 6, '0', STR_PAD_LEFT) }});"></div>
                    @endif

                    <div style="position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 60%); display: flex; flex-direction: column; justify-content: flex-end; padding: 2rem;">
                        @if($category->icon)
                            <i class="{{ $category->icon }}" style="font-size: 2.5rem; color: white; margin-bottom: 1rem;"></i>
                        @endif

                        <h3 style="color: white; font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem;">
                            {{ $category->name }}
                        </h3>

                        <p style="color: rgba(255,255,255,0.9); font-size: 0.938rem; margin-bottom: 1rem;">
                            {{ $category->short_description ?? Str::limit($category->description, 60) }}
                        </p>

                        <div style="display: flex; justify-content: space-between; align-items: center;">
                            <span style="color: white; font-size: 0.875rem; opacity: 0.9;">
                                <i class="fas fa-map-marked-alt"></i> {{ $category->products_count }} Ürün
                            </span>
                            <span style="background: white; color: var(--primary); padding: 0.5rem 1.25rem; border-radius: 50px; font-weight: 600; font-size: 0.875rem;">
                                Keşfet <i class="fas fa-arrow-right"></i>
                            </span>
                        </div>
                    </div>
                </a>
            @endforeach
        </div>
    </div>
</section>

<style>
    .categories-section a:hover img {
        transform: scale(1.15);
    }

    .categories-section a:hover {
        transform: translateY(-8px);
        box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    }
</style>
