@import '../../style/index.less';

@default-ease: cubic-bezier(0.25, 0, 0.15, 1);
@menu--bg: @bixi-geekblack;
@menu-active-bg: @bixi-geekblack-light;
@menu-hover-bg: fade(@menu-active-bg, 60%);
@menu-color: fade(@bixi-white, 70%);
@menu-active-color: @bixi-white-lighter;
@menu-dark-color: fade(@bixi-white, 45%);
@menu-item-height: @layout36;
@small-width: @layout52;
@large-width: @layout200;
@menu-border-color: @bixi-geekblack-light;
@menu-box-shadow-color: #29305B;

.bixi-layout-menu{
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: @menu--bg;
  backface-visibility: hidden;
  transition: width 0.2s @default-ease, translate 0.2s @default-ease;
  -webkit-overflow-scrolling: touch;
  
  &>ul {
    flex: 1;
    li {
      outline: none;
    }
  }
  &-opened{
    width: @large-width;
    .ant-menu-item, .ant-menu-submenu-title {
      width: 100%;
      height: @menu-item-height;
      margin: 4px 0;
      color: @menu-color;
      line-height: @menu-item-height;
      outline: none;
      transition: none;
      user-select: none;
      &:hover {
        color: @menu-active-color;
        background:  @menu-hover-bg;
      }
    }
    .ant-menu-item-group {
      .ant-menu-item-group-title {
        padding-left: 22px;
        color: @menu-color;
      }
    }

  }
  &-collapsed{
    width: @small-width;
    .ant-menu-inline-collapsed{
      width: 100%;
      overflow-y: auto;
      .ant-menu-item, .ant-menu-submenu, .ant-menu-submenu-title {
        width: 100%;
        height: @menu-item-height;
        padding: 0 !important;
        line-height: inherit;
        text-align: center;
        span {
          overflow: hidden;
        }

        .anticon {
          margin-right: 0;
        }
        &:hover {
          color: @menu-active-color;
          background: @menu-active-bg;
        }
      }

      // 收起状态下 group 不可见
      .ant-menu-item-group {
        .ant-menu-item-group-title {
          display: none;
        }
      }

      .ant-menu-submenu-vertical{
        &:hover {
          background: @menu-hover-bg;
        }
        .ant-menu{
          display: none;
        }
      }
    }
  }

  .ant-menu-item-base {
    &:hover {
      color: @menu-active-color;
      background-color: @menu-hover-bg;
    }
  }

  .anticon {
    margin-right: 8px;
    font-size: 16px;
  }

  // ant-menu-vertical为菜单收起状态
  .ant-menu-inline,
  .ant-menu-vertical,
  .ant-menu-vertical-left {
    border-right: none;
  }

  // ant-menu-inline为菜单展开状态
  // .ant-menu-inline {
  //   .ant-menu-item,
  //   .ant-menu-submenu-title {
  //     text-overflow: clip;
  //   }
  // }

  .ant-menu-item {
    margin: 4px 0 !important;
    color: @menu-color;

    span {
      user-select: none;
    }
  }

  .ant-menu-submenu {
    // 子菜单
    .ant-menu-sub {
      background-color: @menu--bg;
    }

    .ant-menu-submenu-title {
      // 保证文字不溢出
      padding-right: 25px;
      &:hover {
        // 父级菜单右侧折叠箭头 hover 样式
        .ant-menu-submenu-arrow {
          &::before,
          &::after {
            height: 1px;
            background-color: @menu-active-color !important;
            background-image: linear-gradient(to right, @menu-active-color, @menu-active-color);
          }
        }
      }
    }

    // 父级菜单右侧折叠箭头样式
    .ant-menu-submenu-arrow {
      &::before,
      &::after {
        height: 1px;
        background-color: @menu-color !important;
        background-image: none;
      }
    }

    .ant-menu {
      color: @menu-color;
      font-size: 14px;
      line-height: 22px;
    }
  }

  .ant-menu-submenu-open, .ant-menu-submenu-selected {
    position: relative;
    &>.ant-menu-submenu-title {
      color: @menu-active-color;
      .ant-menu-submenu-arrow {
        &::before,
        &::after {
          height: 1px;
          background-color: @menu-active-color !important;
        }
      }
    }
  }

  .ant-menu:not(.ant-menu-horizontal) {
    .ant-menu-item-selected::after {
      border: none;
      transition: none;
    }

    .bixi-submenu-selected, .ant-menu-item-selected {
      color: @menu-active-color;
      background: @menu-active-bg !important;
      transition: none;
      span {
        color: @menu-active-color;
      }
    }
  }

  .ant-menu-vertical .ant-menu-item::after,
  .ant-menu-vertical-left .ant-menu-item::after,
  .ant-menu-vertical-right .ant-menu-item::after,
  .ant-menu-inline .ant-menu-item::after {
    transition: none;
  }

  .menu {
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    color: @menu-color;
    font-size: 14px;
    line-height: 22px;
    background-color: @menu--bg;
  }

  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-thumb {
    width: 8px;
    background-color: rgba(65, 80, 123, 0.9) !important;
    border-radius: 5px;
  }

  // toggle 按钮样式
  .bixi-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 27px;
    color: @menu-dark-color;
    background: @menu--bg;
    border-top: 1px solid @menu-border-color;
    border-radius: 0 2px 2px 0;
    cursor: pointer;
    .anticon {
      margin: 0;
      font-size: 14px !important;
    }
    &:hover {
      color: @menu-active-color;
    }
  }
}

// 菜单折叠时，hover到一级菜单上，弹出的二级菜单的类名
.ant-menu-vertical.ant-menu-sub {
  background: @menu--bg !important;
  border-radius: 2px;
  box-shadow: 0 0 10px 0 @menu-box-shadow-color;
  .ant-menu-item, .ant-menu-submenu, .ant-menu-submenu-title {
    color: @menu-color;
    background: transparent;
    outline: none;
    user-select: none;
    .ant-menu-submenu-arrow {
      &::before,
      &::after {
        height: 1px;
        background-color: @menu-color !important;
        background-image: linear-gradient(to right, @menu-color, @menu-color);
      }
    }
    &:hover {
      color: @menu-active-color;
      .ant-menu-submenu-arrow {
        &::before,
        &::after {
          height: 1px;
          background-color: @menu-active-color !important;
          background-image: linear-gradient(to right, @menu-active-color, @menu-active-color);
        }
      }
    }
  }
  .bixi-menu-item {
    height: @menu-item-height;
    padding-left: 16px !important;
    
    .anticon {
      font-size: 16px !important;
    }
  }
  .ant-menu-item-selected {
    color: @menu-active-color !important;
  }
}

// 二级菜单popup的宽度
.bixi-layout-menu-item-tooltip {
  .ant-tooltip-content {
    .ant-tooltip-inner {
      max-width: 150px;
      background-color: @menu--bg;
    }
  }
}

