@use './variables.module.scss' as *;

#app {
  .main-container {
    height: 100%;
    transition: margin-left 0.28s;
    margin-left: $base-sidebar-width;
    position: relative;
    background: var(--el-bg-color-page);
  }

  .sidebarHide {
    margin-left: 0 !important;
  }

  .sidebar-container {
    -webkit-transition: width 0.28s;
    transition: width 0.28s;
    width: $base-sidebar-width !important;
    background-color: $base-menu-background;
    height: 100%;
    position: fixed;
    font-size: 0;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1001;
    overflow: hidden;
    -webkit-box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
    box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.1);

    // reset element-ui css
    .horizontal-collapse-transition {
      transition:
        0s width ease-in-out,
        0s padding-left ease-in-out,
        0s padding-right ease-in-out;
    }

    .scrollbar-wrapper {
      overflow-x: hidden !important;
    }

    .el-scrollbar__bar.is-vertical {
      right: 0;
    }

    .el-scrollbar {
      height: 100%;
    }

    &.has-logo {
      .el-scrollbar {
        height: calc(100% - 50px);
      }
    }

    .is-horizontal {
      display: none;
    }

    a {
      display: inline-block;
      width: 100%;
      overflow: hidden;
    }

    .svg-icon {
      margin-right: 10px;
    }

    .el-menu {
      border: none;
      height: 100%;
      width: 100% !important;
    }

    .el-menu-item,
    .menu-title {
      overflow: hidden !important;
      text-overflow: ellipsis !important;
      white-space: nowrap !important;
    }

    .el-menu-item .el-menu-tooltip__trigger {
      display: inline-block !important;
    }

    // menu hover
    .theme-dark .sub-menu-title-noDropdown,
    .theme-dark .el-sub-menu__title {
      border-radius: var(--app-radius-md);
      margin: 1px 5px 1px 5px;
      &:hover {
        background-color: $base-sub-menu-title-hover !important;
      }
    }
    .sub-menu-title-noDropdown,
    .el-sub-menu__title {
      border-radius: var(--app-radius-md);
      margin: 1px 5px 1px 5px;
      &:hover {
        background-color: rgba(0, 0, 0, 0.05) !important;
      }
    }

    & .theme-dark .is-active > .el-sub-menu__title {
      color: $base-menu-color-active !important;
    }

    & .nest-menu .el-sub-menu > .el-sub-menu__title,
    & .el-sub-menu .el-menu-item {
      min-width: calc($base-sidebar-width - 20px) !important;
      border-radius: var(--app-radius-md);
      height: 45px;
      margin: 1px 5px 1px 5px;
      &:not(.is-active):hover {
        background-color: rgba(0, 0, 0, 0.1) !important;
      }
    }

    & .theme-dark .nest-menu .el-sub-menu > .el-sub-menu__title,
    & .theme-dark .el-sub-menu .el-menu-item {
      background-color: $base-sub-menu-background !important;
      border-radius: var(--app-radius-md);
      height: 45px;
      margin: 1px 5px 1px 5px;

      &.is-active {
        background-color: var(--el-menu-active-color) !important;
        color: #fff;
      }
      &:not(.is-active):hover {
        // you can use $sub-menuHover
        background-color: $base-sub-menu-hover !important;
      }
    }

    & .theme-dark .nest-menu .el-sub-menu > .el-sub-menu__title,
    & .theme-dark .el-menu-item {
      border-radius: var(--app-radius-md);
      height: 45px;
      margin: 1px 5px 1px 5px;

      &.is-active {
        background-color: var(--el-menu-active-color) !important;
        color: #fff;
      }
      &:not(.is-active):hover {
        // you can use $sub-menuHover
        background-color: $base-menu-hover !important;
      }
    }

    & .nest-menu .el-sub-menu > .el-sub-menu__title,
    & .el-menu-item {
      border-radius: var(--app-radius-md);
      height: 45px;
      margin: 1px 5px 1px 5px;

      &.is-active {
        background-color: var(--el-menu-active-color) !important;
        color: #fff;
      }
      &:not(.is-active):hover {
        // you can use $sub-menuHover
        background-color: rgba(0, 0, 0, 0.04) !important;
      }
    }
  }

  // 收起菜单后的样式
  .hideSidebar {
    .sidebar-container {
      width: 54px !important;
    }

    .main-container {
      margin-left: 54px;
    }

    .sub-menu-title-noDropdown {
      padding: 0 !important;
      position: relative;
      height: 45px;
      // 选中状态的菜单
      &.is-active {
        background-color: var(--el-menu-active-color) !important;
        color: #fff !important;
      }

      .el-tooltip {
        padding: 0 !important;
      }
    }


    & .el-sub-menu {
      overflow: hidden;
      border-radius: var(--app-radius-md);
      .el-sub-menu__title.el-tooltip__trigger {
        border-radius: var(--app-radius-md);
        height: 45px;
      }

      // 选中状态的菜单
      &.is-active .el-sub-menu__title.el-tooltip__trigger {
        background-color: var(--el-menu-active-color) !important;
      }


      & > .el-sub-menu__title {
        padding: 0 !important;
      }
    }

    .el-menu--collapse {
      .is-active .svg-icon {
        fill: #fff;
      }
      .svg-icon {
        display: flex;
        margin: auto;
        height: 100%;
        // 这里设置width会跟随sidebar-container的transition 不符合预期
      }
      .el-sub-menu {
        & > .el-sub-menu__title {
          & > span {
            height: 0;
            width: 0;
            overflow: hidden;
            visibility: hidden;
            display: inline-block;
          }
          & > i {
            height: 0;
            width: 0;
            overflow: hidden;
            visibility: hidden;
            display: inline-block;
          }
        }
      }
    }
  }

  .el-menu--collapse .el-menu .el-sub-menu {
    min-width: $base-sidebar-width !important;
  }

  // mobile responsive
  .mobile {
    .main-container {
      margin-left: 0px;
    }

    .sidebar-container {
      transition: transform 0.28s;
      width: $base-sidebar-width !important;
    }

    &.hideSidebar {
      .sidebar-container {
        pointer-events: none;
        transition-duration: 0.3s;
        transform: translate3d(-$base-sidebar-width, 0, 0);
      }
    }
  }

  .withoutAnimation {
    .main-container,
    .sidebar-container {
      transition: none;
    }
  }
}

// when menu collapsed
.el-menu--vertical {
  & > .el-menu {
    .svg-icon {
      margin-right: 16px;
    }
  }
}
// 收起菜单后悬浮的菜单样式
.el-popper.is-pure{
  border-radius: var(--app-radius-md);
  .el-menu--popup{
    border-radius: var(--app-radius-md);
  }
  .el-menu-item{
    border-radius: var(--app-radius-sm);
  }
}
