#modx-split-wrapper {
  .x-border-layout-ct {
    background: transparent;
  }
}

#modx-leftbar-tabs-xcollapsed {
  display: none !important;
}

#modx-leftbar {
  background-color: $white;
  z-index: 0;
  min-width: 288px;

  @include grid-media($gtDesktop) {
    max-width: 50%;
  }

  .x-toolbar {
    padding: 0 !important;
    border: 0;
  }
}

#modx-header {
  background: $colorSplash;
  max-width: $navbarWidth;
  position: absolute;
  z-index: 2;
  height: 100%;
}

#modx-navbar {
  font-weight: bold;
  font: $fontNavbar;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 5px;

  .icon {
    color: $white;
    font-size: 20px;
    line-height: 20px;
    vertical-align: middle;
  }

  li,
  a {
    background: transparent;
    margin: 0;
    padding: 0;
    position: relative;
    width: 100%;
    text-align: center;
  }

  a {
    cursor: pointer;
    color: $navbarText;
    display: block;
    line-height: 12px;
    font-size: 10px;
    text-decoration: none;

    & .description {
      font-size: 9px;
      opacity: .7;
    }

    & .icon, & .label, & .description {
      width: 100%;
      display: block;
    }
  }

  li {
    a:hover {
      opacity: .7;
    }
  }

  #modx-user-menu a {
    .label, .description {
      display: none;
    }
    #user-username {
      white-space: nowrap;
      overflow: hidden;
      max-width: 7ch;
      text-overflow: ellipsis;
      align-self: center;
      padding-top: 0.25rem;
    }
  }

  #modx-manager-search-icon a,
  #modx-leftbar-trigger a,
  #modx-user-menu a {
    padding: 12px 0;
  }

  #modx-topnav {
    @extend %outer-container;
    list-style: none;
    margin: 0;
    padding: 0;

    >li:not(#modx-home-dashboard):not(#modx-manager-search-icon):not(#modx-leftbar-trigger) {
      >a {
        display: block;
        position: relative;
        padding: 12px 0;

        @include grid-media($mobile) {
          padding: 6px;
          width: auto;
        }
      }
    }

    @include grid-media($mobile) {
      margin-top: 0.5rem;
      column-gap: 0.25rem;
      > li {
        border-top: none;
      }
      &::after {
        // Remove the clearfix element
        display: none;
      }
    }
  }

  #modx-user-menu {
    margin-top: auto;

    #user-avatar {
      img {
        border-radius: 20px;
        height: 40px;
        width: 40px;
        display: block;
        margin: auto;
      }
    }

    #limenu-user a {
      display: flex;
      flex-direction: column;
      justify-content: center;
    }
  }

  #modx-home-dashboard {
    border-radius: $borderRadius;
    width: 40px;
    height: 40px;
    line-height: 40px;
    padding: 10px;
  }

  #modx-site-info {
    font-size: 10px;

    .site_name {
      color: $white;
    }

    .full_appname {
      color: $white;
    }

    >.info-item {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

#modx-leftbar-trigger {
  transition: all .2s ease;

  .icon {
    &:before {
      content: fa-content($fa-var-arrow-left);
    }
  }

  &.collapsed {
    .icon:before {
      content: fa-content($fa-var-arrow-right) !important;
    }
  }
}

#modx-header,
#modx-footer {
  .modx-subnav {
    border: 1px solid $navbarBorder;
    box-shadow: $boxShadowBig;
    border-radius: $borderRadius;
    background: $white;
    display: block;
    box-sizing: border-box;
    list-style: none;
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transition: all .15s ease;

    li {
      display: block;
      border-radius: $borderRadius;
      background: $subnavBg;
      margin: 0;
      padding: 0;
      position: relative;

      &:not(:first-child) {
        border-top: 1px solid $subnavSepBorder;
      }

      &:hover {
        &:after {
          border-right-color: $subnavBgHover;
        }
      }

      &.sub {
        &:after {
          @extend %pseudo-font;
          position: absolute;
          color: $subnavDescriptionColor;
          content: fa-content($fa-var-caret-right);
          font-size: 14px;
          margin-top: 0;
          top: 50%;
          transform: translateY(-50%);
          right: 10px;
        }
      }

      a {
        border-radius: $borderRadius;
        background-color: $subnavBg;
        color: $subnavTitleColor;
        font-size: 13px;
        font-weight: bold;
        line-height: 1.5;
        margin: 0;
        padding: 8px 15px;
        text-shadow: none;
        width: 270px;
        display: block;
        text-decoration: none;
        cursor: pointer;
        text-align: left;

        .icon {
          display: inline-block;
          font-size: 18px;
          opacity: .07;
          padding-left: 5px;
        }

        span {
          color: $subnavDescriptionColor;
          display: block;
          float: none;
          font-size: 12px;
          font-weight: normal;
          line-height: 1.3;
          margin-top: 6px;
          width: 100%;
        }

        &:hover {
          background: $subnavBgHover;
          border-top-color: $subnavBorder;
          border-bottom-color: $subnavBorder;
          color: $darkestGray;

          .description {
            color: darken($subnavDescriptionColor, 16%);
          }
        }
      }
    }

    &.active {
      opacity: 1;
      visibility: visible;
    }

    .modx-subsubnav {
      border: 1px solid $navbarBorder;
      box-shadow: $boxShadowBig;
      border-radius: $borderRadius;
      background: $white;
      list-style: none;
      position: absolute;
      &-arrow {
        border: 8px solid transparent;
        border-right-color: #FFF;
        content: " ";
        pointer-events: none;
        position: absolute;
        right: 0;
        top: 50%;
        transform: translate(0, -50%);
        display: none;
      }
      &.active {
        + .modx-subsubnav-arrow {
          display: block;
        }
      }
      @include grid-media($gtDesktop) {
        opacity: 0;
        visibility: hidden;
        &.active {
          opacity: 1;
          visibility: visible;
        }
      }
    }

    &-arrow {
      right: 100%;
      border: 12px solid transparent;
      border-right-color: $subnavBg;
      content: ' ';
      position: absolute;
      pointer-events: none;
      margin-top: -6px;
    }
  }

  // custom styles for language menu
  #language .modx-subsubnav {
    max-height: calc(100vh - 12px);
    overflow-y: auto;
    overflow-x: hidden;
  }
}

@include grid-media($mobile) {
  #modx-header {
    .modx-subnav {
      width: auto !important;
      z-index: 2;
      &#modx-manager-search-icon-submenu {
        width: 95% !important;
        input {
          width: calc(100% - 10px);
        }
      }
    }
  }
  #modx-navbar {
    #modx-headnav,
    #modx-user-menu {
      justify-content: space-evenly;
      flex-grow: 1;
      margin-bottom: 0.5rem;
    }
    #modx-headnav {
      width: 42% !important;
      li {
        flex-basis: 33.3%;
      }
    }
    #modx-user-menu {
      width: 56% !important;
      li {
        flex-basis: auto;
        &#limenu-user {
          a {
            padding: 0;
          }
        }
      }
    }
    #modx-home-dashboard {
      padding: 0 !important;
      width: unset;
      height: unset;
    }
    & > ul {
      > li {
        box-sizing: border-box;
      }
    }
  }
}

@include grid-media($mobile) {
  #modx-navbar {
    flex-wrap: wrap;
    padding: 5px 15px;
    #modx-headnav {
      order: 1;
      width: 50%;
      > li {
        &:not(:first-child) {
          &::after {
            @include main-navbar-side-border();
          }
        }
      }
    }
    #modx-topnav {
      width: 100%;
      order: 0;
    }
    #modx-user-menu {
      width: 50%;
      order: 2;
      #limenu-user {
        padding-left: unset;
      }
      > li {
        &:not(:nth-last-child(n+3)) {
          &::after {
            @include main-navbar-side-border();
          }
        }
      }
    }
    #modx-home-dashboard {
      padding: 0;
    }
  }
}

@media screen and (min-width: 641px) and (max-width: 960px) {
  #modx-navbar {
    & > ul {
      &#modx-headnav {
        > li {
          &:not(:first-child) {
            &::after {
              @include main-navbar-side-border();
            }
          }
        }
      }
      &#modx-topnav {
        > li {
          &::after {
            @include main-navbar-side-border();
          }
        }
      }
      &#modx-user-menu {
        > li {
          &:not(:nth-last-child(n+3)) {
            &::after {
              @include main-navbar-side-border();
            }
          }
        }
      }
    }
    
  }
}

@include grid-media($desktop) {
  #modx-header {
    position: relative;
    min-width: 100%;
    height: auto !important;
  }

  #modx-navbar {
    flex-direction: row;
    justify-content: center;

    #modx-headnav {
      a {
        line-height: initial !important;
      }
      img {
        max-width: 35px;
      }
    }

    #modx-topnav {
      > li {
        min-width: 50px;
      }
    }

    #modx-user-menu {
      flex-direction: row-reverse;
      flex-wrap: nowrap;
      margin-top: 0;
      #limenu-user {
        padding-left: 12px;
        padding-right: 8px;
        border-right: none;
      }
    }

    & > ul {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: center;
      &:not(.modx-subnav) {
        width: unset;
        > li {
          flex-basis: min-content;
          min-width: 45px;
        }
      }
    }

    #modx-site-info {
      display: none;
    }

    #modx-home-dashboard {
      margin: 0;
      padding: 0 10px 0 0;
    }
  }

  #modx-leftbar-trigger {
    .icon {
      &:before {
        content: fa-content($fa-var-arrow-up);
      }
    }

    &.collapsed {
      .icon:before {
        content: fa-content($fa-var-arrow-down) !important;
      }
    }

    @include grid-media($mobile) {
      .icon {
        padding: 0;
      }
    }
  }

  #modx-header,
  #modx-footer {
    .modx-subnav {
      min-width: 300px;

      .description {
        display: none;
      }

      li {
        border-radius: 0;

        &.sub:after {
          display: none;
        }

        a {
          width: auto;
          white-space: nowrap;
        }
      }

      .modx-subsubnav {
        position: initial;
        left: auto;
        box-shadow: none;
        display: block;
        max-height: initial !important;
        overflow-y: initial !important;

        li>a {
          margin-left: 1rem;
        }
      }
    }

    .modx-subnav-arrow {
      display: none;
    }

    // overflow for long subsubnav
    .modx-subnav {
      max-height: calc(100vh - 109px);
      overflow-y: auto;
      overflow-x: hidden;
    }
  }
}

@include grid-media($gtDesktop) {
  #modx-navbar {
    #modx-topnav {
      > li {
        &::after {
          @include main-navbar-side-border(bottom, 1px, 100%);
        }
      }
    }
  }
}

@media (max-height: 520px) {
  #modx-header,
  #modx-footer {
    .modx-subnav {
      .description {
        display: none;
      }
    }
  }
}
