@import '../../styles/mixins/index';
@import '../tabpane/tabpane.scss';

.nut-tabs {
  display: flex;
}

.nut-tabs-titles {
  display: flex;
  box-sizing: border-box;
  height: $tabs-titles-height;
  padding: $tabs-titles-padding;
  user-select: none;
  overflow: hidden;
  background: $tabs-titles-background-color;

  &::-webkit-scrollbar {
    display: none;
    width: 0;
    background: transparent;
  }

  .nut-tabs-list {
    width: 100%;
    height: auto;
    display: flex;
    flex-shrink: 0;
  }

  &-left {
    justify-content: flex-start;
  }

  &-right {
    justify-content: flex-end;
  }

  &-scrollable {
    overflow-x: auto;
    overflow-y: hidden;
  }

  &-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 0 auto;
    padding: 0 10px;
    margin: 0 $tabs-titles-gap;
    min-width: $tabs-titles-item-min-width;
    font-size: $tabs-titles-font-size;
    color: $tabs-titles-item-color;
    text-overflow: ellipsis;
    white-space: nowrap;

    &.taro {
      height: 44px;
      line-height: 44px;
    }

    &-left,
    &-right {
      flex: none;
    }

    &-text {
      text-align: center;
    }

    &-smile,
    &-line {
      position: absolute;
      transition: width 0.3s ease;
      width: 0;
      height: 0;
      content: ' ';
      bottom: $tabs-tab-line-bottom;
      left: 50%;
      transform: translate(-50%, 0);
      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: 20px;
        width: 100%;
        height: 100%;
        color: $color-primary;
      }
    }

    &-active {
      color: $tabs-titles-item-active-color;
      font-weight: $tabs-titles-item-active-font-weight;

      .nut-tabs-titles-item-line {
        overflow: unset;
        content: ' ';
        width: $tabs-tab-line-width;
        height: $tabs-tab-line-height;
        background: $tabs-tab-line-color;
      }

      .nut-tabs-titles-item-smile {
        overflow: unset;
        width: 40px;
        height: 20px;
      }
    }

    &-disabled {
      color: $color-text-disabled;
    }

    &:first-child {
      margin-left: 0;
    }
  }

  &-simple {
    .nut-tabs-titles-item-active {
      color: $color-title;
      font-size: $tabs-titles-item-active-font-size;
    }
  }

  &-card {
    padding: 0;
    background-color: $color-default-light;
    .nut-tabs-titles-item {
      margin: 0;

      &-active {
        font-weight: $font-weight-bold;
        background-color: $white;
        border-radius: $radius-s $radius-s 0 0;
      }
    }
  }

  &-button {
    .nut-tabs-titles-item {
      &-active {
        &.taro {
          height: 28px;
        }

        margin: 8px 9px;
        background: $color-default-light;
        color: $color-text;
        border-radius: $tabs-tab-button-border-radius;
        font-weight: $font-weight-bold;
        background-color: $tabs-tab-button-active-background-color;
        color: $color-text-link;
        border: $tabs-tab-button-active-border;
      }
    }
  }

  &-divider {
    padding: 0;
    border-bottom: 1px solid $color-border;

    .nut-tabs-titles-item {
      margin: 0;
      position: relative;

      &::after {
        content: '';
        position: absolute;
        right: 0;
        top: 50%;
        height: 50%;
        width: 1px;
        background: $color-border;
        transform: translateY(-50%);
      }

      &:last-child {
        &::after {
          display: none;
        }
      }
    }
  }
}

.nut-tabs-horizontal {
  flex-direction: column;
}

.nut-tabs-vertical {
  flex-direction: row;
  width: 100%;

  .nut-tabs-titles {
    box-sizing: border-box;
    flex-direction: column;
    height: 100%;
    padding: 0;
    width: $tabs-vertical-titles-width;
    flex-shrink: 0;

    .nut-tabs-list {
      width: 100%;
      display: flex;
      flex-direction: column;
      flex-shrink: 0;
    }
  }

  .nut-tabs-titles-scrollable {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .nut-tabs-titles-item {
    height: $tabs-vertical-titles-item-height;
    flex: none;

    &-smile {
      width: 0;
      height: 0;
      overflow: hidden;
      transition: width 0.3s ease;
    }

    &-line {
      width: 0;
      height: 0;
      transform: translate(0, -50%);
      transition: height 0.3s ease;
    }

    &-active {
      background-color: $tabs-titles-item-active-background-color;

      .nut-tabs-titles-item-line {
        left: 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: -6px;
        bottom: -2%;
        left: auto;
        width: 40px;
        height: 20px;
        transform: rotate(320deg);
      }
    }

    &:first-child {
      margin: 0 $tabs-titles-gap;
    }
  }

  .nut-tabs-horizontal {
    .nut-tabs-titles {
      flex-direction: row;
      overflow-x: auto;
      overflow-y: hidden;
      height: $tabs-titles-height;

      .nut-tabs-list {
        width: 100%;
        display: flex;
        flex-direction: row;
        flex-shrink: 0;
      }
    }

    .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);
      }

      .nut-tabs-titles-item-smile {
        left: 50%;
        right: auto;
        bottom: -3px;
        transform: translate(-50%, 0) rotate(0deg);
      }
    }
  }

  .nut-tabs-content {
    flex-direction: column;
    height: 100%;

    &-wrap {
      flex: 1;
    }

    .nut-tabpane {
      height: 100%;
    }
  }

  .nut-tabs-horizontal {
    .nut-tabs-titles {
      display: flex;
      flex-direction: row;
      padding: 0 !important;
      width: 100%;

      .nut-tabs-titles-item {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1 0 auto;

        &-active {
          color: $color-primary;
          font-weight: $tabs-titles-item-active-font-weight;
          font-size: $tabs-titles-item-active-font-size;

          .nut-tabs-titles-item-line {
            content: ' ';
            width: $tabs-tab-line-width;
            height: $tabs-tab-line-height;
            background: $tabs-tab-line-color;
          }
        }
      }
    }
  }
}

.nut-tabs-content {
  &-wrap {
    overflow: hidden;
  }

  display: flex;
  box-sizing: border-box;
}
