<template>
    <div class="wrapper">
        <Sidebar/>
        <div class="main" id="page">
            <nav class="navbar navbar-expand navbar-light navbar-bg">
                <a class="sidebar-toggle d-flex" @click="toggleSidebar">
                    <i class="hamburger align-self-center"></i>
                </a>
                <SearchBox/>
                <div class="navbar-collapse collapse">
                    <ul class="navbar-nav navbar-align">
                        <Notifications :notifications="notifications"/>
                        <Messages :messages="messages"/>
                        <UserDropdown/>
                    </ul>
                </div>
            </nav>
            <slot></slot>
            <Footer/>
        </div>
    </div>
</template>

<script>
import {mapGetters, mapMutations, mapState} from 'vuex';
import Notifications from "@/components/Notifications.vue";
import Messages from "@/components/Messages.vue";
import Footer from "@/components/Footer.vue";
import Sidebar from "@/components/Sidebar.vue";
import UserDropdown from "@/components/UserDropdown.vue";
import SearchBox from "@/components/SearchBox.vue";

export default {
    name: 'BaseLayout',
    components: {
        SearchBox,
        UserDropdown,
        Sidebar,
        Footer,
        Messages,
        Notifications
    },
    computed: {
        ...mapState(['messages']),
        ...mapGetters(['notifications']),
    },
    props: {
        hideSearch: {
            type: Boolean,
            required: false,
            default: false
        }
    },
    methods: {
        toggleSidebar() {
            closeAllDropdowns();
            document.getElementById("sidebar").classList.toggle("collapsed");
            document.getElementById("page").classList.toggle("expanded");
        },
    },
}
</script>

<style scoped>

.wrapper {
    align-items: stretch;
    display: flex;
    width: 100%;
}

.main {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    transition: margin-left .35s ease-in-out, left .35s ease-in-out, margin-right .35s ease-in-out, right .35s ease-in-out;
    flex-direction: column;
    overflow: hidden;
}

.navbar-expand {
    flex-wrap: nowrap;
    justify-content: flex-start;
}

.navbar {
    border-bottom: 0;
    padding: .875rem 1.375rem;
    box-shadow: 0 0 2rem var(--bs-shadow)
}

.navbar-align {
    margin-left: auto;
}

.navbar-bg {
    background: var(--bs-white);
}

.sidebar-toggle {
    cursor: pointer;
    width: 26px;
    height: 26px;
    margin-right: 1rem;
}

.hamburger {
    position: relative;

    &, &:after, &:before {
        cursor: pointer;
        border-radius: 1px;
        height: 3px;
        width: 24px;
        background: var(--bs-gray-700);
        display: block;
        content: "";
        transition: background .1s ease-in-out, color .1s ease-in-out
    }

    &:before {
        top: -7.5px;
        width: 24px;
        position: absolute
    }

    &:after {
        bottom: -7.5px;
        width: 16px;
        position: absolute
    }
}

.sidebar-toggle:hover {
    .hamburger, .hamburger:after, .hamburger:before {
        background: var(--bs-primary);
    }
}


</style>

<style>
.nav-flag::after, .nav-icon::after {
    display: none !important;
}

.nav-flag .feather, .nav-flag svg, .nav-icon .feather, .nav-icon svg {
    width: 20px;
    height: 20px;
}

.nav-flag, .nav-icon {
    padding: .1rem .8rem;
    display: block;
    font-size: 1.5rem;
    color: #6c757d;
    transition: background .1s ease-in-out, color .1s ease-in-out;
    line-height: 1.4;
}

.nav-item .indicator {
    background: #3b7ddd;
    box-shadow: 0 .1rem .2rem #0000000d;
    border-radius: 50%;
    display: block;
    height: 18px;
    width: 18px;
    padding: 1px;
    position: absolute;
    top: 0;
    right: -8px;
    text-align: center;
    transition: top .1s ease-out;
    font-size: .675rem;
    color: #fff;
}

</style>