<div >

    {{-- Menu --}}
    <!-- main menu widget-->
    <livewire:widgets.custom :widget="widget('main_menu')" :view="'theme::widgets.main_menu'" />
    <!--/ main menu widget -->

    {{--    title --}}
    <div class="w-full mt-16 relative">
        <div class="absolute xl:w-[750px] lg:w-[600px] min-h-[calc(100vh+140px)] md:w-[600px] w-[400px] top-0 -right-40 rounded-tl-[140px] rounded-bl-[140px] skew-x-[-15deg] before:w-full before:bg-gray-300 h-full
      bg-gradient-to-b from-white to-gray-100
      z-[-1]"></div>

        <div class="container mx-auto z-0">
            <div class="p-3 flex justify-between relative">
                <div class="">
                    <h3 class="font-bold text-xl w-[170px] lg:w-[330px] sm:w-[220px] text-center lg:text-right  text-gray-700">ویدیوها</h3>
                </div>
            </div>
        </div>
    </div>

    {{-- Filter --}}
    <div x-data="sticky" x-init="hand_sticky($el, 'bg-gray-200 shadow-sm')"  class="sticky top-[3.6rem] z-50">

        <div x-data="more_btn">
            <div class="container mx-auto">
                <div class="scrollbar scrollbar-none overflow-scroll">
                    <div class="flex justify-between">
                        <div class="p-3 flex flex-nowrap w-full items-center space-x-2 rtl:space-x-reverse">
                            <div class="text-brand-500 rounded-full  py-0 px-2 flex items-center cursor-pointer" x-on:click="more_text_open()">
                                <i class="las la-filter text-xl py-1 cursor-pointer"></i>
                                <span class="text-base">فیلتر</span>
                            </div>
                            @foreach($filter_labels as $key => $filter)
                            <div class="text-gray-700 rounded-full bg-gray-50 shadow-md pr-3 flex items-center">
                                <span class="text-xs w-max">{{$filter['label']}}</span>
                                <div class="text-gray-700 rounded-full bg-white py-0 px-2 flex items-center mr-2">
                                    <span class="text-sm ">{{$filter['value']}}</span>
                                    <i wire:loading.remove wire:target="removeFilter('{{$filter['slug']}}',{{$key}})" wire:click="removeFilter('{{$filter['slug']}}',{{$key}})" class="las la-times text-xl py-1 cursor-pointer hover:text-red-400 mr-2"></i>
                                    <div wire:loading wire:target="removeFilter('{{$filter['slug']}}',{{$key}})" role="status" class="mr-2 p-2">
                                        <svg aria-hidden="true" class="w-5 h-5 text-gray-200 animate-spin dark:text-gray-600 fill-red-400" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
                                            <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
                                            <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
                                        </svg>
                                        <span class="sr-only">Loading...</span>
                                    </div>
                                </div>
                            </div>
                            @endforeach

                        </div>

                    </div>
                </div>
            </div>

            <div class="fixed w-full h-full bg-gray-500 top-0 z-50 bg-opacity-20" x-show="more_btn"
                 x-transition:enter="transition ease-in-out duration-300 transform"
                 x-transition:enter-start="translate-x-10"
                 x-transition:enter-end="translate-x-0 "
                 x-cloak
            >
                <form wire:submit="save" class="sm:w-96 w-full h-full fixed right-0 top-0 bottom-0 bg-white shadow-lg z-50 " x-on:click.away="more_text_close()">

                    <!-- sidebar header -->
                    <div class="flex flex-wrap justify-between items-right mx-auto max-w-screen-xl">
                        <div class="flex flex-wrap">
                            <div class="flex items-center align-middle cursor-pointer" x-on:click="more_text_close()">
                                <i class="las la-times mr-3 text-xl" ></i>
                            </div>
                            <span class="p-3" >فیلترها</span>
                        </div>
                        <div class="flex items-center md:order-2 relative" >
                            <a wire:click="clearTags()" @click.prevent="show" href="#" class="text-red-500 p-3 focus:ring-4  text-sm text-smfocus:outline-none">حذف فیلترها</a>
                        </div>
                    </div>

                    <!-- filters Accordion -->
                    <div class="mt-5" x-data="accordion">
                        @foreach($filters as $filter)
                            @if(sizeof($filter['items']))
                                <div class="border-b border-b-slate-200 border-gray-210">
                                    <div class="">
                                        <div @click="collapseHandler({{$filter['id']}})" class="bg-white flex items-center justify-between py-5 lg:px-5 px-3 cursor-pointer">
                                            <div class="flex items-center">
                                                <h3 :class="{'!text-[#007f3f]': isActive({{$filter['id']}})}" class="text-sm font-bold text-gray-800">
                                                    {{$filter['title']}}</h3>
                                            </div>
                                            <span class="transition duration-200 transform rotate-90 text-gray-800" :class="{' !rotate-0 !text-[#007f3f]' : isActive({{$filter['id']}})}">
                                                <svg width="16" height="10" viewBox="0 0 16 10" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                    <path d="M1 1.5L8 8.5L15 1.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
                                                </svg>
                                            </span>
                                        </div>
                                        <div x-show="isActive({{$filter['id']}})" x-cloak x-transition class="">
                                            <div class="content-area text-gray-360">
                                                <div id="dropdownSearch" class="bg-white">
                                                    <div class="p-3">
                                                        <label for="input-group-search" class="sr-only">جستجو</label>
                                                        <div class="relative">
                                                            <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
                                                                <svg class="w-4 h-4 text-gray-500" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
                                                                    <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
                                                                </svg>
                                                            </div>
                                                            <input type="text" id="input-group-search" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full ps-10 p-2.5" placeholder="جستجو">
                                                        </div>
                                                    </div>
                                                    <ul class="h-48 px-3 pb-3 overflow-y-auto text-sm text-gray-700 " aria-labelledby="dropdownSearchButton">
                                                        @foreach($filter['items'] as $id => $item)
                                                        <li>
                                                            <div class="flex items-center p-2 rounded hover:bg-gray-100 ">
                                                                <input id="checkbox-item-{{$filter['id']}}-{{$id}}" type="checkbox" wire:model="tags.{{$filter['slug']}}.{{$id}}" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
                                                                <label for="checkbox-item-{{$filter['id']}}-{{$id}}" class="w-full ms-2 text-sm font-medium text-gray-900 rounded ">{{$item}}</label>
                                                            </div>
                                                        </li>
                                                        @endforeach
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            @endif
                        @endforeach
                    </div>

                    <!-- Sidebar Footer -->
                    <div class="sm:w-96 w-full p-3 bg-gray-100 fixed bottom-0 right-0 left-0">
                        <button type="submit" class="bg-[#007f3f] text-white focus:ring-4 font-bold rounded-lg text-sm px-4 py-2 md:px-8 md:py-2.5 w-full block text-center focus:outline-none">
                            <span wire:loading.remove wire:target="save">اعمال فیلترها</span>

                            <div wire:loading wire:target="save" role="status" class="">
                                <svg aria-hidden="true" class="w-5 h-5 text-gray-200 animate-spin dark:text-gray-600 fill-red-400" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
                                    <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
                                </svg>
                                <span class="sr-only">Loading...</span>
                            </div>
                        </button>
                    </div>
                </form>

            </div>
        </div>

    </div>

    {{-- Videos --}}
    <div class="w-full relative overflow-hidden z-0">
        <div class="container mx-auto z-0">
            <div class="px-4 md:px-0 pt-9">
                <div class="grid grid-cols-1 lg:grid-cols-4 md:grid-cols-3 gap-3">
                    @foreach($videos as $video)
                        <a href="{{$video->path()}}" class="swiper-slide p-0 overflow-hidden">
                            <div  class="w-full"><div class="relative rounded-md" >
                                    <img class="rounded-md w-full" src="{{$video->get_poster()}}" alt="">
                                </div>
                                <div>
                                    <div  class="text-center w-full text-bold text-sm text-gray-700 p-2 block">{{$video->title}}</div>
                                </div>
                            </div>
                        </a>
                    @endforeach
                </div>
                <div class="container block mt-16">
                    {{ $videos->links('theme::partials.paigination') }}
                </div>
            </div>
        </div>
    </div>
    <div class="mt-16"></div>
</div>
