//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: var(--bs-baton-menu-bg);
  color: var(--bs-baton-menu-color);
  border-right: 1px solid var(--bs-baton-menu-border-color);
  height: 100%;
  left: -100%;
  padding: 0;
  position: fixed;
  top: 0;
  transition: left 0.2s ease-in-out;
  z-index: 1002;

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

  #branding {
    background: var(--bs-baton-menu-branding-bg);
    border-bottom: 1px solid var(--bs-baton-menu-branding-bg);
    padding-top: 0;
    text-align: center;
    width: 100%;

    > h1 {
      background: var(--bs-baton-menu-branding-bg);
    }

    a {
      color: var(--bs-baton-menu-branding-color) !important;
    }
  }

  .toggle-menu {
    cursor: pointer;
    position: absolute;
    right: 0;
    top: 0.6rem;
  }

  .toggle-menu-ac {
    /* always collapsed close button */
    color: var(--bs-baton-navbar-toggler-color);
    font-size: 36px;
    margin-right: 10px;
    margin-top: 22px;
  }

  #user-tools {
    display: none;
  }

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

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

    .user-area-toggler {
      cursor: pointer;
      font-size: 2.2rem !important;
      margin-top: 1rem !important;
    }

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

    .gravatar-icon {
      border: 2px solid var(--bs-baton-menu-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: 0.5rem;
    }

    a {
      color: var(--bs-baton-menu-link-color) !important;

      &.view-site {
        &::after {
          content: 'desktop_windows';
          @extend %material;
          font-size: 26px;
          line-height: 26px;
        }

        &[href*='doc'] {
          &::after {
            content: 'docs' !important;
            @extend %material;
            font-size: 26px;
            line-height: 26px;
          }
        }
      }

      &.theme-dark {
        &::after {
          content: 'light_mode';
          @extend %material;
          font-size: 26px;
          line-height: 26px;
        }
      }

      &.theme-light {
        &::after {
          content: 'dark_mode';
          @extend %material;
          font-size: 26px;
          line-height: 26px;
        }
      }

      &.password {
        &::after {
          content: 'key';
          @extend %material;
          font-size: 26px;
          line-height: 26px;
        }
      }

      &.logout {
        cursor: pointer;
        display: inline-block;

        &::after {
          content: 'logout';
          @extend %material;
          font-size: 26px;
          line-height: 26px;
        }
      }

      &::after {
        color: var(--bs-baton-menu-user-links-color);
        font-size: 1.3rem;
        display: inline-block;
        margin: 0 0.6rem;
      }
    }
  }

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

    input {
      background: var(--bs-baton-search-field-input-bg);
      border-color: var(--bs-baton-search-field-input-border-color);
      color: var(--bs-baton-search-field-color);
      padding-right: 30px;

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

    &::after {
      color: var(--bs-baton-search-field-icon-color);
      content: 'search';
      @extend %material;
      position: absolute;
      right: 0.5rem;
      top: 1.2rem;
    }

    &.loading {
      &::after {
        @extend %icon-spin;
        content: 'progress_activity';
      }
    }

    #admin-search-datalist {
      background: var(--bs-baton-search-field-datalist-bg);
      max-height: 50vh;
      overflow: auto;
      position: absolute;
      width: 100%;
      z-index: 1000;

      div {
        align-items: center;
        border-bottom: var(--bs-baton-search-field-datalist-bg);
        cursor: pointer;
        display: flex;
        flex-direction: row;
        font-size: 0.9rem;
        justify-content: space-between;
        max-height: 50vh;
        overflow: auto;
        padding: 0.5rem;

        &.selected {
          background: var(--bs-baton-search-field-selected-bg);
          color: var(--bs-baton-search-field-selected-color);

          a {
            color: var(--bs-baton-search-field-selected-color);
          }
        }

        a {
          color: var(--bs-baton-search-field-link-color);
          text-decoration: none;
        }

        i {
          color: var(--bs-baton-search-field-icon-color);
          font-size: 1rem;
        }
      }
    }
  }

  h1 {
    background: var(--bs-baton-menu-mobile-title-bg);
    color: var(--bs-baton-menu-mobile-title-color);
    font-size: $h1-size;
    margin-bottom: 0;
    height: 64px;
    padding: 0.6rem 1rem;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 12;

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

    i {
      color: var(--bs-baton-navbar-toggler-color);
      cursor: pointer;
      float: right;
      font-weight: normal;
      margin-right: 10px;
      margin-top: 5px;
    }
  }

  .depth-0,
  .depth-1 {
    background: var(--bs-baton-menu-bg);
    height: 100%;
    left: 0;
    list-style-type: none;
    overflow: auto;
    padding: 0;
    padding-top: 64px;
    position: absolute;
    top: 0;
    z-index: 10;
    width: 100%;

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

    li {
      padding: 0;

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

    a,
    span {
      align-items: center;
      color: var(--bs-baton-menu-link-color);
      display: flex;
      outline: 0;

      &:hover {
        color: var(--bs-baton-menu-link-hover-color);
        text-decoration: none;
      }

      &.has-children {
        @extend .clearfix;

        &::after {
          @extend %material;
          content: 'keyboard_arrow_right';
          margin-left: auto;
        }
      }

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

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

    .title {
      background: var(--bs-baton-menu-voice-title-bg) !important;

      > span {
        color: var(--bs-baton-menu-voice-title-color) !important;
        font-weight: var(--bs-baton-menu-voice-title-weight);
        text-transform: uppercase;
      }
    }

    @include media-breakpoint-up(lg) {
      li.title ~ li:not(.title),
      .title > .depth-1 {
        border-left: 1px solid var(--bs-baton-menu-depth1-border-color) !important;
        margin-left: 1.9rem;
      }
    }
  }

  .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: 'keyboard_arrow_down' !important;
        }
      }

      ul,
      li {
        background: var(--bs-baton-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: 'keyboard_arrow_down' !important;
        }
      }

      ul,
      li {
        background: var(--bs-baton-menu-selected-sub-bg) !important;
      }

      > .depth-1 {
        display: block;
      }

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

  .nav-back {
    background: var(--bs-baton-menu-mobile-back-bg);
    text-transform: uppercase;

    a {
      padding: 10px 17px !important;
    }

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

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

      ul,
      li {
        background: var(--bs-baton-menu-selected-sub-bg) !important;
      }

      > .depth-1 {
        display: block;
      }

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

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

      a {
        color: var(--bs-baton-menu-active-voice-color) !important;
        margin-left: -5px;
      }
    }
  }
}
