/*
 * SESAM application shell.
 *
 * Sidebar (blue, fixed left) + white top navbar layout used by the
 * Django application pages (anything extending base_application.html).
 *
 * Original structure derived from the SB-Admin-2 Bootstrap theme,
 * trimmed and re-prefixed for SESAM.
 */

/* ***************************************************
 * PAGE WRAPPER
 * *************************************************** */

#wrapper {
  display: flex;
}

#wrapper #content-wrapper {
  width: 100%;
  margin-inline-start: var(--sesam-sidebar-width);
  overflow-x: hidden;
}

/* Default content-area background. Pages that opt into a decorative
   background (e.g. the auth pages) set their own class on #content and
   are excluded here so their background can take effect. */
#wrapper #content-wrapper #content:not(.sesam-lines-background) {
  flex: 1 0 auto;
  background-color: var(--sesam-content-bg) !important;
}

#wrapper #content-wrapper #content.sesam-lines-background {
  flex: 1 0 auto;
}

/* The topbar is a stacking context above the page content, so its dropdowns (user menu) open over panels that
   raise themselves above a map (Builder sidebar). 1030 is Bootstrap's fixed layer: below offcanvas and modals. */
#white-navbar {
  position: relative;
  z-index: 1030;
  height: var(--sesam-navbar-height) !important;
  background-color: var(--sesam-top-navbar-bg);
}

/* The page title (breadcrumb) takes the free space between the menu toggle and the user menu. min-width: 0 lets it
   shrink below its content, so the breadcrumb truncates with "…" instead of running under the user menu. */
.sesam-topbar .sesam-page-title {
  flex: 1 1 auto;
  min-width: 0;
  padding-inline-end: 1rem;
}

/* Bootstrap containers in the app shell get a small horizontal padding. */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl {
  padding-inline: 1.5rem;
}

/* Bootstrap containers inside the app shell (account pages, ...) use the maximum page width of SESAM, 1400px, like
   the Workspace and the Builder (DEV-design-guidelines.md, "Page Layout Types"). Bootstrap's xxl breakpoint alone
   would stop at 1320px. */
@media (width >= 1400px) {
  .container,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl,
  .container-xxl {
    max-width: 1400px;
  }
}

/* ***************************************************
 * BLUE LEFT SIDEBAR
 * *************************************************** */

.sesam-sidebar {
  position: fixed;
  width: var(--sesam-sidebar-width);
  height: 100%;
  overflow: auto;
}

.sesam-bg-gradient-primary {
  background-color: var(--sesam-blue);
  background-size: cover;
}

.sesam-sidebar .nav-item {
  position: relative;
}

.sesam-sidebar .nav-item .nav-link {
  padding: 1rem .75rem;
  text-align: center;
}

.sesam-sidebar .nav-link span {
  display: inline;
  font-size: .65rem;
}

.sesam-sidebar .nav-link .fas {
  font-size: 18px !important;
}

.sesam-sidebar .nav-item.active .nav-link {
  /* Compensates the .2rem border of the active item, so the icon stays centered */
  margin-inline-start: -.2rem;
  font-weight: 700;
}

/* Highlight active sidebar item with a thin white left border. */
.sesam-sidebar .nav-item.active {
  background-color: rgb(226 239 254 / .08);
  border-inline-start: .2rem solid #fff !important;
}

.sesam-sidebar-logo {
  opacity: .3;
}

.sesam-sidebar-logo:hover {
  opacity: 1;
}

hr.sesam-sidebar-divider {
  margin: 1rem;
  border-block-start: 1px solid rgb(255 255 255 / .15);
}

/* Dark variant (only one used in SESAM). */
.sesam-sidebar-dark .nav-item .nav-link {
  color: rgb(255 255 255 / .8);
  text-align: center;
}

.sesam-sidebar-dark .nav-item .nav-link i {
  color: rgb(255 255 255 / .3);
}

.sesam-sidebar-dark .nav-item .nav-link:active,
.sesam-sidebar-dark .nav-item .nav-link:focus,
.sesam-sidebar-dark .nav-item .nav-link:hover {
  color: #fff;
}

.sesam-sidebar-dark .nav-item .nav-link:active i,
.sesam-sidebar-dark .nav-item .nav-link:focus i,
.sesam-sidebar-dark .nav-item .nav-link:hover i {
  color: #fff;
}

.sesam-sidebar-dark .nav-item.active .nav-link,
.sesam-sidebar-dark .nav-item.active .nav-link i {
  color: #fff;
}

/* Vertical "account" nav inside the white content area. */
.sesam-vert-nav .nav-item.active {
  background-color: rgb(90 134 166 / .2);
  border-inline-start: .2rem solid var(--sesam-blue) !important;
}

/* ***************************************************
 * WHITE TOP NAVBAR (TOPBAR)
 * *************************************************** */

.sesam-topbar {
  height: 4.375rem;
}

/* Softer, wider topbar shadow than Bootstrap's default .shadow utility. */
.sesam-topbar.shadow {
  box-shadow: 0 .15rem 1.75rem 0 rgb(58 59 69 / .15) !important;
}

/* The account menu in the size of the page title beside it (14px), not the 16px of the browser */
.sesam-topbar .nav-item .nav-link {
  display: flex;
  align-items: center;
  padding: 0 .75rem;
  font-size: var(--sesam-text-body);
}

.sesam-topbar .nav-item .nav-link:focus,
.sesam-topbar .nav-item:focus {
  outline: none;
}

.sesam-topbar .dropdown {
  position: static;
}

.sesam-topbar .dropdown .dropdown-menu {
  inset-inline-end: 0;
}

@media (width >= 576px) {
  .sesam-topbar .dropdown {
    position: relative;
  }

  .sesam-topbar .dropdown .dropdown-menu {
    inset-inline-end: 0;
    width: auto;
  }
}

.sesam-topbar.navbar-light .navbar-nav .nav-link {
  color: #d1d3e2;
}

.sesam-topbar.navbar-light .navbar-nav .nav-link:hover {
  color: var(--sesam-blue);
}

.sesam-topbar.navbar-light .navbar-nav .nav-link:active {
  color: #858796;
}

/* Replace Bootstrap's default triangular caret on dropdown toggles inside
   the sidebar and topbar with a Font Awesome chevron-down glyph (\f107). */
.sesam-sidebar .nav-item.dropdown .dropdown-toggle::after,
.sesam-topbar .nav-item.dropdown .dropdown-toggle::after {
  float: inline-end;
  width: 1rem;
  font-family: "Font Awesome 5 Free", "Font Awesome 6 Free";
  font-weight: 900;
  vertical-align: 0;
  text-align: center;
  content: "\f107";
  border: 0;
}

/* ***************************************************
 * MOBILE OFFCANVAS SIDEBAR
 * Pattern from https://bootstrap-menu.com/detail-offcanvas-mobile.html
 * *************************************************** */

body.sesam-offcanvas-active {
  overflow: hidden;
}

#offcanvas-header-main-navbar {
  display: none;
}

@media all and (width <= 767px) {
  .sesam-topbar .dropdown .dropdown-menu {
    margin-inline: 1.5rem;
  }

  .sesam-sidebar .nav-link span {
    display: block;
  }

  #offcanvas-header-main-navbar {
    display: block;
  }

  .sesam-mobile-offcanvas {
    position: fixed;
    inset-block-start: 0;
    inset-inline-start: 0;
    z-index: 1200;
    display: block;
    visibility: hidden;
    height: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
    border-radius: 0;
    transform: translateX(-100%);
    transition:
      visibility .3s ease-in-out,
      transform .3s ease-in-out;
  }

  .sesam-mobile-offcanvas.show {
    visibility: visible;
    transform: translateX(0);
  }

  .sesam-mobile-offcanvas .container,
  .sesam-mobile-offcanvas .container-fluid {
    display: block;
  }

  #wrapper #content-wrapper {
    margin-inline-start: 0 !important;
  }
}
