@import "mixins/mixins";
@import "mixins/utils";
@import "common/var";
@import "common/transition";

@mixin side-menu-item {
  display: flex;
  height: 50px;
  line-height: 50px;
  font-size: $--menu-item-font-size;
  list-style: none;
  cursor: pointer;
  position: relative;
  transition: border-color .3s, background-color .3s, color .3s;
  box-sizing: border-box;
  white-space: nowrap;

  &:hover,
  &:focus {
    outline: none;
  }

  @include when(disabled) {
    opacity: 0.25;
    cursor: not-allowed;
    background: none !important;
  }
}

@include b(side-menu) {
  position: relative;
  margin: 0;
  height: 100%;
  padding-left: 0;
  list-style: none;
  @include utils-clearfix;

  @include m(collapse) {
    width: 60px;

    > .hn-side-menu__tree--root {
      > .hn-side-menu-item {
        .hn-side-menu-item__title-icon {
          margin: 0;
          line-height: 50px;
          vertical-align: top;
          text-align: center;
        }
        .hn-side-menu-item__title-text {
          height: 0;
          width: 0;
          overflow: hidden;
          visibility: hidden;
          display: inline-block;
        }
      }
      > .hn-side-submenu > .hn-side-submenu__title {
        .hn-side-submenu__title-icon {
          margin: 0;
          line-height: 50px;
          vertical-align: top;
          text-align: center;
        }
        .hn-side-submenu__title-text {
          height: 0;
          width: 0;
          overflow: hidden;
          visibility: hidden;
          display: inline-block;
        }
        .hn-side-submenu__icon-arrow {
          display: none;
        }
      }
  
      > .hn-side-menu-item.is-active i {
        color: inherit;
      }
    }
    

    .hn-side-menu .hn-side-submenu {
      min-width: 180px;
    }

    .hn-side-submenu {
      position: relative;
      & .hn-side-menu {
        position: absolute;
        margin-left: 5px;
        top: 0;
        left: 100%;
        z-index: 10;
        border: 1px solid $--border-color-light;
        border-radius: $--border-radius-base;
        box-shadow: $--box-shadow-light;
      }

      &.is-opened {
        > .hn-side-submenu__title .hn-side-submenu__icon-arrow {
          transform: none;
        }
      }
    }
  }
  @include m(popup) {
    z-index: 100;
    min-width: 200px;
    border: none;
    padding: 5px 0;
    border-radius: $--border-radius-base;
    box-shadow: $--box-shadow-light;

    &-bottom-start {
      margin-top: 5px;
    }
    &-right-start {
      margin-left: 5px;
      margin-right: 5px;
    }
  }
}
@include b(side-menu-item) {
  @include side-menu-item;

  & .hn-side-menu-item__title-icon {
    margin-right: 10px;
    text-align: center;
    font-size: 20px;
    line-height: 50px;
    vertical-align: top;
  }
  & .hn-side-menu-item__title-text {
    display: inline-block;
    flex: 1;
    margin-right: 20px;
    overflow: hidden;
    word-break: break-all;
    text-overflow: ellipsis;
  }
  @include e(mark) {
    position: absolute;
    left: 0;
    content: "";
    width: 4px;
    height: 100%;
  }
  @include when(active) {
    i {
      color: inherit;
    }
  }
}
  
@include b(side-submenu) {
  list-style: none;
  margin: 0;
  padding-left: 0;

  @include e(title) {
    @include side-menu-item;
    .hn-side-submenu__title-icon {
      line-height: 50px;
      vertical-align: top;
      margin-right: 10px;
      text-align: center;
      font-size: 20px;
    }
    .hn-side-submenu__title-text {
      display: inline-block;
      flex: 1;
      margin-right: 37px;
      overflow: hidden;
      word-break: break-all;
      text-overflow: ellipsis;
    }
  }
  & .hn-side-menu {
    border: none;
  }
  & .hn-side-menu-item {
    height: 50px;
    line-height: 50px;
    min-width: 180px;
  }
  @include e(icon-arrow) {
    position: absolute;
    top: 50%;
    right: 20px;
    margin-top: -7px;
    transition: transform .3s;
    font-size: 12px;
  }
  @include e(mark) {
    position: absolute;
    left: 0;
    content: "";
    width: 4px;
    height: 100%;
  }
  @include when(active) {
    .hn-side-submenu__title {
      border-bottom-color: $--color-primary;
    }
  }
  @include when(opened) {
    > .hn-side-submenu__title .hn-side-submenu__icon-arrow {
      transform: rotateZ(180deg);
    }
  }
  @include when(disabled) {
    .hn-side-submenu__title,
    .hn-side-menu-item {
      opacity: 0.25;
      cursor: not-allowed;
      background: none !important;
    }
  }
}

.horizontal-collapse-transition .hn-side-submenu__title .hn-side-submenu__icon-arrow {
  transition: .2s;
  opacity: 0;
}