//scss-lint:disable PlaceholderInExtend NestingDepth ImportantRule SelectorDepth

.menu-open .sidebar-menu {
  left: 0;
}

body:not(.menu-mobile) {
  @include media-breakpoint-up(lg) {
    .sidebar-menu {
      height: auto;
      left: 0;
      position: static;

      h1 {
        i {
          display: none !important;
        }
      }
    }
  }
}

.sidebar-menu {
  background: $menu-bg;
  color: $menu-color;
  height: 100%;
  left: -100%;
  padding: 0;
  position: fixed;
  top: 0;
  z-index: 100;

  @include media-breakpoint-up(lg) {
    overflow: auto;
  }

  #branding {
    background: $menu-branding-bg;
    border-bottom: 1px solid $menu-branding-bg;
    padding-top: 0;
    text-align: center;
    width: 100%;

    > h1 {
      background: $menu-branding-bg;
    }

    a {
      color: $menu-branding-color !important;
    }
  }

  .toggle-menu {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1.6rem;
  }

  #user-tools {
    display: none;
  }

  #user-tools-sidebar {
    padding: 1rem;
    position: relative;
    text-align: center;

    .user-links {
      height: 38px;
      transition: height .2s linear;
    }

    .user-area-toggler {
      cursor: pointer;
    }

    &.collapsed {
      .user-links,
      .user-info div {
        display: none;
      }
    }

    .gravatar-icon {
      border: 2px solid $gravatar-border-color;
      border-radius: 50%;
    }

    .user-info {
      align-items: center;
      display: flex;
      flex-direction: column;
      font-size: 1.2rem;
      justify-content: center;
    }

    .user-links {
      align-items: center;
      display: flex;
      flex-direction: row;
      justify-content: center;
      margin-top: .5rem;
    }

    a {
      color: $menu-link-color !important;

      &.view-site {
        &::after {
          content: '\f108';
          font-family: 'Font Awesome\ 5 Free';
        }

        &[href*=doc] {
          &::after {
            content: '\f02d' !important;
            font-family: 'Font Awesome\ 5 Free';
          }
        }
      }

      &.password {
        &::after {
          content: '\f084';
          font-family: 'Font Awesome\ 5 Free';
        }
      }

      &.logout {
        &::after {
          content: '\f2f5';
          font-family: 'Font Awesome\ 5 Free';
          font-size: 1.6rem;
        }
      }

      &::after {
        color: $user-links-fg;
        font-size: 1.3rem;
        display: inline-block;
        margin: 0 .6rem;
      }
    }
  }

  .search-field-tool {
    margin: .5rem 1rem;
    position: relative;

    input {
      background: $search-field-input-bg;
      border-color: $search-field-input-border-color;
      color: $search-field-color;
      padding-right: 30px;

      &:focus {
        box-shadow: 0 0 0 transparent;
        outline: 0 none;
      }
    }

    &::after {
      color: $secondary;
      content: '\f002';
      font-family: 'Font Awesome\ 5 Free';
      position: absolute;
      right: .5rem;
      top: .2rem;
    }

    &.loading {
      &::after {
        animation: fa-spin 2s linear infinite;
        content: '\f1ce';
      }
    }

    #admin-search-datalist {
      background: $search-field-datalist-bg;
      max-height: 50vh;
      overflow: auto;
      position: absolute;
      width: 100%;

      div {
        align-items: center;
        border-bottom: 1px solid darken($search-field-datalist-bg, 2%);
        cursor: pointer;
        display: flex;
        flex-direction: row;
        font-size: .9rem;
        justify-content: space-between;
        max-height: 50vh;
        overflow: auto;
        padding: .5rem;

        &.selected {
          background: $search-field-selected-bg;
          color: $search-field-selected-color;

          a {
            color: $search-field-selected-color;
          }

        }

        a {
          color: $search-field-link-color;
          text-decoration: none;
        }

        i {
          color: $search-field-icon-color;
          font-size: .9rem;
        }
      }
    }
  }

  h1 {
    @extend .clearfix;
    background: $menu-mobile-title-bg;
    // border-bottom: 2px solid $menu-mobile-title-border-color;
    color: $menu-mobile-title-color;
    font-size: 1.6rem;
    margin-bottom: 0;
    padding: 1rem 16px;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 12;

    @include media-breakpoint-up(lg) {
      background: $menu-title-bg;
      position: static;
    }

    i {
      cursor: pointer;
      float: right;
      font-weight: normal;
      margin-right: 10px;
      margin-top: 5px;
    }
  }

  .depth-0,
  .depth-1 {
    background: $menu-bg;
    height: 100%;
    left: 0;
    list-style-type: none;
    overflow: auto;
    padding: 0;
    padding-top: 66px;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 10;


    @include media-breakpoint-up(lg) {
      height: auto;
      padding-top: 0;
      position: static;
    }

    li {
      // border-bottom: 1px solid $menu-li-border-color;
      padding: 0;

      a,
      span {
        padding: 10px 20px;
      }
    }

    a,
    span {
      color: $menu-link-color;
      display: block;
      outline: 0;

      &:hover {
        color: $menu-link-hover-color;
        text-decoration: none;
      }

      &.has-children {
        @extend .clearfix;

        &::after {
          @extend %font-awesome;
          content: '\f105';
          float: right;
        }
      }

      i {
        display: inline-block;
        margin-right: 8px;
      }
    }
  }

  .depth-0 {
    > li:not(.title) {
      &:hover {
        background: $menu-li-hover-bg;
      }
    }

    .title {
      background: $menu-voice-title-bg !important;

      > span {
        color: $menu-voice-title-color !important;
        font-weight: bold;
        text-transform: uppercase;
      }
    }
  }

  .depth-1 {
    display: block;
    margin-left: -100%;
    transition: margin-left .0s linear;

    @include media-breakpoint-up(lg) {
      display: none;
      margin-left: 0;

      li {
        padding-left: 10px;
      }
    }
  }

  .title > .depth-1 li {
    @include media-breakpoint-up(lg) {
      padding-left: 0;
    }
  }


  .open {
    @include media-breakpoint-up(lg) {
      .has-children {
        &::after {
          content: '\f107' !important;
        }
      }

      ul,
      li {
        background: $menu-selected-sub-bg !important;
      }
    }

    > .depth-1 {
      display: block;
    }

    .depth-1 {
      margin-left: 0;
      z-index: 10;
    }
  }

  .default-open {
    @include media-breakpoint-up(lg) {
      .has-children {
        &::after {
          content: '\f107' !important;
        }
      }

      ul,
      li {
        background: $menu-selected-sub-bg !important;
      }

      > .depth-1 {
        display: block;
      }

      .depth-1 {
        margin-left: 0;
        z-index: 10;
      }
    }
  }

  .nav-back {
    background: $menu-mobile-back-bg;

    @include media-breakpoint-up(lg) {
      display: none;
    }
  }

  .with-active {
    @include media-breakpoint-up(lg) {
      .has-children {
        &::after {
          content: '\f107' !important;
        }
      }

      ul,
      li {
        background: $menu-selected-sub-bg;
      }

      > .depth-1 {
        display: block;
      }

      .depth-1 {
        margin-left: 0;
        z-index: 10;
      }
    }
  }

  .active:not(.with-active) {
    @include media-breakpoint-up(lg) {
      background: $menu-active-voice-bg !important;
      border-left: 5px solid $menu-active-voice-border-color;
      position: relative;

      a {
        margin-left: -5px;
      }
    }
  }
}
