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

#app {

  .main-container {
    min-height: 100%;
    transition: margin-left .28s;
    margin-left: vars.$base-sidebar-width;
    position: relative;
  }

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

  .sidebar-container {
    transition: width 0.28s;
    width: vars.$base-sidebar-width !important;
    height: 100%;
    position: fixed;
    font-size: 0px;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1001;
    overflow: hidden;
    -webkit-box-shadow: 2px 0 8px rgba(22, 119, 255, 0.15);
    box-shadow: 2px 0 8px rgba(22, 119, 255, 0.15);

    // 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: 0px;
    }

    .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: 16px;
    }

    .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 - 现代化蓝色主题
    .sub-menu-title-noDropdown,
    .el-sub-menu__title {
      transition: all 0.3s ease;
      &:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
      }
    }

    // 暗色主题样式
    & .theme-dark {
      // 父菜单在子菜单选中时不高亮（只高亮子菜单项）
      .el-sub-menu.is-active > .el-sub-menu__title {
        color: vars.$base-menu-color-active !important;
        background-color: transparent !important;
        font-weight: normal !important;
        box-shadow: none !important;
      }

      .el-menu-item.is-active {
        background-color: rgba(255, 255, 255, 0.25) !important;
        color: vars.$base-menu-color-active !important;
        font-weight: 600;
        position: relative;
        box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.1);
        
        &::before {
          content: '';
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          width: 4px;
          height: 70%;
          background-color: #ffffff;
          border-radius: 0 3px 3px 0;
          box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
        }
      }
    }

    // 亮色主题样式
    & .theme-light {
      .el-menu-item {
        &:hover {
          background-color: vars.$menuLightHover !important;
        }

        &.is-active {
          background-color: vars.$menuLightActiveBg !important;
          color: vars.$menuLightActiveText !important;
          font-weight: 700;
          position: relative;
          box-shadow: inset 0 0 10px rgba(22, 119, 255, 0.08);
          
          &::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 70%;
            background: linear-gradient(180deg, vars.$menuLightActiveText 0%, #4096ff 100%);
            border-radius: 0 3px 3px 0;
            box-shadow: 0 0 6px rgba(22, 119, 255, 0.4);
          }
        }
      }

      .el-sub-menu__title {
        &:hover {
          background-color: vars.$menuLightHover !important;
        }
      }

      // 父菜单在子菜单选中时不高亮（只高亮子菜单项）
      .el-sub-menu.is-active > .el-sub-menu__title {
        color: vars.$menuLightText !important;
        background-color: transparent !important;
        font-weight: normal !important;
        box-shadow: none !important;
      }

      // 嵌套菜单项样式
      .nest-menu .el-sub-menu > .el-sub-menu__title,
      .el-sub-menu .el-menu-item {
        &:hover {
          background-color: vars.$menuLightHover !important;
        }
      }

      .nest-menu .el-sub-menu .el-menu-item.is-active {
        background-color: vars.$menuLightActiveBg !important;
        color: vars.$menuLightActiveText !important;
        font-weight: 700;
        box-shadow: inset 0 0 10px rgba(22, 119, 255, 0.08);
        
        &::before {
          content: '';
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          width: 4px;
          height: 70%;
          background: linear-gradient(180deg, vars.$menuLightActiveText 0%, #4096ff 100%);
          border-radius: 0 3px 3px 0;
          box-shadow: 0 0 6px rgba(22, 119, 255, 0.4);
        }
      }
    }

    & .nest-menu .el-sub-menu>.el-sub-menu__title,
    & .el-sub-menu .el-menu-item {
      min-width: vars.$base-sidebar-width !important;
      transition: all 0.3s ease;

      &:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
      }
    }

    & .theme-dark .nest-menu .el-sub-menu>.el-sub-menu__title,
    & .theme-dark .el-sub-menu .el-menu-item {
      background-color: vars.$base-sub-menu-background;

      &:hover {
        background-color: vars.$base-sub-menu-hover !important;
      }
    }

    & .theme-dark .nest-menu .el-sub-menu .el-menu-item.is-active {
      background-color: rgba(255, 255, 255, 0.25) !important;
      color: vars.$base-menu-color-active !important;
      font-weight: 600;
      box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.1);
      
      &::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 4px;
        height: 70%;
        background-color: #ffffff;
        border-radius: 0 3px 3px 0;
        box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
      }
    }

    // 暗色主题：父菜单在子菜单选中时不高亮
    & .theme-dark .el-sub-menu.is-active > .el-sub-menu__title {
      color: vars.$base-menu-color !important;
      background-color: transparent !important;
      font-weight: normal !important;
      box-shadow: none !important;
    }
  }

  .hideSidebar {
    .sidebar-container {
      width: 54px !important;
    }

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

    .sub-menu-title-noDropdown {
      padding: 0 !important;
      position: relative;

      .el-tooltip {
        padding: 0 !important;

        .svg-icon {
          margin-left: 20px;
        }
      }
    }

    .el-sub-menu {
      overflow: hidden;

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

        .svg-icon {
          margin-left: 20px;
        }

      }
    }

    .el-menu--collapse {
      .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: vars.$base-sidebar-width !important;
  }

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

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

    &.hideSidebar {
      .sidebar-container {
        pointer-events: none;
        transition-duration: 0.3s;
        transform: translate3d(-(vars.$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;
    }
  }

  .nest-menu .el-sub-menu>.el-sub-menu__title,
  .el-menu-item {
    &:hover {
      // you can use $sub-menuHover
      background-color: rgba(0, 0, 0, 0.06) !important;
    }
  }

  // the scroll bar appears when the sub-menu is too long
  >.el-menu--popup {
    max-height: 100vh;
    overflow-y: auto;

    &::-webkit-scrollbar-track-piece {
      background: #d3dce6;
    }

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-thumb {
      background: #99a9bf;
      border-radius: 20px;
    }
  }
}
