/*
-------------------------------------------------------------------------------
4.  Layout [hm-04]

Notes:
    ~ The following section contains the position, width, height, and bg color 
    related styles of the page-wrapper, sticky-alerts, navbars, sidebar, and 
    content-wrapper. These are grouped together because reading them all at 
    once in serial makes it quite easy to understand how pages are structured.
    ~ The styles of the children of the above elements can be found in their 
    own sections of this stylesheet. These sections are:
        ~ 14. Alerts
        ~ 15. Navbar content
        ~ 16. Sidebar content
    ~ The page-wrapper can have additional helper classes which automatically 
    fixes the positions and the sizes of the children elements. For example, 
    .page-wrapper.with-navbar will automatically push the content-wrapper down 
    by an amount which is equal to the height of the navbar, in order to make 
    space for the navbar.
-------------------------------------------------------------------------------
*/

html,
body {
    position: absolute;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    left: 0;
    top: 0;
}

/* Page wrapper */

.page-wrapper {
    position: absolute;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* Sticky alerts */

.sticky-alerts {
    position: fixed;
    top: var(--sticky-alerts-top);
    right: var(--sticky-alerts-right);
    z-index: 100; /* Can be used on top of modals */
}

/* Navbar */

.navbar {
    position: relative;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    -ms-flex-align: center;
    align-items: center;
    -ms-flex-flow: row nowrap;
    flex-flow: row nowrap;
    -ms-flex-pack: start;
    justify-content: flex-start;
    width: 100%;
    height: var(--navbar-height);
    padding-left: var(--navbar-horizontal-padding);
    padding-right: var(--navbar-horizontal-padding);
    background-color: var(--lm-navbar-bg-color);
    background-image: var(--lm-navbar-bg-image);
    border-bottom: var(--navbar-border-width) solid var(--lm-navbar-border-color);
    -moz-box-shadow: var(--lm-navbar-box-shadow);
    -webkit-box-shadow: var(--lm-navbar-box-shadow);
    box-shadow: var(--lm-navbar-box-shadow);
}
.dark-mode .navbar {
    background-color: var(--dm-navbar-bg-color);
    background-image: var(--dm-navbar-bg-image);
    border-color: var(--dm-navbar-border-color);
    -moz-box-shadow: var(--dm-navbar-box-shadow);
    -webkit-box-shadow: var(--dm-navbar-box-shadow);
    box-shadow: var(--dm-navbar-box-shadow);
}
.navbar.navbar-fixed-bottom {
    height: var(--navbar-fixed-bottom-height);
    border-bottom: none;
    border-top: var(--navbar-border-width) solid var(--lm-navbar-border-color);
    -moz-box-shadow: var(--lm-navbar-fixed-bottom-box-shadow);
    -webkit-box-shadow: var(--lm-navbar-fixed-bottom-box-shadow);
    box-shadow: var(--lm-navbar-fixed-bottom-box-shadow);
}
.dark-mode .navbar.navbar-fixed-bottom {
    border-color: var(--dm-navbar-border-color);
    -moz-box-shadow: var(--dm-navbar-fixed-bottom-box-shadow);
    -webkit-box-shadow: var(--dm-navbar-fixed-bottom-box-shadow);
    box-shadow: var(--dm-navbar-fixed-bottom-box-shadow);
}
.navbar.navbar-static-bottom {
    border-bottom: none;
    border-top: var(--navbar-border-width) solid var(--lm-navbar-border-color);
    -moz-box-shadow: var(--lm-navbar-static-bottom-box-shadow);
    -webkit-box-shadow: var(--lm-navbar-static-bottom-box-shadow);
    box-shadow: var(--lm-navbar-static-bottom-box-shadow);
}
.dark-mode .navbar.navbar-static-bottom {
    border-color: var(--dm-navbar-border-color);
    -moz-box-shadow: var(--dm-navbar-static-bottom-box-shadow);
    -webkit-box-shadow: var(--dm-navbar-static-bottom-box-shadow);
    box-shadow: var(--dm-navbar-static-bottom-box-shadow);
}
.page-wrapper > .navbar {
    position: fixed; 
    left: 0;
    z-index: 40;
    display: none;
}
.page-wrapper > .navbar:not(.navbar-fixed-bottom) {
    top: 0;
}
.page-wrapper.with-navbar > .navbar:not(.navbar-fixed-bottom) {
    display: -ms-flexbox;
    display: flex;
}
.page-wrapper > .navbar.navbar-fixed-bottom {
    bottom: 0;
}
.page-wrapper.with-navbar-fixed-bottom > .navbar.navbar-fixed-bottom {
    display: -ms-flexbox;
    display: flex;
}

/* Sidebar */

.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    max-width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 20;
    background-color: var(--lm-sidebar-bg-color);
    background-image: var(--lm-sidebar-bg-image);
    border-right: var(--sidebar-border-width) solid var(--lm-sidebar-border-color);
    -moz-box-shadow: var(--lm-sidebar-box-shadow);
    -webkit-box-shadow: var(--lm-sidebar-box-shadow);
    box-shadow: var(--lm-sidebar-box-shadow);
}
.dark-mode .sidebar {
    background-color: var(--dm-sidebar-bg-color);
    background-image: var(--dm-sidebar-bg-image);
    border-color: var(--dm-sidebar-border-color);
    -moz-box-shadow: var(--dm-sidebar-box-shadow);
    -webkit-box-shadow: var(--dm-sidebar-box-shadow);
    box-shadow: var(--dm-sidebar-box-shadow);
}
.page-wrapper > .sidebar {
    display: none;
}
.page-wrapper.with-sidebar > .sidebar {
    display: block;
}

/* Content wrapper */

.content-wrapper {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    overflow: auto;
}

/* Page wrapper helper classes */

/* With navbar */

.page-wrapper.with-navbar > .sticky-alerts {
    top: var(--navbar-height);
}
.page-wrapper.with-navbar > .content-wrapper,
.page-wrapper.with-navbar > .sidebar {
    top: var(--navbar-height);
    height: calc(100% - var(--navbar-height));
}

/* With sidebar */

.page-wrapper.with-sidebar > .content-wrapper {
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}
@media (max-width: 768px) {
    .page-wrapper.with-sidebar > .content-wrapper {
        width: 100%;
    }
}

/* Hidden sidebar */

.page-wrapper.with-sidebar[data-sidebar-hidden] > .sidebar {
    left: -100%;
}
.page-wrapper.with-sidebar[data-sidebar-hidden] > .content-wrapper {
    width: 100%;
    left: 0;
}

/* With navbar fixed to bottom */

.page-wrapper.with-navbar-fixed-bottom > .content-wrapper,
.page-wrapper.with-navbar-fixed-bottom > .sidebar {
    bottom: var(--navbar-fixed-bottom-height);
    height: calc(100% - var(--navbar-fixed-bottom-height));
}

/* With navbar and navbar fixed to bottom */

.page-wrapper.with-navbar.with-navbar-fixed-bottom > .content-wrapper,
.page-wrapper.with-navbar.with-navbar-fixed-bottom > .sidebar {
    top: var(--navbar-height);
    bottom: var(--navbar-fixed-bottom-height);
    height: calc(100% - var(--navbar-height) - var(--navbar-fixed-bottom-height));
}

/* Full height sidebar */

.page-wrapper.with-sidebar[data-sidebar-type~="full-height"] > .sidebar {
    height: 100%;
    top: 0;
}
.page-wrapper.with-sidebar[data-sidebar-type~="full-height"] > .navbar:not(.navbar-fixed-bottom),
.page-wrapper.with-sidebar[data-sidebar-type~="full-height"] > .navbar.navbar-fixed-bottom {
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}
@media (max-width: 768px) {
    .page-wrapper.with-sidebar[data-sidebar-type~="full-height"] > .navbar:not(.navbar-fixed-bottom),
    .page-wrapper.with-sidebar[data-sidebar-type~="full-height"] > .navbar.navbar-fixed-bottom {
        width: 100%;
    }
}
.page-wrapper.with-sidebar[data-sidebar-type~="full-height"][data-sidebar-hidden] > .navbar:not(.navbar-fixed-bottom),
.page-wrapper.with-sidebar[data-sidebar-type~="full-height"][data-sidebar-hidden] > .navbar.navbar-fixed-bottom {
    left: 0;
    width: 100%;
}

/* Overlayed sidebar */

.page-wrapper.with-sidebar[data-sidebar-type~="overlayed-all"] > .navbar:not(.navbar-fixed-bottom),
.page-wrapper.with-sidebar[data-sidebar-type~="overlayed-all"] > .content-wrapper,
.page-wrapper.with-sidebar[data-sidebar-type~="overlayed-all"] > .navbar.navbar-fixed-bottom {
    left: 0;
    width: 100%;
}
.page-wrapper.with-sidebar[data-sidebar-type~="overlayed-all"] > .sidebar {
    height: 100%;
    top: 0;
    z-index: 50;
}
.page-wrapper.with-sidebar[data-sidebar-type~="overlayed-all"] > .sidebar-overlay {
    position: absolute;
    height: 100%;
    width: 100%;
    z-index: 45;
    background-color: var(--sidebar-overlay-bg-color);
}
.page-wrapper.with-sidebar[data-sidebar-type~="overlayed-all"][data-sidebar-hidden] > .sidebar-overlay {
    display: none;
}
@media (max-width: 768px) {
    .page-wrapper.with-sidebar[data-sidebar-type~="overlayed-sm-and-down"] > .navbar:not(.navbar-fixed-bottom),
    .page-wrapper.with-sidebar[data-sidebar-type~="overlayed-sm-and-down"] > .content-wrapper,
    .page-wrapper.with-sidebar[data-sidebar-type~="overlayed-sm-and-down"] > .navbar.navbar-fixed-bottom {
        left: 0;
        width: 100%;
    }
    .page-wrapper.with-sidebar[data-sidebar-type~="overlayed-sm-and-down"] > .sidebar {
        height: 100%;
        top: 0;
        z-index: 50;
    }
    .page-wrapper.with-sidebar[data-sidebar-type~="overlayed-sm-and-down"] > .sidebar-overlay {
        position: absolute;
        height: 100%;
        width: 100%;
        z-index: 45;
        background-color: var(--sidebar-overlay-bg-color);
    }
    .page-wrapper.with-sidebar[data-sidebar-type~="overlayed-sm-and-down"][data-sidebar-hidden] > .sidebar-overlay {
        display: none;
    }
}

/* With transitions (for sidebar toggles) */

.page-wrapper.with-transitions.with-sidebar > .sidebar {
    -webkit-transition: left .4s cubic-bezier(.25, .8, .25, 1);
    transition: left .4s cubic-bezier(.25, .8, .25, 1);
}
.page-wrapper.with-transitions.with-sidebar .content-wrapper,
.page-wrapper.with-transitions.with-sidebar[data-sidebar-type~="full-height"] > .navbar:not(.navbar-fixed-bottom),
.page-wrapper.with-transitions.with-sidebar[data-sidebar-type~="full-height"] > .navbar.navbar-fixed-bottom {
    -webkit-transition: width .4s cubic-bezier(.25, .8, .25, 1), left .4s cubic-bezier(.25, .8, .25, 1);
    transition: width .4s cubic-bezier(.25, .8, .25, 1), left .4s cubic-bezier(.25, .8, .25, 1);
}

/* Janky scroll fix (for Safari) */

.content-wrapper,
.sidebar {
    -webkit-overflow-scrolling: touch;
}


