@keyframes sidebarFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#app {

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

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

  .sidebar-container {
    -webkit-transition: width .28s ease-in-out;
    transition: width 0.28s ease-in-out, box-shadow 0.3s ease;
    width: $base-sidebar-width !important;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    height: 100vh;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1001;
    overflow: hidden;
    border-radius: 0 20px 20px 0;
    -webkit-box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    
    // 添加悬停效果
    &:hover {
      box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    }
    
    // 进入动画仅用透明度；勿对侧栏本体使用 transform，
    // 否则会影响子菜单弹出层（popper-append-to-body）的定位，出现跑偏、重影。
    animation: sidebarFadeIn 0.45s ease-out;

    // 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% - 60px);
      }
    }

    .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;
      font-size: 14px;
      background: transparent !important;
      padding: 10px 0;
    }

    .el-menu-item, .el-submenu__title {
      overflow: hidden !important;
      text-overflow: ellipsis !important;
      white-space: nowrap !important;
      font-size: 14px !important;
      font-weight: 600;
      color: $base-menu-color !important;
      background: transparent !important;
      border-radius: 12px;
      margin: 4px 12px;
      padding: 0 16px !important;
      height: 48px;
      line-height: 48px;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      position: relative;

      &:hover {
        background: rgba(25, 118, 210, 0.1) !important;
        color: $base-menu-color-active !important;
        transform: translateX(4px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      }
      
      &.is-active {
        background: rgba(21, 101, 192, 0.18) !important;
        color: $base-menu-color-active !important;
        font-weight: 600;
        box-shadow: 0 4px 16px rgba(21, 101, 192, 0.2);
        
        &::before {
          content: '';
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          width: 4px;
          height: 20px;
          background: $base-menu-color-active;
          border-radius: 0 2px 2px 0;
        }
      }
    }

    // 仅在侧栏菜单「未折叠」时强制标题 span 可见；勿写在通用 .el-menu-item 上，
    // 否则会覆盖 Element 折叠态样式，导致收起后文字仍挤出侧栏。
    .el-menu:not(.el-menu--collapse) {
      .el-menu-item,
      .el-submenu > .el-submenu__title {
        span {
          font-size: 14px !important;
          display: inline-block !important;
          visibility: visible !important;
          opacity: 1 !important;
          width: auto !important;
          height: auto !important;
          overflow: visible !important;
        }
      }
    }

    // 侧栏折叠：单行只保留图标（与 hideSidebar / Element 折叠行为对齐）
    .el-menu.el-menu--collapse {
      .el-menu-item,
      .el-submenu > .el-submenu__title {
        overflow: hidden !important;
      }

      // 折叠态不要用 translate 做悬停位移，否则会抖动 reference，Popper 浮层错位/叠层
      > .el-menu-item:hover,
      > .el-submenu > .el-submenu__title:hover {
        transform: none !important;
        box-shadow: none !important;
      }

      .el-submenu > .el-submenu__title .el-submenu__icon-arrow {
        display: none !important;
      }

      // 含 el-tooltip 包裹时文字不在 li 的直接子 span 上，故用后代选择器
      > .el-menu-item span,
      > .el-submenu > .el-submenu__title span {
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        display: inline-block !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 0 !important;
        line-height: 0 !important;
      }

      .svg-icon:hover {
        transform: none !important;
      }
    }

    // 子菜单样式优化
    .el-submenu {
      .el-submenu__title {
        border-radius: 12px;
        margin: 4px 12px;
        padding: 0 16px !important;
        height: 48px;
        line-height: 48px;
        
        &:hover {
          background: rgba(25, 118, 210, 0.1) !important;
          color: $base-menu-color-active !important;
          transform: translateX(4px);
        }
      }
      
      .el-menu {
        background: rgba(255, 255, 255, 0.3) !important;
        border-radius: 12px;
        margin: 8px 12px;
        padding: 8px 0;
        box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
        
        .el-menu-item {
          margin: 2px 8px;
          padding: 0 24px !important;
          height: 40px;
          line-height: 40px;
          font-size: 13px !important;
          
          span {
            font-size: 13px !important;
            display: inline-block !important;
            visibility: visible !important;
            opacity: 1 !important;
            width: auto !important;
            height: auto !important;
            overflow: visible !important;
          }
          
          &:hover {
            background: rgba(25, 118, 210, 0.08) !important;
            color: $base-menu-color-active !important;
            transform: translateX(2px);
          }
          
          &.is-active {
            background: rgba(21, 101, 192, 0.14) !important;
            color: $base-menu-color-active !important;
            
            &::before {
              width: 3px;
              height: 16px;
            }
          }
        }
      }
    }
    
    // 图标样式优化
    .svg-icon {
      color: #1e293b !important;
      transition: all 0.3s ease;
      margin-right: 12px;
      
      &:hover {
        color: $base-menu-color-active !important;
        transform: scale(1.1);
      }
    }
  }

  .hideSidebar {
    .sidebar-container {
      width: 54px !important;
      // 折叠时关闭毛玻璃，避免 Chromium 下与 Popper 浮层定位/重影异常
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
    }

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

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

      .el-tooltip {
        padding: 0 !important;

        .svg-icon {
          margin-left: 20px;
        }
      }
      
      span {
        height: 0 !important;
        width: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
        display: inline-block !important;
      }
    }

    .el-submenu {
      overflow: hidden;

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

        .svg-icon {
          margin-left: 20px;
        }
        
        span {
          height: 0 !important;
          width: 0 !important;
          overflow: hidden !important;
          visibility: hidden !important;
          display: inline-block !important;
        }
      }
    }

    .el-menu--collapse {
      .el-submenu {
        &>.el-submenu__title {
          &>span {
            height: 0 !important;
            width: 0 !important;
            overflow: hidden !important;
            visibility: hidden !important;
            display: inline-block !important;
          }
        }
      }
      
      .el-menu-item {
        span {
          height: 0 !important;
          width: 0 !important;
          overflow: hidden !important;
          visibility: hidden !important;
          display: inline-block !important;
        }
      }
    }
  }

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

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

    .sidebar-container {
      transition: transform .28s ease-in-out;
      width: $base-sidebar-width !important;
      border-radius: 0;
      
      // 移动端优化
      .el-menu-item, .el-submenu__title {
        margin: 2px 8px;
        padding: 0 12px !important;
        height: 44px;
        line-height: 44px;
        font-size: 13px;
      }
      
      .el-submenu .el-menu-item {
        height: 36px;
        line-height: 36px;
        font-size: 12px;
      }
    }

    &.hideSidebar {
      .sidebar-container {
        pointer-events: none;
        transition-duration: 0.3s;
        transform: translate3d(-$base-sidebar-width, 0, 0);
        box-shadow: none;
      }
    }
  }
  
  // 平板设备优化
  @media (max-width: 1024px) {
    .sidebar-container {
      .el-menu-item, .el-submenu__title {
        font-size: 13px;
        height: 44px;
        line-height: 44px;
      }
    }
  }
  
  // 小屏幕优化
  @media (max-width: 768px) {
    .sidebar-container {
      border-radius: 0;
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
      
      .el-menu {
        padding: 8px 0;
      }
      
      .el-menu-item, .el-submenu__title {
        margin: 2px 6px;
        padding: 0 10px !important;
        height: 40px;
        line-height: 40px;
        font-size: 12px;
      }
    }
  }

  .withoutAnimation {

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

}

.el-menu--popup {
  z-index: 3050 !important;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 0;
  
  .el-menu-item {
    color: $base-menu-color !important;
    margin: 2px 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    
    &:hover {
      background: rgba(25, 118, 210, 0.1) !important;
      color: $base-menu-color-active !important;
    }
    
    &.is-active {
      background: rgba(21, 101, 192, 0.15) !important;
      color: $base-menu-color-active !important;
    }
  }
  
  // 自定义滚动条
  &::-webkit-scrollbar-track-piece {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
  }

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

  &::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    
    &:hover {
      background: rgba(255, 255, 255, 0.5);
    }
  }
}

// 收起状态下的样式
.el-menu--vertical {
  &>.el-menu {
    .svg-icon {
      margin-right: 16px;
    }
  }

  .nest-menu .el-submenu>.el-submenu__title,
  .el-menu-item {
    &:hover {
      background: rgba(255, 255, 255, 0.15) !important;
    }
  }
}
