@import '../../../../styles/mixins/index';

.nut-tabs {
  display: flex;
}

.nut-tabs-horizontal {
  flex-direction: column;
}

.nut-tabs-titles {
  display: flex;
  box-sizing: border-box;
  height: $tabs-titles-height;
  user-select: none;
  overflow-x: auto;
  overflow-y: hidden;
  background: $tabs-titles-background-color;
  scrollbar-width: none;

  &::-webkit-scrollbar {
    display: none;
    width: 0;
    background: transparent;
  }

  .nut-tabs-list {
    width: 100%;
    display: flex;
    flex-shrink: 0;
  }

  &-left {
    justify-content: flex-start;
    .nut-tabs-titles-item {
      padding: 0 scale-px(22px);
    }
  }

  &-right {
    justify-content: flex-end;
    .nut-tabs-titles-item {
      padding: 0 scale-px(22px);
    }
  }

  &-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 0 auto;
    padding: 0 $tabs-titles-gap;
    height: $tabs-titles-height;
    line-height: $tabs-titles-height;
    min-width: $tabs-titles-item-min-width;
    font-size: $tabs-titles-font-size;
    color: $tabs-titles-item-color;
    text-overflow: ellipsis;
    white-space: nowrap;

    .nut-icon {
      color: $tabs-titles-item-color;
    }

    &-left,
    &-right {
      flex: none;
    }

    &-text {
      color: $tabs-titles-item-color;
    }

    &-smile,
    &-line {
      position: absolute;
      transition: width 0.3s ease;
      width: 0;
      height: 0;
      content: ' ';
      left: 50%;
      transform: translate(-50%, 0);
      bottom: $tabs-tab-line-bottom;
      border-radius: $tabs-tab-line-border-radius;
      opacity: $tabs-tab-line-opacity;
      overflow: hidden;
    }

    &-smile {
      bottom: $tabs-titles-item-smile-bottom;

      .nut-icon {
        position: absolute;
        font-size: $font-size-2xl;
        width: 100%;
        height: 100%;
      }
    }

    &-smile-icon {
      width: scale-px(40px);
      height: scale-px(20px);
    }

    &-active {
      .nut-icon {
        color: $tabs-titles-item-active-color;
      }

      .nut-tabs-titles-item-text {
        color: $tabs-titles-item-active-color;
        font-weight: $tabs-titles-item-active-font-weight;
      }

      .nut-tabs-titles-item-line {
        /* #ifndef dynamic*/
        overflow: unset;
        /* #endif */
        content: ' ';
        width: $tabs-tab-line-width;
        height: $tabs-tab-line-height;
        background: $tabs-tab-line-color;
      }

      .nut-tabs-titles-item-smile {
        /* #ifndef dynamic*/
        overflow: unset;
        /* #endif */
        width: scale-px(40px);
        height: scale-px(20px);

        .nut-icon {
          color: $tabs-titles-item-active-color;
        }
      }
    }

    &-disabled {
      color: $color-text-disabled;
      .nut-icon {
        color: $color-text-disabled;
      }
      .nut-tabs-titles-item-text {
        color: $color-text-disabled;
      }
    }
  }

  &-simple {
    .nut-tabs-titles-item {
      &-active {
        .nut-tabs-titles-item-text,
        .nut-icon {
          color: $color-title;
          font-size: $tabs-titles-item-active-font-size;
        }
      }
    }
  }

  &-card {
    .nut-tabs-titles-item {
      &-active {
        font-weight: $font-weight-bold;
        background-color: $white;
        border-radius: $radius-base $radius-base 0 0;
      }
    }
  }

  &-button {
    .nut-tabs-titles-item {
      padding: 0 scale-px(10px);
      .nut-tabs-titles-item-text {
        flex: 1;
        height: scale-px(28px);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 scale-px(8px);
      }
    }
    .nut-tabs-titles-item-active {
      .nut-tabs-titles-item-text {
        background: $color-default-light;
        color: $tabs-titles-item-active-color;
        border-radius: $tabs-tab-button-border-radius;
        font-weight: $font-weight-bold;
        background-color: $tabs-tab-button-active-background-color;
        border: $tabs-tab-button-active-border;
      }
    }
  }

  &-divider {
    border-bottom: scale-px(1px) solid $color-border;

    .nut-tabs-titles-item {
      position: relative;

      &::after {
        content: '';
        position: absolute;
        right: 0;
        top: 50%;
        height: 50%;
        width: scale-px(1px);
        background: $color-border;
        transform: translateY(-50%);
      }

      &:last-child {
        &::after {
          display: none;
        }
      }
    }
  }
}

.nut-tabs-vertical {
  .nut-tabs-ellipsis {
    white-space: break-spaces;
    /* #ifdef harmony dynamic*/
    padding-left: scale-px(12px);
    /* #endif */
    /* #ifndef harmony dynamic*/
    padding-left: scale-px(6px);
    /* #endif */
    width: scale-px(90px);
    line-height: $font-size-base;
  }

  .nut-tabs-titles {
    flex-direction: column;
    height: 100%;
    width: $tabs-vertical-titles-width;
    flex-shrink: 0;

    .nut-tabs-list {
      flex-direction: column;
    }
  }

  .nut-tabs-titles-item {
    height: $tabs-vertical-titles-item-height;
    flex: none;

    &-smile {
      overflow: hidden;
      transition: width 0.3s ease;
    }

    &-line {
      transform: translate(0, -50%);
      transition: height 0.3s ease;

      &-vertical {
        top: 50%;
      }
    }

    &-active {
      background-color: $tabs-titles-item-active-background-color;
      .nut-tabs-titles-item-line {
        left: scale-px(10px);
        width: $tabs-vertical-tab-line-width;
        height: $tabs-vertical-tab-line-height;
        background: $tabs-vertical-tab-line-color;
      }

      .nut-tabs-titles-item-smile {
        right: scale-px(-12px);
        bottom: -2%;
        left: auto;
        transform: rotate(320deg);
      }
    }
  }

  .nut-tabs-horizontal {
    .nut-tabs-titles {
      flex-direction: row;
      height: $tabs-titles-height;
      width: 100%;
      padding: 0 !important;

      .nut-tabs-list {
        flex-direction: row;
        height: auto;
      }
    }

    .nut-tabs-content {
      flex-direction: row;
    }

    .nut-tabs-titles-item-active {
      background-color: initial;

      .nut-tabs-titles-item-line {
        left: 50%;
        transform: translate(-50%, 0);
        width: $tabs-tab-line-width;
        height: $tabs-tab-line-height;
        background: $tabs-tab-line-color;
      }

      .nut-tabs-titles-item-smile {
        left: 50%;
        right: auto;
        bottom: scale-px(-3px);
        transform: translate(-50%, 0) rotate(0deg);
      }
    }
  }

  .nut-tabs-content {
    flex-direction: column;
    height: 100%;

    &-wrap {
      flex: 1;
    }

    .nut-tabpane {
      height: 100%;
    }
  }
}

.nut-tabs-content {
  display: flex;
  box-sizing: border-box;

  &-wrap {
    overflow: hidden;
  }
}

[dir='rtl'] .nut-tabs-titles,
.nut-rtl .nut-tabs-titles {
  &-item {
    &-smile,
    &-line {
      left: auto;
      right: 50%;
      transform: translate(50%, 0);
    }
  }
  &-divider {
    .nut-tabs-titles-item {
      &::after {
        right: auto;
        left: 0;
      }
    }
  }
}

[dir='rtl'] .nut-tabs-vertical,
.nut-rtl .nut-tabs-vertical {
  .nut-tabs-titles {
    &-line {
      .nut-tabs-titles-item {
        padding-left: 0;
        padding-right: scale-px(14px);
      }
    }
  }

  .nut-tabs-titles-item {
    &-active {
      .nut-tabs-titles-item-line {
        left: auto;
        right: scale-px(10px);
      }

      .nut-tabs-titles-item-smile {
        left: scale-px(-12px);
        right: auto;
        transform: rotate(-320deg);
      }
    }
  }

  .nut-tabs-horizontal {
    .nut-tabs-titles-item-active {
      .nut-tabs-titles-item-line {
        left: auto;
        right: 50%;
        transform: translate(50%, 0);
      }

      .nut-tabs-titles-item-smile {
        right: 50%;
        left: auto;
        transform: translate(50%, 0) rotate(0deg);
      }
    }
  }
}
