@php
    $footerContent = getContent('footer.content', true);
    $socialIcons = getContent('social_icon.element', false, 4, true);
    $policyPages = getContent('policy_pages.element', false,null, true);
    $languages = App\Models\Language::get();
    $defaultLanguage = $languages->where('code', app()->getLocale())->first();
@endphp
<footer class="footer bg-img" data-background-image="{{ asset(activeTemplate(true) . 'images/footer/bg.png') }}">
    <div class="container">
        <div class="footer-top py-60">
            <div class="footer-top__inner">
                <h2 class="footer-top__title">
                    {{ __($footerContent?->data_values?->heading ?? '') }}
                </h2>
                <a class="btn btn-outline--base-two" href="{{ url($footerContent?->data_values?->button_url ?? '') }}">
                    <span class="btn__text">{{ __($footerContent?->data_values?->button_text ?? '') }}</span>
                    <span class="btn__icon">
                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
                            fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
                            stroke-linejoin="round" class="lucide lucide-arrow-up-right-icon lucide-arrow-up-right">
                            <path d="M7 7h10v10"></path>
                            <path d="M7 17 17 7"></path>
                        </svg>
                    </span>
                </a>
            </div>
        </div>
        <div class="footer-main py-60">
            <div class="row gy-4">
                <div class="col-lg-4">
                    <a class="footer-logo" href="{{ route('home') }}">
                        <img src="{{ siteLogo() }}" alt="">
                    </a>
                    <p class="footer-desc">
                        @php
                            echo trans($footerContent?->data_values?->description ?? '');
                        @endphp
                    </p>
                    <ul class="social-list style-two">
                        @foreach ($socialIcons as $icon)
                            <li class="social-list__item">
                                <a href="{{ $icon->data_values?->url }}" class="social-list__link" target="_blank">
                                    @php echo $icon?->data_values?->social_icon ?? '' @endphp
                                </a>
                            </li>
                        @endforeach
                    </ul>
                </div>
                <div class="col-lg-8">
                    <div class="row gy-4">
                        <div class="col-6 col-md-3">
                            <div class="footer-item w-lg-fit-content mx-auto">
                                <h6 class="footer-item__title">@lang('Site Links')</h6>
                                <ul class="footer-menu">
                                    <li class="footer-menu__item">
                                        <a class="footer-menu__link" href="{{ route('home') }}">
                                            @lang('Home')
                                        </a>
                                    </li>
                                    <li class="footer-menu__item">
                                        <a class="footer-menu__link" href="{{ route('domain.list') }}">
                                            @lang('Domains')
                                        </a>
                                    </li>
                                    <li class="footer-menu__item">
                                        <a class="footer-menu__link" href="{{ route('blog') }}">
                                            @lang('Blogs')
                                        </a>
                                    </li>
                                    <li class="footer-menu__item">
                                        <a class="footer-menu__link" href="{{ route('contact') }}">
                                            @lang('Contact')
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="col-6 col-md-3">
                            <div class="footer-item w-lg-fit-content mx-auto">
                                <h6 class="footer-item__title">@lang('Polices')</h6>
                                <ul class="footer-menu">
                                    <li class="footer-menu__item">
                                        <a class="footer-menu__link" href="{{ route('cookie.policy') }}">
                                            @lang('Cookie Policy')
                                        </a>
                                    </li>
                                    @foreach ($policyPages as $policy)
                                        <li class="footer-menu__item">
                                            <a class="footer-menu__link"
                                                href="{{ route('policy.pages', $policy->slug) }}">
                                                {{ __(@$policy?->data_values?->title ?? '') }}
                                            </a>
                                        </li>
                                    @endforeach
                                </ul>
                            </div>
                        </div>
                        <div class="col-12 col-md-6">
                            <div class="footer-item w-lg-fit-content mx-auto">
                                <h6 class="footer-item__title">
                                    {{ __($footerContent?->data_values?->subscribe_heading ?? '') }}</h6>
                                <p class="footer-item__desc">
                                    {{ __($footerContent?->data_values?->subscribe_description ?? '') }}</p>
                                <form class="footer-form" id="subscribeForm">
                                    <input class="footer-form__input" type="email" name="email" id="email"
                                        placeholder="@lang('What\'s your work email')?">
                                    <button class="btn btn--base-two" type="submit">
                                        <span class="btn__text">@lang('Subscribe')</span>
                                        <span class="btn__icon">
                                            <svg width="128" height="128" viewBox="0 0 24 24" fill="none"
                                                class="injected-svg" role="img" color="currentColor">
                                                <path
                                                    d="M22.3886 3.50934C22.9207 2.01947 21.4821 0.58092 19.9922 1.11301L2.24451 7.45149C0.477797 8.08246 0.630218 10.6298 2.45959 11.0455L9.59327 12.648L13.3909 8.73607C13.7756 8.3398 14.4087 8.33041 14.8049 8.7151C15.2012 9.09979 15.2106 9.73289 14.8259 10.1292L10.9106 14.1623L12.456 21.042C12.8718 22.8714 15.4191 23.0238 16.0501 21.2571L22.3886 3.50934Z"
                                                    fill="currentColor"></path>
                                            </svg>
                                        </span>
                                    </button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="footer-bottom">
            <p class="footer-copyright">
                @lang('Copyright') &copy; @php echo date('Y') @endphp @lang('All Rights
                                    Reserved by')
                <a href="{{ route('home') }}" class="text--base-two">{{ __(gs()->site_name) }}</a>
            </p>


            <div class="dropdown dropdown--lang">
                <button class="dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                    <span class="icon">
                        <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 16 16"
                            fill="none" preserveAspectRatio="xMidYMid meet" aria-hidden="true" role="img">
                            <path d="M1.5 8H14.5" stroke="currentColor" stroke-width="1.21" stroke-linecap="round"
                                stroke-linejoin="round"></path>
                            <path
                                d="M8 14.5C11.5899 14.5 14.5 11.5899 14.5 8C14.5 4.41015 11.5899 1.5 8 1.5C4.41015 1.5 1.5 4.41015 1.5 8C1.5 11.5899 4.41015 14.5 8 14.5Z"
                                stroke="currentColor" stroke-width="1.21" stroke-linecap="round"
                                stroke-linejoin="round"></path>
                            <path
                                d="M10.7083 8C10.7083 12.3333 7.99996 14.5 7.99996 14.5C7.99996 14.5 5.29163 12.3333 5.29163 8C5.29163 3.66667 7.99996 1.5 7.99996 1.5C7.99996 1.5 10.7083 3.66667 10.7083 8Z"
                                stroke="currentColor" stroke-width="1.21" stroke-linecap="round"
                                stroke-linejoin="round"></path>
                        </svg>
                    </span>
                    <span class="text"> {{ __(strtoupper($defaultLanguage->code)) }} </span>
                </button>
                <div class="dropdown-menu">
                    @foreach ($languages as $language)
                        <a class="dropdown-item {{ $defaultLanguage->code == $language->code ? 'active' : '' }}"
                            href="{{ route('lang', $language->code) }}">
                            <img class="lang-flag"
                                src="{{ getImage(getFilePath('language') . '/' . $language->image, getFileSize('language')) }}"
                                alt="">
                            <span class="lang-text"> {{ __(strtoupper($language->code)) }}</span>
                        </a>
                    @endforeach
                </div>
            </div>
        </div>
    </div>
</footer>

@push('script')
    <script>
        (function($) {
            "use strict";
            $('#subscribeForm').on('submit', function(e) {
                e.preventDefault();
                var email = $('#email').val();
                if (email == '') {
                    notify('error', 'Please enter email address');
                    return;
                }
                var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

                if (!emailPattern.test(email)) {
                    notify('error', 'Please enter a valid email address');
                    return;
                }

                $.ajax({
                    type: "POST",
                    url: "{{ route('subscribe.post') }}",
                    data: {
                        email: email,
                        _token: "{{ csrf_token() }}"
                    },
                    success: function(response) {
                        if (response.success) {
                            $('#email').val('');
                            notify('success', response.success);
                        } else {
                            notify('error', response.error);
                        }
                    }
                });
            });
        })(jQuery);
    </script>
@endpush
