<div id="navbar_vue" class="nav-header nav-header-classic menu-space header-position header-white">
    <div class="{{ \Str::contains(url()->current(), 'dashboard') ? 'dashboard-container' : 'container' }}">
        <div class="row">
            <div class="col-md-12">

                <!-- Vue Alert message -->
                @if ($errors->any())
                    <alert-message :errors="{{ json_encode($errors->all(), JSON_HEX_APOS) }}"></alert-message>
                @endif

                @if (session('status'))
                    <alert-message :message="'{{ session('status') }}'"></alert-message>
                @endif
                <!-- Vue Alert message -->

                <nav class="navbar navbar-expand-lg py-1">
                    <a class="navbar-brand d-flex align-items-center gap-2" href="{{ url('') }}">
                        <img src="{{ getStorageImage(setting('site.logo')) }}" 
                        class="mx-auto d-blocks {{ App::isLocale('ar') ? 'float-end' : 'float-start' }}"
                            alt="{{ setting('site.site_name') }}" 
                            style="height: 40px; width: auto;">
                        <span class="fw-bold fs-6 text-white">{{ setting('site.site_name') }}</span>
                    </a>

                    <button class="navbar-toggler collapsed" type="button" data-bs-toggle="collapse"
                        data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation" id='navbartoggler'>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>


                    <div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
                        <ul class="navbar-nav">
                            <!-- Authentication Links -->
                            @guest
                                @include('eventmie::layouts.guest_header')
                            @else
                                @include('eventmie::layouts.member_header')
                            @endguest

                            <li class="nav-item d-lg-none">
                                <a href="{{ route('eventmie.venues.index') }}"
                                    class="nav-link">
                                    <i class="fas fa-map-location"></i> @lang('eventmie-pro::em.venues')
                                </a>
                            </li>
                            <li class="nav-item d-lg-none">
                                <a href="{{ route('eventmie.events_index') }}"
                                    class="nav-link">
                                    <i class="fas fa-calendar-day"></i> @lang('eventmie-pro::em.browse_events')
                                </a>
                            </li>

                            <!-- Theme Toggle for Mobile -->
                            <li class="nav-item dropdown d-lg-none">
                                <a class="nav-link dropdown-toggle" href="javascript:void(0)" id="mobileThemeToggle" data-bs-toggle="dropdown" aria-expanded="false">
                                    <i class="fas fa-circle-half-stroke"></i> @lang('eventmie-pro::em.theme')
                                </a>
                                <ul class="dropdown-menu" aria-labelledby="mobileThemeToggle">
                                    <li>
                                        <button class="dropdown-item" type="button" data-theme="light">
                                            <i class="fas fa-sun me-2"></i>@lang('eventmie-pro::em.theme_light')
                                        </button>
                                    </li>
                                    <li>
                                        <button class="dropdown-item" type="button" data-theme="dark">
                                            <i class="fas fa-moon me-2"></i>@lang('eventmie-pro::em.theme_dark')
                                        </button>
                                    </li>
                                    <li>
                                        <button class="dropdown-item" type="button" data-theme="auto">
                                            <i class="fas fa-circle-half-stroke me-2"></i>@lang('eventmie-pro::em.theme_auto')
                                        </button>
                                    </li>
                                </ul>
                            </li>

                            {{-- Additional menu items for mobile --}}
                            @php $headerMenuItems = headerMenu() @endphp
                            @if (!empty($headerMenuItems))
                                <li class="nav-item dropdown d-lg-none">
                                    <a class="nav-link dropdown-toggle" href="javascript:void(0)" 
                                        data-bs-toggle="dropdown" aria-expanded="false">
                                        <i class="fas fa-grip-vertical"></i> @lang('eventmie-pro::em.more')
                                    </a>
                                    <ul class="dropdown-menu dropdown-menu-start">
                                        @foreach ($headerMenuItems as $parentItem)
                                            @if (!empty($parentItem->submenu))
                                                <li class="nav-item dropdown">
                                                    <a class="dropdown-item dropdown-toggle" href="javascript:void(0)"
                                                        data-bs-toggle="dropdown">
                                                        <i class="{{ $parentItem->icon_class }}"></i>
                                                        {{ $parentItem->title }}
                                                    </a>
                                                    <ul class="dropdown-menu dropdown-menu-start">
                                                        @foreach ($parentItem->submenu as $childItem)
                                                            <li>
                                                                <a class="dropdown-item"
                                                                    target="{{ $childItem->target }}"
                                                                    href="{{ $childItem->url }}">
                                                                    <i class="{{ $childItem->icon_class }}"></i>
                                                                    {{ $childItem->title }}
                                                                </a>
                                                            </li>
                                                        @endforeach
                                                    </ul>
                                                </li>
                                            @else
                                                <li>
                                                    <a class="dropdown-item" target="{{ $parentItem->target }}"
                                                        href="{{ $parentItem->url }}">
                                                        <i class="{{ $parentItem->icon_class }}"></i>
                                                        {{ $parentItem->title }}
                                                    </a>
                                                </li>
                                            @endif
                                        @endforeach
                                    </ul>
                                </li>
                            @endif
                        </ul>
                        
                        {{-- Desktop buttons --}}
                        <div class="d-none d-lg-flex">
                            <a href="{{ route('eventmie.venues.index') }}"
                                class="btn text-white">
                                <i class="fas fa-map-location"></i> @lang('eventmie-pro::em.venues')
                            </a>
                            <a href="{{ route('eventmie.events_index') }}"
                                class="btn btn-primary bg-gradient">
                                <i class="fas fa-calendar-day"></i> @lang('eventmie-pro::em.browse_events')
                            </a>
                        </div>

                        <!-- Theme Toggle Dropdown for Desktop -->
                        <ul class="navbar-nav ms-lg-2 d-none d-lg-flex">
                            <li class="nav-item dropdown">
                                <a id="themeToggle" class="nav-link dropdown-toggle" href="javascript:void(0)" data-bs-toggle="dropdown" aria-expanded="false">
                                    <i class="fas fa-sun"></i>
                                </a>
                                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="themeToggle">
                                    <li>
                                        <button class="dropdown-item" type="button" data-theme="light">
                                            <i class="fas fa-sun me-2"></i>@lang('eventmie-pro::em.theme_light')
                                        </button>
                                    </li>
                                    <li>
                                        <button class="dropdown-item" type="button" data-theme="dark">
                                            <i class="fas fa-moon me-2"></i>@lang('eventmie-pro::em.theme_dark')
                                        </button>
                                    </li>
                                    <li>
                                        <button class="dropdown-item" type="button" data-theme="auto">
                                            <i class="fas fa-circle-half-stroke me-2"></i>@lang('eventmie-pro::em.theme_auto')
                                        </button>
                                    </li>
                                </ul>
                            </li>
                        </ul>

                        {{-- More menu for desktop --}}
                        <ul class="navbar-nav ms-lg-2 d-none d-lg-flex">
                            @if (!empty($headerMenuItems))
                                <li class="nav-item dropdown">
                                    <a class="nav-link dropdown-toggle" href="javascript:void(0)" 
                                        data-bs-toggle="dropdown" aria-expanded="false">
                                        <i class="fas fa-grip-vertical"></i>
                                    </a>
                                    <ul class="dropdown-menu dropdown-menu-end">
                                        @foreach ($headerMenuItems as $parentItem)
                                            @if (!empty($parentItem->submenu))
                                                <li class="nav-item dropdown">
                                                    <a class="dropdown-item dropdown-toggle" href="javascript:void(0)"
                                                        data-bs-toggle="dropdown">
                                                        <i class="{{ $parentItem->icon_class }}"></i>
                                                        {{ $parentItem->title }}
                                                    </a>
                                                    <ul class="dropdown-menu dropdown-menu-end">
                                                        @foreach ($parentItem->submenu as $childItem)
                                                            <li>
                                                                <a class="dropdown-item"
                                                                    target="{{ $childItem->target }}"
                                                                    href="{{ $childItem->url }}">
                                                                    <i class="{{ $childItem->icon_class }}"></i>
                                                                    {{ $childItem->title }}
                                                                </a>
                                                            </li>
                                                        @endforeach
                                                    </ul>
                                                </li>
                                            @else
                                                <li>
                                                    <a class="dropdown-item" target="{{ $parentItem->target }}"
                                                        href="{{ $parentItem->url }}">
                                                        <i class="{{ $parentItem->icon_class }}"></i>
                                                        {{ $parentItem->title }}
                                                    </a>
                                                </li>
                                            @endif
                                        @endforeach
                                    </ul>
                                </li>
                            @endif
                        </ul>
                    </div>
                </nav>
            </div>
        </div>
    </div>
</div>
