<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Fonts -->

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    @vite(['resources/sass/app.scss', 'resources/js/app.js', 'resources/js/multiselect.js', 'resources/js/zoomable.js', 'resources/css/app.css', 'resources/css/form.css', 'resources/css/docs.css', 'resources/css/plan7.css', 'resources/css/zoomable.css', 'resources/css/multiselect.css'])
    @include('layouts.design')
    @trixassets
    <script src="https://plan7.ru/catalog/exp/cat.js"></script>
</head>

<body>
    <div id="app">
        <nav class="navbar navbar-expand-md bg-body-tertiary shadow-sm">
            <div class="container d-flex flex-row">
                <div class=" text-center">
                    <a class="navbar-brand">
                        @if(array_key_exists('logo', DESIGN_PARAMETERS))
                        <img src="{{ url('/storage/' . DESIGN_PARAMETERS['logo']) }}" alt="Logo" height="70">
                        @else
                        <img src={{ url('/images/logo.png') }} alt="Logo" height="70">
                        @endif
                    </a>
                </div>
                <div class="flex-fill px-0 px-md-4 text-start text-truncate fw-light fs-4 text-secondary text-uppercase"
                    id="pageTitle">
                    @isset($title)
                    {{ $title }}
                    @endisset
                </div>
                <!-- Right Side Of Navbar -->
                <div class="d-flex flex-row align-items-center">
                    <div class="nav-item d-none d-lg-block">
                        @livewire('citymanagerinfo')
                    </div>
                    <div class="vr mx-3 d-none d-md-block"></div>
                    <div class="nav-item">
                        @livewire('notices.user-notices-button')
                    </div>
                    <div class="dropdown">
                        <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button"
                            data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                            <img src="../../images/icons/user.png" class="img-fluid align-middle" style="height: 40px;">
                        </a>

                        <div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown"
                            style="z-index:3000;">
                            <a class="dropdown-item" href="/profile">
                                Профиль
                            </a>
                            <a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();">
                                Выйти
                            </a>
                            <hr class="dropdown-divider">
                            <a class="dropdown-item" href="#" data-bs-toggle="modal"
                                data-bs-target="#helpDeleteContract">
                                <i class="bi bi-question-diamond"></i> Помощь
                            </a>

                            <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
                                @csrf
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </nav>

        <!-- Modal -->
        <div class="modal fade" id="helpDeleteContract" tabindex="-1" aria-labelledby="helpDeleteContractlLabel"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h1 class="modal-title fs-5" id="helpDeleteContractLabel">Заявка в техническую поддержку</h1>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <div class="form-floating">
                            <select class="form-select" id="floatingSelect" aria-label="Выберите тему обращения">
                                <option value="1">Изменить данные профиля</option>
                                <option value="2">Удалить сделку</option>
                                <option value="3">Другое</option>
                            </select>
                            <label for="floatingSelect">Выберите тему обращения</label>
                        </div>
                        <div class="form-floating mt-3">
                            <textarea rows="4" class="form-control" placeholder="Оставьте текст обращения в этом поле"
                                id="floatingTextarea"></textarea>
                            <label for="floatingTextarea">Текст обращения</label>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
                        <button type="button" class="btn btn-primary">Отправить</button>
                    </div>
                </div>
            </div>
        </div>

        <main class="py-4">
            <div class="container ">
                <div class="d-flex flex-row justify-content-center">
                    <div class="d-flex flex-column" id="leftPanel">
                        @include('left-panel')
                    </div>
                    <div class="px-0 px-md-4 w-100">
                        @if (session('success'))
                        <div class="alert alert-success">
                            {{ session('success') }}
                        </div>
                        @endif
                        @foreach ($errors->all() as $error)
                        {{ $error }}
                        @endforeach
                        @yield('content')
                    </div>
                </div>
            </div>

        </main>
    </div>
    @if(array_key_exists('plan7_iframe', DESIGN_PARAMETERS))
    <!-- Plan 7 Modal -->
    <div class="modal fade" id="plan7Modal" style="z-index:3000" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-fullscreen">
            <div class="modal-content">
                <div class="modal-header">
                    <h1 class="modal-title fs-5" id="exampleModalLabel">
                        <button class="btn btn-light" data-bs-dismiss="modal">
                            <i class="bi bi-chevron-left"></i>
                        </button>
                        Подбор квартиры
                    </h1>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <div id="catalogFrame" data-multicat="1" style="position:relative; width:100%; height:240px;">
                        <iframe src="{{ DESIGN_PARAMETERS['plan7_iframe'] }}" style="position:absolute; left:0px; top:0px; width:100%; height:100%; border:none;"></iframe>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-bs-dismiss="modal">Закрыть</button>
                </div>
            </div>
        </div>
    </div>
    @endif
    @include('notice::index')

    <script>
        (function(w, d, u) {
            var s = d.createElement('script');
            s.async = true;
            s.src = u + '?' + (Date.now() / 60000 | 0);
            var h = d.getElementsByTagName('script')[0];
            h.parentNode.insertBefore(s, h);
        })(window, document, 'https://bx.zachem.info/upload/crm/site_button/loader_1_wnj4gb.js');
        window.addEventListener('onBitrixLiveChat', function(event) {
            var widget = event.detail.widget;
            widget.setCustomData("[b]{{ auth()->user()->name }}[/b] ({{ auth()->user()->email }})");
            widget.setCustomData("Роли: {{ implode(', ', auth()->user()->roles->pluck('name')->toArray()) }}");
        });
    </script>

</body>

</html>