@use "../mixins/function.scss" as *;
@use "../mixins/mixins.scss" as *;

@include b(menu) {
  height: 100%;
  overflow: hidden;
  font-size: getCssVar("font-size", "medium");
  transition:
    background-color 0.3s getCssVar("bezier", "1"),
    opacity 0.3s getCssVar("bezier", "1"),
    width 0.3s getCssVar("bezier", "1");
  @include e(content) {
    width: 100%;
    display: flex;
    gap: 4px;
    overflow: hidden;
  }
  @include m(horizontal) {
    @include be(menu, content) {
      flex-direction: row;
      height: 50px;
      padding: 0 20px;
    }
    @include be(menu, sub-menu) {
      width: fit-content;
      height: 100%;
      flex-direction: row;
      align-items: center;
    }
    @include be(menu, sub-title) {
      padding: 0 12px;
      border-radius: getCssVar("radius", "medium");
      @include when(active) {
        background-color: getCssVar("color", "fill-2");
        color: getCssVar("color", "primary-6");
      }
    }
    @include be(menu, item) {
      width: fit-content;
      height: 100%;
    }
    @include be(menu, item-title) {
      padding: 0 12px;
      border-radius: getCssVar("radius", "medium");
      align-items: center;
      @include when(active) {
        &::before {
          content: "";
          display: none;
        }
      }
    }
  }
  @include m(vertical) {
    @include be(menu, content) {
      flex-direction: column;
    }
  }
  @include e(sub-menu) {
    width: 100%;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    @include when(collapse) {
      @include be(menu, sub-title) {
        justify-content: center;
        padding: 0;
        @include when(active) {
          background-color: getCssVar("color", "fill-2");
          color: getCssVar("color", "primary-6");
        }
      }
      @include be(menu, item-title) {
        @include when(active) {
          &::before {
            content: "";
            display: none;
          }
        }
      }
    }
  }
  @include e(sub-title) {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 40px;
    gap: 8px;
    padding-left: calc(var(--s-menu-level) * 20px);
    padding-right: 20px;
    &:hover {
      background-color: getCssVar("color", "fill-2");
    }
    @include when(active) {
      color: getCssVar("color", "primary-6");
    }
  }
  @include e(sub-icon) {
    display: flex;
    align-items: center;
  }
  @include e(sub-label) {
    flex: 1;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  @include e(sub-arrow) {
    display: flex;
    align-items: center;
    font-size: getCssVar("font-size", "large");
  }
  @include e(sub-content) {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  @include e(item) {
    display: flex;
    align-items: center;
    width: 100%;
  }
  @include e(item-title) {
    height: 40px;
    width: 100%;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    padding-left: calc(20px + var(--s-menu-level) * 20px);
    padding-right: 20px;
    position: relative;
    gap: 8px;
    &:hover {
      background-color: getCssVar("color", "fill-2");
    }
    @include when(active) {
      color: #fff;
      background-color: getCssVar("color", "primary-6");
    }
    @include when(active-left) {
      background: linear-gradient(
        to right,
        getCssVar("color", "primary-1"),
        getCssVar("color", "primary-3")
      );
      color: getCssVar("color", "primary-6");
      &::before {
        content: "";
        position: absolute;
        height: 100%;
        width: 4px;
        top: 0;
        left: 0;
        background-color: getCssVar("color", "primary-6");
      }
    }
    @include when(active-right) {
      background: linear-gradient(
        to right,
        getCssVar("color", "primary-3"),
        getCssVar("color", "primary-1")
      );
      color: getCssVar("color", "primary-6");
      &::after {
        content: "";
        position: absolute;
        height: 100%;
        width: 4px;
        top: 0;
        right: 0;
        background-color: getCssVar("color", "primary-6");
      }
    }
  }
  @include e(item-icon) {
    display: flex;
    align-items: center;
  }
  @include e(item-label) {
    flex: 1;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  @include e(pop-content) {
    border-radius: getCssVar("radius", "medium");
    background-color: getCssVar("color", "bg-3");
    box-shadow: getCssVar("shadow", "1");
    border: 1px solid getCssVar("color", "fill-3");
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;

    @include be(menu, sub-title) {
      justify-content: flex-start !important;
      padding: 0 20px !important;
    }

    @include be(menu, item-title) {
      justify-content: flex-start !important;
      padding: 0 20px !important;

      @include when(active) {
        background-color: getCssVar("color", "fill-2");
        color: getCssVar("color", "primary-6");
        &::before {
          content: "";
          display: none;
        }
      }
    }
  }
  @include e(group) {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  @include e(group-title) {
    height: 40px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: getCssVar("font-size", "medium");
    color: getCssVar("color", "text-2");
    padding-left: calc(var(--s-menu-level) * 20px);
    padding-right: 20px;
  }
  @include e(group-icon) {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  @include e(group-label) {
    flex: 1;
  }
  @include e(group-content) {
    display: flex;
    flex-direction: column;
    gap: 4px;
    @include within-be(menu, item-title) {
      padding-left: calc(20px + var(--s-menu-level) * 20px);
    }
    @include within-be(menu, sub-title) {
      padding-left: calc(20px + var(--s-menu-level) * 20px);
    }
  }
}
