
.nut-popover {
  position: absolute;
  display: inline-block;
  word-break: normal;

  &-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;

    &-top {
      bottom: 0;
      border-top-color: $popover-border-color;
      border-bottom-width: 0;
      margin-bottom: -8px;
    }

    &-bottom {
      top: 0px;
      border-bottom-color: $popover-border-color;
      border-top-width: 0;
      margin-top: -8px;
    }

    &-left {
      right: 0px;
      border-left-color: $popover-border-color;
      border-right-width: 0;
      margin-right: -8px;

      &.nut-popover-arrow-left {
        top: 50%;
        transform: translateY(-50%);
      }

      &.nut-popover-arrow-left-start {
        top: 16px;
        transform: translateY(0%);
      }

      &.nut-popover-arrow-left-end {
        bottom: 16px;
        transform: translateY(0%);
      }
    }

    &-right {
      left: 0px;
      border-right-color: $popover-border-color;
      border-left-width: 0;
      margin-left: -8px;

      &.nut-popover-arrow-right {
        top: 50%;
        transform: translateY(-50%);
      }

      &.nut-popover-arrow-right-start {
        top: 16px;
        transform: translateY(0%);
      }

      &.nut-popover-arrow-right-end {
        bottom: 16px;
        transform: translateY(0%);
      }
    }
  }

  .nut-popover-content {
    position: absolute;
    background-color: $popover-content-background-color;
    border-radius: $popover-border-radius;
    font-size: $popover-font-size;
    font-family: PingFangSC;
    font-weight: normal;
    color: $popover-text-color;
    box-shadow: 0 2px 12px #3232331f;
    max-height: initial;
    overflow-y: initial;

    &-group {
      display: block;
      height: 100%;
      width: 100%;
    }

    .nut-popover-menu-item {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: $popover-menu-item-padding;
      border-bottom: 1px solid $popover-divider-color;
      max-width: $popover-menu-item-width;
      word-wrap: break-word;

      &:last-child {
        margin-bottom: 0px;
        border-bottom: none;
      }

      &:hover:nth-of-type(2) {
        border-radius: 8px 8px 0px 0px;
      }

      &:hover:last-of-type {
        border-radius: 0px 0px 8px 8px;
      }

      &-icon {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 12px;
        height: 12px;
        font-size: 12px;
        .nut-icon {
          width: 12px;
          height: 12px;
          font-size: 12px;
        }
      }

      &-name {
        width: calc(100% - 34px);
        word-break: keep-all;
        margin: 0 6px 0 4px;
        flex: 1;
      }

      &-action-icon {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 12px;
        height: 12px;
        font-size: 12px;
        color: $color-text;
      }

      &.nut-popover-menu-disabled {
        color: $popover-disable-color;
        cursor: not-allowed;
      }

      &.nut-popover-menu-taroitem {
        display: flex;
      }
    }

    &-top {
      .nut-popover-arrow-top {
        left: 50%;
        transform: translateX(-50%);
      }
    }

    &-top-end {
      right: 0;
      .nut-popover-arrow-top-end {
        right: 16px;
        transform: translateX(0%);
      }
    }

    &-top-start {
      left: 0;
      .nut-popover-arrow-top-start {
        left: 16px;
        transform: translateX(0%);
      }
    }

    &-bottom {
      .nut-popover-arrow-bottom {
        left: 50%;
        transform: translateX(-50%);
      }
    }

    &-bottom-end {
      right: 0;
      .nut-popover-arrow-bottom-end {
        right: 16px;
        transform: translateX(0%);
      }
    }

    &-bottom-start {
      left: 0;
      .nut-popover-arrow-bottom-start {
        left: 16px;
        transform: translateX(0%);
      }
    }

    &-left-end {
      bottom: 0;
    }

    &-left-start {
      top: 0;
    }

    &-right-end {
      bottom: 0;
    }

    &-right-start {
      top: 0;
    }
  }
}

.nut-popover-dark {
  background: $popover-text-color;
  color: $popover-content-background-color;

  .nut-popover-arrow {
    &-top {
      border-top-color: $popover-text-color;
    }
    &-bottom {
      border-bottom-color: $popover-text-color;
    }
    &-left {
      border-left-color: $popover-text-color;
    }
    &-right {
      border-right-color: $popover-text-color;
    }
  }

  .nut-popover-content {
    background: $popover-text-color !important;
    color: $popover-content-background-color !important;
    .nut-popover-menu-item {
      border-bottom-color: $popover-content-background-color;
      &:hover {
        color: $popover-content-background-color;
        background-color: $popover-text-color;
      }
    }
  }
}

[dir='rtl'] .nut-popover,
.nut-rtl .nut-popover {
  .nut-popover-content {
    .nut-popover-menu-item {
      &-name {
        margin-left: 0;
        margin-right: 4px;
      }

      &-action-icon {
        right: auto;
        left: $popover-menu-item-padding;
      }
    }
    &-top {
      .nut-popover-arrow-top {
        left: auto;
        right: 50%;
        transform: translateX(50%);
      }
    }
    &-top-end {
      right: auto;
      left: 0;

      .nut-popover-arrow-top-end {
        right: auto;
        left: 16px;
      }
    }

    &-top-start {
      left: auto;
      right: 0;

      .nut-popover-arrow-top-start {
        left: auto;
        right: 16px;
      }
    }

    &-bottom {
      .nut-popover-arrow-bottom {
        left: auto;
        right: 50%;
        transform: translateX(50%);
      }
    }
    &-bottom-end {
      right: auto;

      left: 0;

      .nut-popover-arrow-bottom-end {
        right: auto;
        left: 16px;
      }
    }

    &-bottom-start {
      left: auto;
      right: 0;

      .nut-popover-arrow-bottom-start {
        left: auto;
        right: 16px;
      }
    }
  }
}

.nut-popover-enter-from,
.nut-popover-leave-active {
  transform: scale(0.8);
  opacity: 0;
}

.nut-popover-enter-active {
  transition-timing-function: ease-out;
}

.nut-popover-leave-active {
  transition-timing-function: ease-in;
}

.nut-popover-content-bg {
  position: fixed;
  height: 100%;
  width: 100%;
  top: 0;
  left: 0;
  background: transparent;
  z-index: 999;
}

[dir='rtl'] .nut-popover-content-bg,
.nut-rtl .nut-popover-content-bg {
  left: auto;
  right: 0;
}

.nut-popover-wrapper {
  display: inline-block;
}

// Taro
.nut-popover-content-copy {
  position: absolute;
  top: -99999px;
}
