@import url(../var.less);

@tabs-prefix: ~"@{prefix}tabs";

.@{tabs-prefix}{
  &__header {
    padding: 0;
    position: relative;
    margin: 0 0 16px;
  }

  &__expand {
    display: flex;
    align-items: center;
    margin: 0 0 16px;
    position: relative;

    .w-tabs__header  {
      overflow: hidden;
      margin-bottom: 0;
      flex: 1;
    }
    &::after {
      content: "";
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 2px;
      background-color: @border-lighter-color;
      z-index: @z-index-normal + 1;
    }
    .w-tabs__active-bar {
      bottom: 1px;
    }

    &--front {
      flex-shrink: 0;
    }

    &--end {
      flex-shrink: 0;
    }

    .w-tabs__nav {
      z-index: @z-index-normal + 2;
    }

  }
  &__active-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background-color: @tabs-active-bar-background-color;
    z-index: 1;
    transition: transform .3s cubic-bezier(.645,.045,.355,1);
    list-style: none;
  }

  &__new-tab {
    float: right;
    border: @tabs-new-tab-border;
    height: 18px;
    width: 18px;
    line-height: 16px;
    margin: 12px 0 9px 10px;
    border-radius: 3px;
    text-align: center;
    font-size: 12px;
    color: @tabs-new-tab-color;
    cursor: pointer;
    transition: all .15s;

    .w-icon-plus {
      transform: scale(0.8, 0.8);
    }

    &:hover {
      color: @primary-color;
    }
  }

  &__nav-wrap {
    overflow: hidden;
    margin-bottom: -1px;
    position: relative;

    &::after {
      content: "";
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 2px;
      background-color: @border-lighter-color;
      z-index: @z-index-normal;
    }

    &.is-scrollable {
      padding: 0 20px;
      box-sizing: border-box;
    }
  }

  &__nav-scroll {
    overflow: hidden;
  }

  &__nav-next, &__nav-prev {
    position: absolute;
    cursor: pointer;
    line-height: @tabs-item-height;
    font-size: @tabs-item-font-size;
    color: @secondary-text-color;
  }

  &__nav-next {
    right: 0;
  }

  &__nav-prev {
    left: 0;
  }

  &__nav {
    white-space: nowrap;
    position: relative;
    transition: transform .3s;
    float: left;
    z-index: @z-index-normal + 1;

    &.is-stretch {
      min-width: 100%;
      display: flex;
      & > * {
        flex: 1;
        text-align: center;
      }
    }
  }

  &__item {
    padding: @tabs-item-padding;
    height: @tabs-item-height;
    box-sizing: border-box;
    line-height: @tabs-item-height;
    display: inline-block;
    list-style: none;
    font-size: @tabs-item-font-size;
    font-weight: @tabs-item-font-weight;
    color: @tabs-item-font-color;
    position: relative;

    &:focus, &:focus:active {
      outline: none;
    }

    &:focus.is-active.is-focus:not(:active) {
      box-shadow: 0 0 2px 2px @primary-color inset;
      border-radius: 3px;
    }

    & .w-icon-close {
      border-radius: 50%;
      text-align: center;
      transition: all .3s cubic-bezier(.645,.045,.355,1);
      margin-left: 5px;
      
      &:before {
        transform: scale(.9);
        display: inline-block;
      }

      &:hover {
        background-color: @primary-color;
        color: @color-white;
      }
    }

    &.is-active {
      color: @primary-color;
    }

    &:hover {
      color: @primary-color;
      cursor: pointer;
    }

    &.is-disabled {
      color: @disabled-font-color;
      cursor: default;
    }
  }

  &__content {
    overflow: hidden;
    position: relative;
  }

  &--card {
    > .w-tabs__header {
      border-bottom: 1px solid @border-lighter-color;
    }
    > .w-tabs__header .w-tabs__nav-wrap::after {
      content: none;
    }
    > .w-tabs__header .w-tabs__nav {
      box-sizing: border-box;
    }
    > .w-tabs__header .w-tabs__active-bar {
      display: none;
    }
    > .w-tabs__header .w-tabs__item .w-icon-close {
      position: relative;
      font-size: 14px;
      width: 0;
      height: 14px;
      vertical-align: middle;
      line-height: 15px;
      overflow: hidden;
      top: -1px;
      right: -2px;
      transform-origin: 100% 50%;
    }
    > .w-tabs__header .w-tabs__item {
      border: @tabs-card-item-border;
      background-color: @tabs-card-item-background;
      border-radius: 2px 2px 0px 0px;
      border-bottom: 1px solid transparent;
      margin-left: 8px;
      transition: color .3s cubic-bezier(.645,.045,.355,1), padding .3s cubic-bezier(.645,.045,.355,1);
      &.is-closable {
        &:hover {
          padding-left: 13px;
          padding-right: 13px;

          & .w-icon-close {
            width: 14px;
          }
        }
      }
      &.is-active {
        border-bottom-color: @color-white;
        background-color: transparent;

        &.is-closable {
          padding-left: 20px;
          padding-right: 20px;

          .w-icon-close {
            width: 14px;
          }
        }
      }
    }
  }

  &--border-card {
    background: @tabs-border-card-background;
    border: @tabs-border-card-border;
    box-shadow: 0 2px 4px 0 rgba(0,0,0,0.12), 0 0 6px 0 rgba(0,0,0,0.04);

    > .w-tabs__content {
      padding: 15px;
    }
    > .w-tabs__header {
      background-color: @background-color-base;
      border-bottom: 1px solid @border-lighter-color;
      margin: 0;
    }
    > .w-tabs__header .w-tabs__nav-wrap::after {
      content: none;
    }
    > .w-tabs__header .w-tabs__item {
      transition: all .3s cubic-bezier(.645,.045,.355,1);
      border: 1px solid transparent;
      margin-top: -1px;

      &:first-child {
        margin-left: -1px;
      }

      & + .w-tabs__item {
        margin-left: -1px;
      }

      &.is-active {
        color: @primary-color;
        background-color: @color-white;
        border-right-color: @border-base-color;
        border-left-color: @border-base-color;
      }
      &:not(.is-disabled):hover {
        color: @primary-color;
      }
      &.is-disabled {
        color: @disabled-font-color;
      }
    }

    > .w-tabs__header .is-scrollable .w-tabs__item:first-child {
      margin-left: 0;
    }
  }

  &--top, &--bottom {
    // .w-tabs__item.is-top:nth-child(2),
    // .w-tabs__item.is-bottom:nth-child(2) {
    //   padding-left: 0;
    // }
    // .w-tabs__item.is-top:last-child,
    // .w-tabs__item.is-bottom:last-child {
    //   padding-right: 0;
    // }

    // &.w-tabs--border-card, &.w-tabs--card,
    // .w-tabs--left, .w-tabs--right {
    //   > .w-tabs__header {
    //     .w-tabs__item:nth-child(2) {
    //       padding-left: 20px;
    //     }
    //     .w-tabs__item:last-child {
    //       padding-right: 20px;
    //     }
    //   }
    // }
  }

  &--bottom {
    w-tabs__header.is-bottom {
      margin-bottom: 0;
      margin-top: 10px;
    }
    &.w-tabs--border-card {
      .w-tabs__header.is-bottom {
        border-bottom: 0;
        border-top: 1px solid @border-base-color;
      }
      .w-tabs__nav-wrap.is-bottom {
        margin-top: -1px;
        margin-bottom: 0;
      }
      .w-tabs__item.is-bottom:not(.is-active) {
        border: 1px solid transparent;
      }
      .w-tabs__item.is-bottom {
        margin: 0 -1px -1px -1px;
      }
    }
  }

  &--left, &--right {
    overflow: hidden;

    .w-tabs__header.is-left,
    .w-tabs__header.is-right,
    .w-tabs__nav-wrap.is-left,
    .w-tabs__nav-wrap.is-right,
    .w-tabs__nav-scroll {
      height: 100%;
    }

    .w-tabs__active-bar.is-left,
    .w-tabs__active-bar.is-right {
      top: 0;
      bottom: auto;
      width: 2px;
      height: auto;
    }

    .w-tabs__nav-wrap.is-left,
    .w-tabs__nav-wrap.is-right {
      margin-bottom: 0;

      > .w-tabs__nav-prev,
      > .w-tabs__nav-next {
        height: 30px;
        line-height: 30px;
        width: 100%;
        text-align: center;
        cursor: pointer;

        i {
          transform: rotateZ(90deg);
        }
      }
      > .w-tabs__nav-prev {
        left: auto;
        top: 0;
      }
      > .w-tabs__nav-next {
        right: auto;
        bottom: 0;
      }

      &.is-scrollable {
        padding: 30px 0;
      }

      &::after {
        height: 100%;
        width: 2px;
        bottom: auto;
        top: 0;
      }
    }

    .w-tabs__nav.is-left,
    .w-tabs__nav.is-right {
      float: none;
    }
    .w-tabs__item.is-left,
    .w-tabs__item.is-right {
      display: block;
    }
  }

  &--left {
    .w-tabs__header.is-left {
      float: left;
      margin-bottom: 0;
      margin-right: 10px;
    }
    .w-tabs__nav-wrap.is-left {
      margin-right: -1px;
      &::after {
        left: auto;
        right: 0;
      }
    }
    .w-tabs__active-bar.is-left {
      right: 0;
      left: auto;
    }
    .w-tabs__item.is-left {
      text-align: right;
    }

    &.w-tabs--card {
      .w-tabs__active-bar.is-left {
        display: none;
      }
      .w-tabs__item.is-left {
        border-left: none;
        border-right: 1px solid @border-lighter-color;
        border-bottom: none;
        border-top: 1px solid @border-lighter-color;
        text-align: left;
      }
      .w-tabs__item.is-left:first-child {
        border-right: 1px solid @border-lighter-color;
        border-top: none;
      }
      .w-tabs__item.is-left.is-active {
        border: 1px solid @border-lighter-color;
        border-right-color: #fff;
        border-left: none;
        border-bottom: none;

        &:first-child {
          border-top: none;
        }
        &:last-child {
          border-bottom: none;
        }
      }

      .w-tabs__nav {
        border-radius: 4px 0 0 4px;
        border-bottom: 1px solid @border-lighter-color;
        border-right: none;
      }

      .w-tabs__new-tab {
        float: none;
      }
    }

    &.w-tabs--border-card {
      .w-tabs__header.is-left {
        border-right: 1px solid #dfe4ed;
      }
      .w-tabs__item.is-left {
        border: 1px solid transparent;
        margin: -1px 0 -1px -1px;

        &.is-active {
          border-color: transparent;
          border-top-color: rgb(209, 219, 229);
          border-bottom-color: rgb(209, 219, 229);
        }
      }
    }
  }

  &--right {
    .w-tabs__header.is-right {
      float: right;
      margin-bottom: 0;
      margin-left: 10px;
    }

    .w-tabs__nav-wrap.is-right {
      margin-left: -1px;
      &::after {
        left: 0;
        right: auto;
      }
    }

    .w-tabs__active-bar.is-right {
      left: 0;
    }

    &.w-tabs--card {
      .w-tabs__active-bar.is-right {
        display: none;
      }
      .w-tabs__item.is-right {
        border-bottom: none;
        border-top: 1px solid @border-lighter-color;
      }
      .w-tabs__item.is-right:first-child {
        border-left: 1px solid @border-lighter-color;
        border-top: none;
      }
      .w-tabs__item.is-right.is-active {
        border: 1px solid @border-lighter-color;
        border-left-color: #fff;
        border-right: none;
        border-bottom: none;

        &:first-child {
          border-top: none;
        }
        &:last-child {
          border-bottom: none;
        }
      }

      .w-tabs__nav {
        border-radius: 0 4px 4px 0;
        border-bottom: 1px solid @border-lighter-color;
        border-left: none;
      }
    }
    &.w-tabs--border-card {
      .w-tabs__header.is-right {
        border-left: 1px solid #dfe4ed;
      }
      .w-tabs__item.is-right {
        border: 1px solid transparent;
        margin: -1px -1px -1px 0;

        &.is-active {
          border-color: transparent;
          border-top-color: rgb(209, 219, 229);
          border-bottom-color: rgb(209, 219, 229);
        }
      }
    }
  }

  &--center {
    .w-tabs__nav-scroll {
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .is-scrollable {
      .w-tabs__nav-scroll {
        display: block;
      }
    }
  }

  &--medium {
    .w-tabs__item {
      height: @tabs-medium-item-height;
      line-height: @tabs-medium-item-height;
      padding: @tabs-medium-item-padding;
      font-size: @tabs-medium-item-font-size;
    }
  }

  &--small {
    .w-tabs__item {
      height: @tabs-small-item-height;
      line-height: @tabs-small-item-height;
      padding: @tabs-small-item-padding;
      font-size: @tabs-small-item-font-size;
    }
  }
  
}

.slideInRight-transition,
.slideInLeft-transition {
  display: inline-block;
}
.slideInRight-enter {
  animation: slideInRight-enter .3s;
}
.slideInRight-leave {
  position: absolute;
  left: 0;
  right: 0;
  animation: slideInRight-leave .3s;
}
.slideInLeft-enter {
  animation: slideInLeft-enter .3s;
}
.slideInLeft-leave {
  position: absolute;
  left: 0;
  right: 0;
  animation: slideInLeft-leave .3s;
}

@keyframes slideInRight-enter {
  0% {
    opacity: 0;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: translateX(100%);
    transform: translateX(100%)
  }

  to {
    opacity: 1;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: translateX(0);
    transform: translateX(0)
  }
}
@keyframes slideInRight-leave {
  0% {
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: translateX(0);
    transform: translateX(0);
    opacity: 1
  }

  100% {
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: translateX(100%);
    transform: translateX(100%);
    opacity: 0
  }
}
@keyframes slideInLeft-enter {
  0% {
    opacity: 0;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%)
  }

  to {
    opacity: 1;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: translateX(0);
    transform: translateX(0)
  }
}
@keyframes slideInLeft-leave {
  0% {
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: translateX(0);
    transform: translateX(0);
    opacity: 1
  }

  100% {
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%);
    opacity: 0
  }
}