@import "mixins/mixins";
@import "common/var";


@include b(tabs) {
  @include e(header) {
    padding: 0;
    position: relative;
    margin: 0 0 15px;
  }

  @include e(active-bar) {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background-color: $tabs-bg-color;
    z-index: 1;
    transition: transform .15s cubic-bezier(.75,0,.25,1);
    list-style: none;
  }

  @include e(new-tab) {
    float: right;
    border: 1px solid #d3dce6;
    height: 18px;
    width: 18px;
    line-height: 18px;
    margin: 12px 0 9px 10px;
    border-radius: 3px;
    text-align: center;
    font-size: 12px;
    color: #d3dce6;
    cursor: pointer;
    transition: all .15s;

    .#{$namespace}-icon-add {
      transform: scale(0.8, 0.8);
    }

    &:hover {
      color: $tabs-bg-color;
    }
  }

  @include e(nav-wrap) {
    overflow: hidden;
    margin-bottom: -1px;
    position: relative;

    &::after {
      content: "";
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 2px;
      background-color: $border-color;
      z-index: $z-index-normal;
    }

    @include pf(scrollable) {
      padding: 0 20px;
      box-sizing: border-box;
    }
  }

  @include e(nav-scroll) {
    overflow: hidden;
  }

  @include e((nav-next, nav-prev)) {
    position: absolute;
    cursor: pointer;
    line-height: 44px;
    font-size: 12px;
    color: $text-color-gradual-3;
  }
  @include e(nav-next) {
    right: 0;
  }
  @include e(nav-prev) {
    left: 0;
  }
  @include e(nav) {
    white-space: nowrap;
    position: relative;
    transition: transform .3s;
    float: left;
    z-index: #{$z-index-normal+1};

    @include pf(stretch){
      min-width: 100%;
      display: flex;
      & > * {
        flex: 1;
        text-align: center;
      }
    }
  }

  @include e(item){
    padding: 0 20px;
    height: $tabs-height;
    box-sizing: border-box;
    line-height: $tabs-height;
    display: inline-block;
    list-style: none;
    font-size: 14px;
    font-weight: 500;
    color: $text-color-gradual-1;
    position: relative;
    &:focus, &:focus:active{
      outline: none;
    }

    & .#{$namespace}-icon-close{
      border-radius: 50%;
      text-align: center;
      transition: all .3s cubic-bezier(.75,0,.25,1);
      margin-left: 5px;
      &:before{
        transform: scale(.9);
        display: inline-block;
      }

      &:hover{
        background-color: $text-color-gradual-5;
        color: $color-white;
      }
    }

    @include pf(active){
      color: $tabs-bg-color;
    }

    &:hover{
      color: $tabs-bg-color;
      cursor: pointer;
    }

    @include pf(disabled){
      color: $disabled-color;
      cursor: not-allowed;
    }
  }

  @include e(content){
    overflow: hidden;
    position: relative;
  }

  @include mf(card){
    > .#{$namespace}-tabs_header {
      border-bottom: 1px solid $border-color;
    }
    > .#{$namespace}-tabs_header .#{$namespace}-tabs_nav-wrap::after {
      content: none;
    }
    > .#{$namespace}-tabs_header .#{$namespace}-tabs_nav {
      border: 1px solid $border-color;
      border-bottom: none;
      border-radius: 4px 4px 0 0;
      box-sizing: border-box;
    }
    > .#{$namespace}-tabs_header .#{$namespace}-tabs_active-bar {
      display: none;
    }
    > .#{$namespace}-tabs_header .#{$namespace}-tabs_item .#{$namespace}-icon-close {
      position: relative;
      font-size: 12px;
      width: 0;
      height: 14px;
      vertical-align: middle;
      line-height: 15px;
      overflow: hidden;
      top: -1px;
      right: -2px;
      transform-origin: 100% 50%;
    }
    > .#{$namespace}-tabs_header .#{$namespace}-tabs_item {
      border-bottom: 1px solid transparent;
      border-left: 1px solid $border-color;
      transition: color .15s cubic-bezier(.75,0,.25,1), padding .15s cubic-bezier(.75,0,.25,1);
      &:first-child {
        border-left: none;
      }
      &.ro-closable {
        &:hover {
          padding-left: 13px;
          padding-right: 13px;

          & .#{$namespace}-icon-close {
            width: 14px;
          }
        }
      }
      &.ro-active {
        border-bottom-color: $color-white;

        &.ro-closable {
          padding-left: 20px;
          padding-right: 20px;

          .#{$namespace}-icon-close {
            width: 14px;
          }
        }
      }
    }
  }
  @include mf(border-card) {
    background: $color-white;
    border: 1px solid $border-color;
    box-shadow: 0 2px 4px 0 rgba(0,0,0,0.12), 0 0 6px 0 rgba(0,0,0,0.04);

    > .#{$namespace}-tabs_content {
      padding: 15px;
    }
    > .#{$namespace}-tabs_header {
      background-color: $bg-color;
      border-bottom: 1px solid $border-color;
      margin: 0;
    }
    > .#{$namespace}-tabs_header .#{$namespace}-tabs_nav-wrap::after {
      content: none;
    }
    > .#{$namespace}-tabs_header .#{$namespace}-tabs_item {
      transition: all .15s cubic-bezier(.75,0,.25,1);
      border: 1px solid transparent;
      margin-top: -1px;
      color: $text-color-gradual-3;

      &:first-child {
        margin-left: -1px;
      }

      & + .#{$namespace}-tabs_item {
        margin-left: -1px;
      }

      &.ro-active {
        color: $tabs-bg-color;
        background-color: $color-white;
        border-right-color: $border-color;
        border-left-color: $border-color;
      }
      &:not(.ro-disabled):hover {
        color: $tabs-bg-color;
      }
      &.ro-disabled {
        color: $disabled-color;
      }
    }

    > .#{$namespace}-tabs_header .ro-scrollable .#{$namespace}-tabs_item:first-child {
      margin-left: 0;
    }
  }
  @include mf((top, bottom)) {
    .#{$namespace}-tabs_item.ro-top:nth-child(2),
    .#{$namespace}-tabs_item.ro-bottom:nth-child(2) {
      padding-left: 0;
    }
    .#{$namespace}-tabs_item.ro-top:last-child,
    .#{$namespace}-tabs_item.ro-bottom:last-child {
      padding-right: 0;
    }

    &.#{$namespace}-tabs-border-card, &.#{$namespace}-tabs-card,
    .#{$namespace}-tabs-left, .#{$namespace}-tabs-right {
      > .#{$namespace}-tabs_header {
        .#{$namespace}-tabs_item:nth-child(2) {
          padding-left: 20px;
        }
        .#{$namespace}-tabs_item:last-child {
          padding-right: 20px;
        }
      }
    }
  }
  @include mf(bottom) {
    .#{$namespace}-tabs_header.ro-bottom {
      margin-bottom: 0;
      margin-top: 10px;
    }
    &.#{$namespace}-tabs-border-card {
      .#{$namespace}-tabs_header.ro-bottom {
        border-bottom: 0;
        border-top: 1px solid $border-color;
      }
      .#{$namespace}-tabs_nav-wrap.ro-bottom {
        margin-top: -1px;
        margin-bottom: 0;
      }
      .#{$namespace}-tabs_item.ro-bottom:not(.ro-active) {
        border: 1px solid transparent;
      }
      .#{$namespace}-tabs_item.ro-bottom {
        margin: 0 -1px -1px -1px;
      }
    }
  }
  @include mf((left, right)) {
    overflow: hidden;

    .#{$namespace}-tabs_header.ro-left,
    .#{$namespace}-tabs_header.ro-right,
    .#{$namespace}-tabs_nav-wrap.ro-left,
    .#{$namespace}-tabs_nav-wrap.ro-right,
    .#{$namespace}-tabs_nav-scroll {
      height: 100%;
    }

    .#{$namespace}-tabs_active-bar.ro-left,
    .#{$namespace}-tabs_active-bar.ro-right {
      top: 0;
      bottom: auto;
      width: 2px;
      height: auto;
    }

    .#{$namespace}-tabs_nav-wrap.ro-left,
    .#{$namespace}-tabs_nav-wrap.ro-right {
      margin-bottom: 0;

      > .#{$namespace}-tabs_nav-prev,
      > .#{$namespace}-tabs_nav-next {
        height: 30px;
        line-height: 30px;
        width: 100%;
        text-align: center;
        cursor: pointer;

        i {
          transform: rotateZ(90deg);
        }
      }
      > .#{$namespace}-tabs_nav-prev {
        left: auto;
        top: 0;
      }
      > .#{$namespace}-tabs_nav-next {
        right: auto;
        bottom: 0;
      }

      &.ro-scrollable {
        padding: 30px 0;
      }

      &::after {
        height: 100%;
        width: 2px;
        bottom: auto;
        top: 0;
      }
    }

    .#{$namespace}-tabs_nav.ro-left,
    .#{$namespace}-tabs_nav.ro-right {
      float: none;
    }
    .#{$namespace}-tabs_item.ro-left,
    .#{$namespace}-tabs_item.ro-right {
      display: block;
    }
  }

  @include mf(left) {
    .#{$namespace}-tabs_header.ro-left {
      float: left;
      margin-bottom: 0;
      margin-right: 10px;
    }
    .#{$namespace}-tabs_nav-wrap.ro-left {
      margin-right: -1px;
      &::after {
        left: auto;
        right: 0;
      }
    }
    .#{$namespace}-tabs_active-bar.ro-left {
      right: 0;
      left: auto;
    }
    .#{$namespace}-tabs_item.ro-left {
      text-align: right;
    }

    &.#{$namespace}-tabs-card {
      .#{$namespace}-tabs_active-bar.ro-left {
        display: none;
      }
      .#{$namespace}-tabs_item.ro-left {
        border-left: none;
        border-right: 1px solid $border-color;
        border-bottom: none;
        border-top: 1px solid $border-color;
        text-align: left;
      }
      .#{$namespace}-tabs_item.ro-left:first-child {
        border-right: 1px solid $border-color;
        border-top: none;
      }
      .#{$namespace}-tabs_item.ro-left.ro-active {
        border: 1px solid $border-color;
        border-right-color: #fff;
        border-left: none;
        border-bottom: none;

        &:first-child {
          border-top: none;
        }
        &:last-child {
          border-bottom: none;
        }
      }

      .#{$namespace}-tabs_nav {
        border-radius: 4px 0 0 4px;
        border-bottom: 1px solid $border-color;
        border-right: none;
      }

      .#{$namespace}-tabs_new-tab {
        float: none;
      }
    }

    &.#{$namespace}-tabs-border-card {
      .#{$namespace}-tabs_header.ro-left {
        border-right: 1px solid #dfe4ed;
      }
      .#{$namespace}-tabs_item.ro-left {
        border: 1px solid transparent;
        margin: -1px 0 -1px -1px;

        &.ro-active {
          border-color: transparent;
          border-top-color: rgb(209, 219, 229);
          border-bottom-color: rgb(209, 219, 229);
        }
      }
    }
  }
  @include mf(right) {
    .#{$namespace}-tabs_header.ro-right {
      float: right;
      margin-bottom: 0;
      margin-left: 10px;
    }

    .#{$namespace}-tabs_nav-wrap.ro-right {
      margin-left: -1px;
      &::after {
        left: 0;
        right: auto;
      }
    }

    .#{$namespace}-tabs_active-bar.ro-right {
      left: 0;
    }

    &.#{$namespace}-tabs-card {
      .#{$namespace}-tabs_active-bar.ro-right {
        display: none;
      }
      .#{$namespace}-tabs_item.ro-right {
        border-bottom: none;
        border-top: 1px solid $border-color;
      }
      .#{$namespace}-tabs_item.ro-right:first-child {
        border-left: 1px solid $border-color;
        border-top: none;
      }
      .#{$namespace}-tabs_item.ro-right.ro-active {
        border: 1px solid $border-color;
        border-left-color: #fff;
        border-right: none;
        border-bottom: none;

        &:first-child {
          border-top: none;
        }
        &:last-child {
          border-bottom: none;
        }
      }

      .#{$namespace}-tabs_nav {
        border-radius: 0 4px 4px 0;
        border-bottom: 1px solid $border-color;
        border-left: none;
      }
    }
    &.#{$namespace}-tabs-border-card {
      .#{$namespace}-tabs_header.ro-right {
        border-left: 1px solid #dfe4ed;
      }
      .#{$namespace}-tabs_item.ro-right {
        border: 1px solid transparent;
        margin: -1px -1px -1px 0;

        &ro-active {
          border-color: transparent;
          border-top-color: rgb(209, 219, 229);
          border-bottom-color: rgb(209, 219, 229);
        }
      }
    }
  }
}

.slideInRight-transition,
.slideInLeft-transition {
  display: inline-block;
}
.slideInRight-enter {
  animation: slideInRight-enter .15s;
}
.slideInRight-leave {
  position: absolute;
  left: 0;
  right: 0;
  animation: slideInRight-leave .15s;
}
.slideInLeft-enter {
  animation: slideInLeft-enter .15s;
}
.slideInLeft-leave {
  position: absolute;
  left: 0;
  right: 0;
  animation: slideInLeft-leave .15s;
}
@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
  }
}
