@php
    $ts = themeService()->boot();
    $headerSettings = $ts->settings('header');

    // Config values
    $address = $ts->trans('header', 'header_address');
    $phone = $ts->config('header', 'header_phone', '');
    $email = $ts->config('header', 'header_email', '');
    $promoText = $ts->trans('header', 'header_promo_text');
    $promoUrl = $ts->config('header', 'header_promo_url', '');
    $storeText = $ts->trans('header', 'header_store_text', null, __('warehouses.our_shop'));
@endphp

<header class="pb-md-0 pb-0">
    {{-- Top Bar --}}
    @if($headerSettings['show_top_bar'] ?? true)
    <div class="header-top">
        <div class="container-fluid-lg">
            <div class="row">
                <div class="col-xxl-3 col-sm-9 col-10">
                    <div class="top-left-header">
                        <i class="iconly-Location icli text-white"></i>
                        <span class="text-white">
                            {{ $address }}
                            @if($phone)
                                <a class="text-white" href="tel:{{ $phone }}">{{ $phone }}</a>
                            @endif
                        </span>
                    </div>
                </div>

                <div class="col-xxl-6 col-lg-9 d-lg-block d-none">
                    <div class="header-offer">
                        <div class="notification-slider">
                            @if($promoText)
                            <div>
                                <div class="timer-notification">
                                    <h6>{!! $promoText !!}</h6>
                                </div>
                            </div>
                            @endif

                            @php $promoText2 = $ts->trans('header', 'header_promo_text_2'); @endphp
                            @if($promoText2)
                            <div>
                                <div class="timer-notification">
                                    <h6>{!! $promoText2 !!}</h6>
                                </div>
                            </div>
                            @endif
                        </div>
                    </div>
                </div>

                @if($headerSettings['show_language_switcher'] ?? true)
                <div class="col-xxl-3 col-sm-3 col-2">
                    <ul class="about-list right-nav-about">
                        <li class="right-nav-list">
                            <div class="dropdown theme-form-select">
                                <button class="btn dropdown-toggle" type="button" id="select-language" data-bs-toggle="dropdown">
                                    <span class="text-uppercase">{{ Route::locale() }}</span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-end">
                                    @foreach(Route::locales() as $locale)
                                    <li>
                                        <a class="dropdown-item" href="{{ Route::switch($locale, $element ?? null) }}">
                                            <span class="text-uppercase">{{ $locale->tag }}</span>
                                        </a>
                                    </li>
                                    @endforeach
                                </ul>
                            </div>
                        </li>
                    </ul>
                </div>
                @endif
            </div>
        </div>
    </div>
    @endif

    {{-- Main Header --}}
    <div class="top-nav top-header sticky-header">
        <div class="container-fluid-lg">
            <div class="row">
                <div class="col-12">
                    <div class="navbar-top">
                        <button class="navbar-toggler d-xl-none d-inline navbar-menu-button" type="button"
                                data-bs-toggle="offcanvas" data-bs-target="#primaryMenu">
                            <span class="navbar-toggler-icon"><i class="fa-solid fa-bars"></i></span>
                        </button>

                        <a href="{{ Route::localeSlug() }}" class="web-logo nav-logo">
                            <img src="{{ theme()->publicPath('images/florial/logo_florial_main.svg') }}" class="img-fluid blur-up lazyload" alt="">
                        </a>

                        <div class="middle-box">
                            @if($headerSettings['show_store_locator'] ?? true)
                            <div class="location-box">
                                <button class="btn location-button" data-bs-toggle="modal" data-bs-target="#locationModal">
                                    <span class="location-arrow"><i data-feather="map-pin"></i></span>
                                    <span class="locat-name">{{ $storeText }}</span>
                                    <i class="fa-solid fa-angle-down"></i>
                                </button>
                            </div>
                            @endif

                            @if($headerSettings['show_search'] ?? true)
                            <div class="search-box">
                                <div class="input-group">
                                    <input type="search" class="form-control" placeholder="{{ __('globals.search_text') }}">
                                    <button class="btn" type="button"><i data-feather="search"></i></button>
                                </div>
                            </div>
                            @endif
                        </div>

                        <div class="rightside-box">
                            <div class="search-full">
                                <div class="input-group">
                                    <span class="input-group-text"><i data-feather="search" class="font-light"></i></span>
                                    <input type="text" class="form-control search-type" placeholder="{{ __('globals.search_here') }}">
                                    <span class="input-group-text close-search"><i data-feather="x" class="font-light"></i></span>
                                </div>
                            </div>
                            <ul class="right-side-menu">
                                <li class="right-side">
                                    <div class="delivery-login-box">
                                        <div class="delivery-icon">
                                            <div class="search-box"><i data-feather="search"></i></div>
                                        </div>
                                    </div>
                                </li>

                                @if($headerSettings['show_phone_icon'] ?? true)
                                <li class="right-side">
                                    <a href="{{ $phone ? 'tel:' . $phone : '#' }}" class="delivery-login-box">
                                        <div class="delivery-icon"><i data-feather="phone-call"></i></div>
                                    </a>
                                </li>
                                @endif

                                @if($headerSettings['show_wishlist'] ?? true)
                                <li class="right-side">
                                    <a href="wishlist.html" class="btn p-0 position-relative header-wishlist">
                                        <i data-feather="heart"></i>
                                    </a>
                                </li>
                                @endif

                                @if($headerSettings['show_cart'] ?? true)
                                <li class="right-side">
                                    <x:cart::widget />
                                </li>
                                @endif

                                @if($headerSettings['show_account'] ?? true)
                                <li class="right-side onhover-dropdown">
                                    <div class="delivery-login-box">
                                        <div class="delivery-icon"><i data-feather="user"></i></div>
                                    </div>
                                    <div class="onhover-div onhover-div-login">
                                        <ul class="user-box-name">
                                            @guest
                                            <li class="product-box-contain">
                                                <a href="{{ app_route('web.login.index') }}">{{ __('auth.login') }}</a>
                                            </li>
                                            <li class="product-box-contain">
                                                <a href="{{ app_route('web.register.index') }}">{{ __('auth.register') }}</a>
                                            </li>
                                            <li class="product-box-contain">
                                                <a href="{{ app_route('web.password.request') }}">{{ __('auth.forgot_password') }}</a>
                                            </li>
                                            @else
                                            <li class="product-box-contain">
                                                <a href="{{ app_route('web.account.index') }}">{{ __('auth.my_account') }}</a>
                                            </li>
                                            <li class="product-box-contain">
                                                <form method="post" action="{{ app_route(\ViartasCore\Core\Facades\Viartas::driver()->app()->logout()) }}">
                                                    @csrf
                                                    <button type="submit" class="form-control-plaintext">{{ __('auth.logout') }}</button>
                                                </form>
                                            </li>
                                            @endguest
                                        </ul>
                                    </div>
                                </li>
                                @endif
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    {{-- Navigation Bar --}}
    <div class="container-fluid-lg">
        <div class="row">
            <div class="col-12">
                <div class="header-nav">
                    @php $mainMenuTag = $ts->menuTag('main'); @endphp
                    @php $topMenuTag = $ts->menuTag('top'); @endphp

                    <div class="header-nav-left">
                        @if($mainMenuTag)
                            {!! menu($mainMenuTag) !!}
                        @endif
                    </div>

                    <div class="header-nav-middle">
                        @if($topMenuTag)
                            {!! menu($topMenuTag) !!}
                        @endif
                    </div>

                    <div class="header-nav-right">
                        <button class="btn deal-button" data-bs-toggle="modal" data-bs-target="#deal-box">
                            <i data-feather="zap"></i>
                            <span>{{ __('checkout.week_deals') }}</span>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>
