/**
 * Menu Style
 */
@import '../variables/index.scss';

.at-menu {
  position: relative;
  display: block;
  margin: 0;
  padding: 0;
  color: $menu-text-color;
  font-size: $menu-font-size;
  list-style: none;
  background-color: $menu-bg-color-light;

  /* element */
  &__item {
    position: relative;
    display: block;
    list-style: none;
    transition: color .3s;
    cursor: pointer;
    z-index: 1;

    a {
      display: inline-block;
      width: 100%;
      height: 100%;
      color: $menu-text-color;
    }
    i {
      margin-right: 8px;
    }
    .at-menu__item-link {
      padding: $menu-item-padding;
      width: 100%;
    }

    &--disabled {
      cursor: not-allowed;

      .at-menu__item-link {
        color: $menu-text-color-disabled;
        cursor: not-allowed;
        pointer-events: none;

        &::after {
          display: none;
        }
      }
    }
  }
  &__item-group {
    padding: 0;
    line-height: 1;

    &-title {
      @include ellipsis();
      width: 100%;
      padding: $menu-group-title-padding;
      color: $menu-group-title-text-color;
      font-size: $menu-group-title-font-size;
      line-height: 1;
      white-space: nowrap;
      overflow: hidden;
      transition: all .3s;
      cursor: initial;
    }
    &-list {
      padding: 0;
    }
  }
  &__submenu {
    &--disabled {
      color: $menu-text-color-disabled;
      cursor: not-allowed;
    }
  }
  &__submenu-title {
    position: relative;
    cursor: pointer;

    i {
      margin-right: 8px;
    }
  }
  .at-dropdown__popover {
    width: 100%;
  }
  .at-dropdown-menu {
    max-height: none;

    .at-menu__item {
      @include ellipsis();
      display: block;
      font-size: $menu-dropdown-item-font-size;
      line-height: 1.5;
      white-space: nowrap;
      transition: all .3s;
      cursor: pointer;

      &--disabled {
        cursor: not-allowed;
      }
    }
  }

  /* modifier */
  &--horizontal,
  &--vertical,
  &--inline {
    z-index: auto;
  }

  &--horizontal,
  &--vertical {
    .at-menu__item-group-list .at-menu__item {
      float: none;

      &.at-menu__item--active .at-menu__item-link,
      .at-menu__item-link.router-link-active {
        color: $menu-item-text-color-active;
        font-weight: bold;
        // background-color: $menu-item-bg-color-active;

        &::after {
          display: none;
        }
      }
    }
  }

  /* Horizontal */
  &--horizontal {
    position: relative;
    height: $menu-height-horizontal;
    line-height: $menu-height-horizontal;
    border-bottom: 1px solid $menu-border-color;

    .at-menu__item,
    .at-menu__submenu {
      position: relative;
      float: left;
    }
    .at-menu__item {
      &.at-menu__item--active {
        .at-menu__item-link {
          color: $menu-item-text-color-active;

          a {
            color: $menu-item-text-color-active;
          }
          &::after {
            transform: scaleX(1);
          }
        }
      }
      &--disabled {
        .at-menu__item-link {
          color: $menu-text-color-disabled;

          &:hover {
            color: $menu-text-color-disabled;
          }
        }
      }
    }
    .at-menu__item-link {
      display: inline-block;
      padding: $menu-item-padding-base;

      &::after {
        content: '';
        position: absolute;
        display: inline-block;
        width: 100%;
        height: 2px;
        left: 0;
        bottom: 0;
        background-color: $menu-item-text-color-active;
        transform: scaleX(0);
        transition: all .15s;
      }
      &:hover,
      &.router-link-active {
        color: $menu-item-text-color-active;

        &::after {
          transform: scaleX(1);
        }
      }
    }
    > .at-menu__submenu {
      &:hover,
      &.at-menu__submenu--active {
        > .at-menu__submenu-title {
          color: $menu-item-text-color-active;
        }
        &::after {
          transform: scaleX(1);
        }
      }
    }
    .at-menu__submenu {
      &::after {
        content: '';
        position: absolute;
        display: inline-block;
        width: 100%;
        height: 2px;
        left: 0;
        bottom: 0;
        background-color: $menu-item-text-color-active;
        transform: scaleX(0);
        transition: all .15s;
      }
      .at-menu__submenu-title {
        padding: $menu-item-padding-base;
      }
      .at-menu__item {
        display: block;
        float: none;

        .at-menu__item-link {
          padding: $menu-submenu-padding;
          padding-left: 16px;

          &::after {
            display: none;
          }
        }
      }
      .at-menu__submenu {
        display: block;
        float: none;
        height: inherit;
        font-size: $menu-dropdown-item-font-size;
        line-height: 1.5;

        .at-menu__submenu-title {
          padding: $menu-submenu-padding;
          padding-right: 16px;

          i:last-child {
            position: absolute;
            right: 0;
            top: 50%;
            margin-top: -6px;
            transform: rotate(-90deg);
          }
        }
        &.at-menu__submenu--active {
          &::after {
            transform: scaleX(0);
          }
        }
      }

      &:hover,
      &.at-menu__submenu--active {
        > .at-menu__submenu-title {
          color: $menu-item-text-color-active;
        }
      }
      &--disabled {
        &:hover,
        &.at-menu__submenu--active {
          .at-menu__submenu-title {
            color: $menu-text-color-disabled;
            cursor: not-allowed;
          }
          &::after {
            transform: scaleX(0);
          }
        }
      }
    }
  }

  /* Vertical */
  &--vertical {
    position: relative;
    border-right: 1px solid $menu-border-color;

    .at-menu__item,
    .at-menu__submenu {
      position: relative;
      display: block;
    }
    > .at-menu__item.at-menu__item--active {
      > .at-menu__item-link {
        background-color: $menu-item-bg-color-active-inline;

        &::after {
          opacity: 1;
        }
      }
    }
    > .at-menu__submenu {
      &:hover {
        &::after {
          opacity: 1;
        }
        > .at-menu__submenu-title {
          color: $menu-item-text-color-active;
        }
      }
      &.at-menu__submenu--active {
        background-color: $menu-item-bg-color-active-inline;

        &::after {
          opacity: 1;
        }
      }
    }
    > .at-menu__item {
      > .at-menu__item-link {
        &:hover {
          color: $menu-item-text-color-active;

          &::after {
            opacity: 1;
          }
        }
      }
    }
    .at-menu__item {
      &.at-menu__item--active {
        .at-menu__item-link {
          color: $menu-item-text-color-active;

          a {
            color: $menu-item-text-color-active;
          }
        }
      }
      &--disabled {
        &:hover {
          color: $menu-text-color-disabled;

          a {
            color: $menu-text-color-disabled;
          }
        }
        .at-menu__item-link.router-link-active {
          color: $menu-item-text-color-active;

          &:hover {
            color: $menu-item-text-color-active;
          }
        }
      }
    }
    .at-menu__item-link {
      padding: $menu-submenu-padding;
      padding-left: 32px;

      &::after {
        content: '';
        display: inline-block;
        position: absolute;
        top: 0;
        left: 0;
        width: 6px;
        height: 100%;
        background-color: $menu-prefix-bg-color;
        border-top-right-radius: 4px;
        border-bottom-right-radius: 4px;
        box-shadow: 1px 0 12px 0 $menu-prefix-bg-color;
        transition: opacity .2s;
        opacity: 0;
      }
      &:hover {
        color: $menu-item-text-color-active;
      }
      &.router-link-active {
        color: $menu-item-text-color-active;
        background-color: $menu-item-bg-color-active-inline;

        &::after {
          opacity: 1;
        }
      }
    }
    .at-menu__submenu {
      font-size: $menu-font-size;

      &::after {
        content: '';
        display: inline-block;
        position: absolute;
        top: 0;
        left: 0;
        width: 6px;
        height: 100%;
        background-color: $menu-prefix-bg-color;
        border-top-right-radius: 4px;
        border-bottom-right-radius: 4px;
        box-shadow: 1px 0 12px 0 $menu-prefix-bg-color;
        transition: opacity .2s;
        opacity: 0;
      }
      .at-menu__submenu-title {
        padding: $menu-submenu-padding;
        padding-left: 32px;

        i:last-child {
          position: absolute;
          right: 0;
          top: 50%;
          margin-top: -$menu-icon-size / 2;
          transform: rotate(-90deg);
        }
      }
      .at-menu__submenu {
        font-size: $menu-dropdown-item-font-size;

        .at-menu__submenu-title {
          padding-left: 24px;
        }
      }
      .at-menu__item-link {
        padding-left: 24px;
      }

      &:hover,
      &.at-menu__submenu--active {
        > .at-menu__submenu-title {
          color: $menu-item-text-color-active;
        }
      }
      &.at-menu__submenu--disabled {
        &:hover,
        &.at-menu__submenu--active {
          > .at-menu__submenu-title {
            color: $menu-text-color-disabled;
            cursor: not-allowed;
          }
        }
      }
    }
    .at-menu__item-group-title {
      padding-left: 16px;
      font-weight: bold;
    }
  }

  /* Inline */
  &--inline {
    position: relative;
    border-right: 1px solid $menu-border-color;

    .at-menu__item,
    .at-menu__submenu {
      position: relative;
      display: block;
      padding-left: 0;
      transition: all .3s, color 0s;
    }
    .at-menu__item {
      &:hover {
        color: $menu-item-text-color-active;

        > .at-menu__item-link {
          color: $menu-item-text-color-active;
        }
      }
      &.at-menu__item--active {
        .at-menu__item-link {
          color: $menu-item-text-color-active;
          background-color: $menu-item-bg-color-active-inline;

          &::after {
            opacity: 1;
          }
        }
      }
      &--disabled {
        &.at-menu__item--active {
          .at-menu__item-link {
            color: $menu-text-color-disabled;
            background-color: transparent;

            &::after {
              opacity: 0;
            }
          }
        }
      }
    }
    .at-menu__submenu {
      font-size: $menu-font-size;

      &.at-menu__submenu--active {
        > .at-menu__submenu-title {
          color: $menu-item-text-color-active;
        }
      }
      &.at-menu__submenu--disabled {
        &:hover,
        &.at-menu__submenu--active {
          > .at-menu__submenu-title {
            color: $menu-text-color-disabled;
            cursor: not-allowed;
          }
        }
      }
      &.at-menu__submenu--opened {
        .at-menu__submenu-title {
          font-weight: bold;

        }
        .at-menu__submenu-icon {
          transform: rotate(-180deg);
        }
      }

      > .at-menu__submenu-title {
        &:hover {
          color: $menu-item-text-color-active;
        }
      }
      .at-menu__submenu-title {
        padding: $menu-item-padding-inline;
        padding-left: 32px;

        i:last-child {
          position: absolute;
          right: 0;
          top: 50%;
          margin-top: -$menu-icon-size / 2;
        }
      }
      .at-menu__submenu-icon {
        color: $menu-icon-color-inline;
        transition: transform .3s;
      }
      .at-menu__submenu {
        font-size: $menu-font-size;
      }
      .at-menu__item-link {
        padding-left: 48px;
      }
    }
    .at-menu__item-link {
      padding: $menu-item-padding-inline;
      padding-left: 32px;
      transition: all .3s;

      &::after {
        content: '';
        display: inline-block;
        position: absolute;
        top: 0;
        left: 0;
        width: 6px;
        height: 100%;
        background-color: $menu-prefix-bg-color;
        border-top-right-radius: 4px;
        border-bottom-right-radius: 4px;
        box-shadow: 1px 0 12px 0 $menu-prefix-bg-color;
        transition: opacity .2s;
        opacity: 0;
      }
      &.router-link-active {
        color: $menu-item-text-color-active;
        background-color: $menu-item-bg-color-active-inline;

        &::after {
          opacity: 1;
        }
      }
    }
    .at-menu {
      margin: 8px 0;
    }
    .at-menu__item-group-title {
      padding-left: 40px;
      font-weight: bold;
    }
  }

  /* theme */
  &--dark {
    color: $menu-text-color-dark;
    background-color: $menu-bg-color-dark;

    .at-menu {
      color: $menu-text-color-dark;
      background-color: $menu-bg-color-dark;
    }
    .at-menu__item {
      a {
        color: $menu-text-color-dark;
      }
      .at-menu__item-link {
        &::after {
          width: 4px;
          border-radius: 0;
          background-color: $menu-prefix-bg-color-dark;
          box-shadow: none;
        }
      }

      &:hover,
      &.at-menu__item--active {
        .at-menu__item-link {
          color: $menu-text-color-dark-hover;
          background-color: $menu-bg-color-dark-hover;

          a {
            color: $menu-text-color-dark-hover;
          }
        }
      }
      &--disabled {
        opacity: 0.5;

        &:hover,
        &.at-menu__item--active {
          .at-menu__item-link {
            color: $menu-text-color-disabled;
            background-color: transparent;
          }
        }
      }
    }
    .at-menu__submenu {
      &:hover,
      &.at-menu__submenu--active {
        .at-menu__submenu-title {
          color: $menu-text-color-dark-hover;
          font-weight: bold;
        }
      }
      &.at-menu__submenu--disabled {
        .at-menu__submenu-title {
          opacity: .5;
          font-weight: normal;
          cursor: not-allowed;
        }
      }
    }

    &.at-menu--horizontal {
      border: none;

      .at-menu__item,
      .at-menu__submenu {
        &:hover,
        &.at-menu__item--active,
        &.at-menu__submenu--active {
          &::after {
            width: 100%;
            height: 4px;
          }
        }
      }
      .at-menu__submenu {
        &.at-menu__submenu--disabled {
          &:hover,
          &.at-menu__item--active {
            .at-menu__submenu-title {
              color: $menu-text-color-disabled;
            }
          }
        }
        .at-menu__item {
          color: $menu-text-color;

          &:hover,
          &.at-menu__item--active {
            .at-menu__item-link {
              color: $menu-item-text-color-active;
              background-color: transparent;

              a {
                color: $menu-item-text-color-active;
              }
            }
          }
          a {
            color: $menu-text-color;
          }
        }
      }
    }
    &.at-menu--vertical {
      .at-menu__submenu {
        &.at-menu__submenu--active {
          background-color: transparent;

          &::after {
            content: '';
            width: 4px;
            border-radius: 0;
            background-color: $menu-prefix-bg-color-dark;
            box-shadow: none;
            opacity: 1;
          }
        }
        .at-menu__item {
          color: $menu-text-color;

          &:hover,
          &.at-menu__item--active {
            .at-menu__item-link {
              color: $menu-item-text-color-active;
              background-color: transparent;

              a {
                color: $menu-item-text-color-active;
              }
            }
          }
          &.at-menu__item--disabled {
            .at-menu__item-link {
              color: $menu-text-color-disabled;
            }
          }
          a {
            color: $menu-text-color;
          }
        }
      }
    }
  }
}
