@import '../../style/themes/index';
@import '../../style/mixins/index';

@yee-menu-prefix-cls: ~'@{yee-prefix}-menu';

// default theme
.@{yee-menu-prefix-cls} {
  .yee-reset-component;

  margin-bottom: 0;
  padding-left: 0; // Override default ul/ol
  color: @yee-menu-item-color;
  line-height: 0; // Fix display inline-block gap
  list-style: none;
  background: @yee-menu-bg;
  outline: none;
  box-shadow: @yee-box-shadow-base;
  transition:
    background 0.3s,
    width 0.3s cubic-bezier(0.2, 0, 0, 1) 0s;
  .yee-clearfix;

  ul,
  ol {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  &-hidden {
    display: none;
  }

  &-item-group-title {
    padding: 8px 16px;
    color: @yee-menu-item-group-title-color;
    font-size: @yee-font-size-base;
    line-height: @yee-line-height-base;
    transition: all 0.3s;
  }

  &-submenu,
  &-submenu-inline {
    transition:
      border-color 0.3s @yee-ease-in-out,
      background 0.3s @yee-ease-in-out,
      padding 0.15s @yee-ease-in-out;
  }

  &-submenu-selected {
    color: @yee-menu-highlight-color;
  }

  &-item:active,
  &-submenu-title:active {
    background: @yee-menu-item-active-bg;
  }

  &-submenu &-sub {
    cursor: initial;
    transition:
      background 0.3s @yee-ease-in-out,
      padding 0.3s @yee-ease-in-out;
  }

  &-item > a {
    display: block;
    color: @yee-menu-item-color;
    &:hover {
      color: @yee-menu-highlight-color;
    }
    &::before {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      background-color: transparent;
      content: '';
    }
  }

  // https://github.com/ant-design/ant-design/issues/19809
  &-item > .@{yee-prefix}-badge > a {
    color: @yee-menu-item-color;
    &:hover {
      color: @yee-menu-highlight-color;
    }
  }

  &-item-divider {
    height: 1px;
    overflow: hidden;
    line-height: 0;
    background-color: @yee-border-color-split;
  }

  &-item:hover,
  &-item-active,
  &:not(&-inline) &-submenu-open,
  &-submenu-active,
  &-submenu-title:hover {
    color: @yee-menu-highlight-color;
  }

  &-horizontal &-item,
  &-horizontal &-submenu {
    margin-top: -1px;
  }

  &-horizontal > &-item:hover,
  &-horizontal > &-item-active,
  &-horizontal > &-submenu &-submenu-title:hover {
    background-color: transparent;
  }

  &-item-selected {
    color: @yee-menu-highlight-color;
    > a,
    > a:hover {
      color: @yee-menu-highlight-color;
    }
  }

  &:not(&-horizontal) &-item-selected {
    background-color: @yee-menu-item-active-bg;
  }

  &-inline,
  &-vertical,
  &-vertical-left {
    border-right: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
  }
  &-vertical-right {
    border-left: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
  }

  &-vertical&-sub,
  &-vertical-left&-sub,
  &-vertical-right&-sub {
    min-width: 160px;
    padding: 0;
    border-right: 0;
    transform-origin: 0 0;

    .@{yee-menu-prefix-cls}-item {
      left: 0;
      margin-left: 0;
      border-right: 0;
      &::after {
        border-right: 0;
      }
    }
    > .@{yee-menu-prefix-cls}-item,
    > .@{yee-menu-prefix-cls}-submenu {
      transform-origin: 0 0;
    }
  }

  &-horizontal&-sub {
    min-width: 114px; // in case of submenu width is too big: https://codesandbox.io/s/qvpwm6mk66
  }

  &-item,
  &-submenu-title {
    position: relative;
    display: block;
    margin: 0;
    padding: 0 20px;
    white-space: nowrap;
    cursor: pointer;
    transition:
      color 0.3s @yee-ease-in-out,
      border-color 0.3s @yee-ease-in-out,
      background 0.3s @yee-ease-in-out,
      padding 0.15s @yee-ease-in-out;
    .@{yee-iconfont-css-prefix} {
      min-width: 14px;
      margin-right: 10px;
      font-size: @yee-menu-icon-size;
      transition:
        font-size 0.15s @yee-ease-out,
        margin 0.3s @yee-ease-in-out;
      + span {
        opacity: 1;
        transition:
          opacity 0.3s @yee-ease-in-out,
          width 0.3s @yee-ease-in-out;
      }
    }
  }

  & > &-item-divider {
    height: 1px;
    margin: 1px 0;
    padding: 0;
    overflow: hidden;
    line-height: 0;
    background-color: @yee-border-color-split;
  }

  &-submenu {
    &-popup {
      position: absolute;
      z-index: @yee-zindex-dropdown;
      border-radius: @yee-border-radius-base;

      .submenu-title-wrapper {
        padding-right: 20px;
      }

      &::before {
        position: absolute;
        top: -7px;
        right: 0;
        bottom: 0;
        left: 0;
        opacity: 0.0001;
        content: ' ';
      }
    }

    > .@{yee-menu-prefix-cls} {
      background-color: @yee-menu-bg;
      border-radius: @yee-border-radius-base;
      &-submenu-title::after {
        transition: transform 0.3s @yee-ease-in-out;
      }
    }

    &-vertical,
    &-vertical-left,
    &-vertical-right,
    &-inline {
      > .@{yee-menu-prefix-cls}-submenu-title .@{yee-menu-prefix-cls}-submenu-arrow {
        position: absolute;
        top: 50%;
        right: 16px;
        width: 10px;
        transition: transform 0.3s @yee-ease-in-out;
        &::before,
        &::after {
          position: absolute;
          width: 6px;
          height: 1.5px;
          // background + background-image to makes before & after cross have same color.
          // Since `linear-gradient` not work on IE9, we should hack it.
          // ref: https://github.com/ant-design/ant-design/issues/15910
          background: @yee-menu-bg;
          background: ~'@{yee-menu-item-color} \9';
          background-image: linear-gradient(to right, @yee-menu-item-color, @yee-menu-item-color);
          background-image: ~'none \9';
          border-radius: 2px;
          transition:
            background 0.3s @yee-ease-in-out,
            transform 0.3s @yee-ease-in-out,
            top 0.3s @yee-ease-in-out;
          content: '';
        }
        &::before {
          transform: rotate(45deg) translateY(-2px);
        }
        &::after {
          transform: rotate(-45deg) translateY(2px);
        }
      }
      > .@{yee-menu-prefix-cls}-submenu-title:hover .@{yee-menu-prefix-cls}-submenu-arrow {
        &::after,
        &::before {
          background: linear-gradient(to right, @yee-menu-highlight-color, @yee-menu-highlight-color);
        }
      }
    }

    &-inline > .@{yee-menu-prefix-cls}-submenu-title .@{yee-menu-prefix-cls}-submenu-arrow {
      &::before {
        transform: rotate(-45deg) translateX(2px);
      }
      &::after {
        transform: rotate(45deg) translateX(-2px);
      }
    }

    &-open {
      &.@{yee-menu-prefix-cls}-submenu-inline
        > .@{yee-menu-prefix-cls}-submenu-title
        .@{yee-menu-prefix-cls}-submenu-arrow {
        transform: translateY(-2px);
        &::after {
          transform: rotate(-45deg) translateX(-2px);
        }
        &::before {
          transform: rotate(45deg) translateX(2px);
        }
      }
    }
  }

  &-vertical &-submenu-selected,
  &-vertical-left &-submenu-selected,
  &-vertical-right &-submenu-selected {
    color: @yee-menu-highlight-color;
    > a {
      color: @yee-menu-highlight-color;
    }
  }

  &-horizontal {
    line-height: 46px;
    white-space: nowrap;
    border: 0;
    border-bottom: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
    box-shadow: none;

    > .@{yee-menu-prefix-cls}-item,
    > .@{yee-menu-prefix-cls}-submenu {
      position: relative;
      top: 1px;
      display: inline-block;
      vertical-align: bottom;
      border-bottom: 2px solid transparent;

      &:hover,
      &-active,
      &-open,
      &-selected {
        color: @yee-menu-highlight-color;
        border-bottom: 2px solid @yee-menu-highlight-color;
      }
    }

    > .@{yee-menu-prefix-cls}-item {
      > a {
        display: block;
        color: @yee-menu-item-color;
        &:hover {
          color: @yee-menu-highlight-color;
        }
        &::before {
          bottom: -2px;
        }
      }
      &-selected > a {
        color: @yee-menu-highlight-color;
      }
    }

    &::after {
      display: block;
      clear: both;
      height: 0;
      content: '\20';
    }
  }

  &-vertical,
  &-vertical-left,
  &-vertical-right,
  &-inline {
    .@{yee-menu-prefix-cls}-item {
      position: relative;
      &::after {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        border-right: @yee-menu-item-active-border-width solid @yee-menu-highlight-color;
        transform: scaleY(0.0001);
        opacity: 0;
        transition:
          transform 0.15s @yee-ease-out,
          opacity 0.15s @yee-ease-out;
        content: '';
      }
    }

    .@{yee-menu-prefix-cls}-item,
    .@{yee-menu-prefix-cls}-submenu-title {
      height: @yee-menu-item-height;
      margin-top: @yee-menu-item-vertical-margin;
      margin-bottom: @yee-menu-item-vertical-margin;
      padding: 0 16px;
      overflow: hidden;
      font-size: @yee-menu-item-font-size;
      line-height: @yee-menu-item-height;
      text-overflow: ellipsis;
    }

    // disable margin collapsed
    .@{yee-menu-prefix-cls}-submenu {
      padding-bottom: 0.02px;
    }

    .@{yee-menu-prefix-cls}-item:not(:last-child) {
      margin-bottom: @yee-menu-item-boundary-margin;
    }

    > .@{yee-menu-prefix-cls}-item,
    > .@{yee-menu-prefix-cls}-submenu > .@{yee-menu-prefix-cls}-submenu-title {
      height: @yee-menu-inline-toplevel-item-height;
      line-height: @yee-menu-inline-toplevel-item-height;
    }
  }

  &-inline {
    width: 100%;
    .@{yee-menu-prefix-cls}-selected,
    .@{yee-menu-prefix-cls}-item-selected {
      &::after {
        transform: scaleY(1);
        opacity: 1;
        transition:
          transform 0.15s @yee-ease-in-out,
          opacity 0.15s @yee-ease-in-out;
      }
    }

    .@{yee-menu-prefix-cls}-item,
    .@{yee-menu-prefix-cls}-submenu-title {
      width: ~'calc(100% + 1px)';
    }

    .@{yee-menu-prefix-cls}-submenu-title {
      padding-right: 34px;
    }
  }

  &-inline-collapsed {
    width: @yee-menu-collapsed-width;
    > .@{yee-menu-prefix-cls}-item,
    > .@{yee-menu-prefix-cls}-item-group > .@{yee-menu-prefix-cls}-item-group-list > .@{yee-menu-prefix-cls}-item,
    > .@{yee-menu-prefix-cls}-item-group
      > .@{yee-menu-prefix-cls}-item-group-list
      > .@{yee-menu-prefix-cls}-submenu
      > .@{yee-menu-prefix-cls}-submenu-title,
    > .@{yee-menu-prefix-cls}-submenu > .@{yee-menu-prefix-cls}-submenu-title {
      left: 0;
      padding: 0 (@yee-menu-collapsed-width - @yee-menu-icon-size-lg) / 2 !important;
      text-overflow: clip;
      .@{yee-menu-prefix-cls}-submenu-arrow {
        display: none;
      }
      .@{yee-iconfont-css-prefix} {
        margin: 0;
        font-size: @yee-menu-icon-size-lg;
        line-height: @yee-menu-item-height;
        + span {
          display: inline-block;
          max-width: 0;
          opacity: 0;
        }
      }
    }
    &-tooltip {
      pointer-events: none;
      .@{yee-iconfont-css-prefix} {
        display: none;
      }
      a {
        color: @yee-text-color-dark;
      }
    }

    .@{yee-menu-prefix-cls}-item-group-title {
      padding-right: 4px;
      padding-left: 4px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }

  &-item-group-list {
    margin: 0;
    padding: 0;
    .@{yee-menu-prefix-cls}-item,
    .@{yee-menu-prefix-cls}-submenu-title {
      padding: 0 16px 0 28px;
    }
  }

  &-root&-vertical,
  &-root&-vertical-left,
  &-root&-vertical-right,
  &-root&-inline {
    box-shadow: none;
  }

  &-sub&-inline {
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    & > .@{yee-menu-prefix-cls}-item,
    & > .@{yee-menu-prefix-cls}-submenu > .@{yee-menu-prefix-cls}-submenu-title {
      height: @yee-menu-item-height;
      line-height: @yee-menu-item-height;
      list-style-position: inside;
      list-style-type: disc;
    }

    & .@{yee-menu-prefix-cls}-item-group-title {
      padding-left: 32px;
    }
  }

  // Disabled state sets text to gray and nukes hover/tab effects
  &-item-disabled,
  &-submenu-disabled {
    color: @yee-disabled-color !important;
    background: none;
    border-color: transparent !important;
    cursor: not-allowed;
    > a {
      color: @yee-disabled-color !important;
      pointer-events: none;
    }
    > .@{yee-menu-prefix-cls}-submenu-title {
      color: @yee-disabled-color !important;
      cursor: not-allowed;
      > .@{yee-menu-prefix-cls}-submenu-arrow {
        &::before,
        &::after {
          background: @yee-disabled-color !important;
        }
      }
    }
  }
}

@import './dark';
