@import './var.less';

:root {
  --rv-tab-text-color: @tab-text-color;
  --rv-tab-active-text-color: @tab-active-text-color;
  --rv-tab-disabled-text-color: @tab-disabled-text-color;
  --rv-tab-font-size: @tab-font-size;
  --rv-tab-line-height: @tab-line-height;
  --rv-tabs-default-color: @tabs-default-color;
  --rv-tabs-line-height: @tabs-line-height;
  --rv-tabs-card-height: @tabs-card-height;
  --rv-tabs-nav-background-color: @tabs-nav-background-color;
  --rv-tabs-bottom-bar-width: @tabs-bottom-bar-width;
  --rv-tabs-bottom-bar-height: @tabs-bottom-bar-height;
  --rv-tabs-bottom-bar-color: @tabs-bottom-bar-color;

  --rv-tab-capsule-padding: var(--rv-padding-xs) var(--rv-padding-sm);

  --rv-tabs-jumbo-height: @tabs-jumbo-height;
  --rv-tab-jumbo-title-size: var(--rv-font-size-lg);
  --rv-tab-description-font-size: var(--rv-font-size-sm);
  --rv-tab-description-color: @gray-6;
  --rv-tab-description-background-color: @gray-3;
}

.@{rv-prefix}-tab {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0 var(--rv-padding-base);
  color: var(--rv-tab-text-color);
  font-size: var(--rv-tab-font-size);
  line-height: var(--rv-tab-line-height);
  cursor: pointer;

  &__pane {
    height: 100%;
    &,
    &-wrapper {
      flex-shrink: 0;
      box-sizing: border-box;
      width: 100%;
    }

    &-wrapper--inactive {
      height: 0;
      overflow: visible;
    }
  }

  &--active {
    color: var(--rv-tab-active-text-color);
    font-weight: var(--rv-font-weight-bold);
  }

  &--disabled {
    color: var(--rv-tab-disabled-text-color);
    cursor: not-allowed;
  }

  &__text {
    &--ellipsis {
      display: -webkit-box;
      overflow: hidden;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
    }
  }
  &__description {
    padding: 2px var(--rv-padding-xs);
    border-radius: 10px;
    color: var(--rv-tab-description-color);
    font-size: var(--rv-tab-description-font-size);
    line-height: var(--rv-tab-description-font-size);
    background-color: var(--rv-tab-description-background-color);
    font-weight: normal;
  }
}

.@{rv-prefix}-tabs {
  position: relative;

  &__wrap {
    overflow: hidden;

    &--page-top {
      position: fixed;
    }

    &--content-bottom {
      top: auto;
      bottom: 0;
    }

    &--scrollable {
      .@{rv-prefix}-tab {
        flex: 1 0 auto;
        padding: 0 var(--rv-padding-sm);
      }

      .@{rv-prefix}-tabs__nav {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;

        &::-webkit-scrollbar {
          display: none;
        }
      }
    }
  }

  &__nav {
    position: relative;
    display: flex;
    background-color: var(--rv-tabs-nav-background-color);
    user-select: none;

    &--line,
    &--capsule,
    &--jumbo {
      box-sizing: content-box;
      height: 100%;
      padding-bottom: 15px; /* 15px padding to hide scrollbar in mobile safari */
    }

    &--line&--complete {
      padding-right: var(--rv-padding-xs);
      padding-left: var(--rv-padding-xs);
    }

    &--start {
      .@{rv-prefix}-tab {
        flex: none;
        padding: 0 var(--rv-padding-sm);
      }
    }

    &--card {
      box-sizing: border-box;
      height: var(--rv-tabs-card-height);
      margin: 0 var(--rv-padding-md);
      border: var(--rv-border-width-base) solid var(--rv-tabs-default-color);
      border-radius: var(--rv-border-radius-sm);

      .@{rv-prefix}-tab {
        color: var(--rv-tabs-default-color);
        border-right: var(--rv-border-width-base) solid
          var(--rv-tabs-default-color);

        &:last-child {
          border-right: none;
        }

        &.@{rv-prefix}-tab--active {
          color: var(--rv-white);
          background-color: var(--rv-tabs-default-color);
        }

        &--disabled {
          color: var(--rv-tab-disabled-text-color);
        }
      }
    }
    &--capsule {
      .@{rv-prefix}-tab {
        padding: var(--rv-tab-capsule-padding);
        &__text {
          width: 100%;
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
        }

        &.@{rv-prefix}-tab--active {
          color: var(--rv-white);

          .@{rv-prefix}-tab__text {
            border-radius: 22px;
            background-color: var(--rv-tabs-bottom-bar-color);
          }
        }
      }
    }
    &--jumbo {
      .@{rv-prefix}-tab {
        flex-direction: column;
        align-items: center;

        &__text {
          font-size: var(--rv-tab-jumbo-title-size);
          line-height: 1.6em;
        }

        &--active {
          .@{rv-prefix}-tab__description {
            color: var(--rv-white);
            background-color: var(--rv-tab-active-text-color);
          }
        }
      }
    }
  }

  &__line {
    position: absolute;
    bottom: 15px;
    left: 0;
    z-index: 1;
    width: var(--rv-tabs-bottom-bar-width);
    height: var(--rv-tabs-bottom-bar-height);
    background-color: var(--rv-tabs-bottom-bar-color);
    border-radius: var(--rv-tabs-bottom-bar-height);
  }

  &__track {
    position: relative;
    display: flex;
    width: 100%;
    height: 100%;
    will-change: left;
  }

  &__content {
    &--animated {
      overflow: hidden;
    }
  }

  &--line,
  &--capsule {
    .@{rv-prefix}-tabs__wrap {
      height: var(--rv-tabs-line-height);
    }
  }

  &--card {
    > .@{rv-prefix}-tabs__wrap {
      height: var(--rv-tabs-card-height);
    }
  }

  &--jumbo {
    .@{rv-prefix}-tabs__wrap {
      height: var(--rv-tabs-jumbo-height);
    }
    .@{rv-prefix}-badge__wrapper {
      display: flex;
      align-items: center;
      flex-direction: column;
    }
  }
}
