@import 'mixins/mixins';
@import 'common/var';

@include b(tabs) {
  @include e(header) {
    padding: 0;
    position: relative;
  }
  @include e(active-bar) {
    position: absolute;
    bottom: 0;
    // 避免 border-box 影响位置
    box-sizing: content-box;
    left: -16px;
    padding: 0 16px;
    height: $--tab-active-bar;
    background-color: $--color-primary;
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    list-style: none;
    border-radius: $--border-radius-base $--border-radius-base 0px 0px;
  }
  @include e(new-tab) {
    position: relative;
    margin-left: 2px;
    z-index: 2;

    .el-icon-plus {
      display: inline-block;
      border: $--border-base;
      height: 16px;
      width: 16px;
      line-height: 16px;
      border-radius: $--border-radius-base;
      text-align: center;
      font-size: 12px;
      color: $--icon-color;
      cursor: pointer;
      transition: all 0.15s;
    }

    &:hover {
      color: $--color-primary;
    }
  }
  @include e(nav-wrap) {
    overflow: hidden;
    margin-bottom: -1px;
    position: relative;

    &::after {
      content: '';
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 1px;
      background-color: $--border-color-base;
      z-index: $--index-normal;
    }

    @include when(bottom) {
      margin-bottom: 0;
      margin-top: -1px;
    }

    @include when(scrollable) {
      box-sizing: border-box;
    }
  }
  @include e(nav-scroll) {
    overflow: hidden;
    flex: 1;
  }
  .el-tabs__nav-btn {
    text-align: right;
    display: table;
    & > * {
      display: table-cell;
      vertical-align: middle;
    }
  }
  .el-tabs__prepend {
    margin: 0 5px;
  }
  .el-tabs__prepend-btn {
    display: table;
    & > * {
      display: table-cell;
      vertical-align: middle;
    }
  }
  .el-tabs__nav-box{
    display: flex;
    position: relative;
    z-index: 2;
  }
  .el-tabs__append{
    display: table;
    & > * {
      display: table-cell;
    }
  }
  @include e((nav-next, nav-prev)) {
    i{
      display: inline-block;
      margin: 0 4px;
      border: $--border-base;
      height: 16px;
      width: 16px;
      line-height: 16px;
      text-align: center;
      font-size: 12px;
      color: $--icon-color;
      cursor: pointer;
      transition: all 0.15s;
      @include when(disabled) {
        cursor: not-allowed;
      }
    }
  }
  @include e(nav-next) {
    // margin: 0 4px;
  }
  @include e(nav-prev) {
    // left: 4px;
  }
  @include e(nav) {
    white-space: nowrap;
    position: relative;
    transition: transform 0.3s;
    float: left;
    z-index: #{$--index-normal + 1};

    @include when(stretch) {
      min-width: 100%;
      display: flex;
      & > * {
        flex: 1;
        text-align: center;
      }
    }
  }
  @include e(item) {
    padding: 0 16px;
    height: 34px;
    box-sizing: border-box;
    line-height: 34px;
    display: inline-block;
    list-style: none;
    font-size: 14px;
    font-weight: $--font-weight-primary;
    color: $--color-text-primary;
    position: relative;

    &:focus-visible{
      outline-offset: -2px;
      outline: 1px solid $--color-primary;
    }

    & .el-icon-close {
      padding: 1px;
      font-size: 12px;
      color: mix($--tag-info-color, $--color-white, 100%);
      border-radius: 50%;
      text-align: center;
      transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
      margin-left: 5px;
      &:before {
        transform: scale(0.9);
        display: inline-block;
      }

      &:hover {
        color: $--color-white;
        background-color: mix($--tag-info-color, $--color-white, 100%);
      }
    }

    @include when(active) {
      color: $--color-primary;
      font-weight: $--tab-active-weight;
    }

    &:hover {
      color: $--color-primary;
      cursor: pointer;
    }

    @include when(disabled) {
      color: $--disabled-color-base;
      cursor: default;
    }
  }
  @include e(content) {
    overflow: hidden;
    position: relative;
  }
  @include m(card) {
    > .el-tabs__header.is-top {
      border-bottom: $--border-base;
    }
    > .el-tabs__header.is-bottom {
      border-top: $--border-base;
    }
    > .el-tabs__header.is-left,
    > .el-tabs__header.is-right {
      border-bottom: none;
    }
    > .el-tabs__header .el-tabs__nav-wrap::after {
      content: none;
    }
    > .el-tabs__header .el-tabs__nav {
      border: $--border-base;
      border-bottom: none;
      border-radius: $--border-radius-base $--border-radius-base 0 0;
      box-sizing: border-box;
    }
    > .el-tabs__header .el-tabs__nav.is-top {
      border: $--border-base;
      border-bottom: none;
    }
    > .el-tabs__header .el-tabs__nav.is-bottom {
      border: $--border-base;
      border-top: none;
    }
    > .el-tabs__header .el-tabs__active-bar {
      display: none;
    }
    > .el-tabs__header .el-tabs__item .el-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%;
    }
    > .el-tabs__header .el-tabs__item {
      padding: 0 20px;
      border-bottom: 1px solid transparent;
      border-left: $--border-base;
      transition: color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1),
        padding 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
      &:first-child {
        border-left: none;
      }
      &.is-closable {
        &:hover {
          padding-left: 13px;
          padding-right: 13px;

          & .el-icon-close {
            width: 14px;
          }
        }
      }
      &.is-active {
        border-bottom-color: $--color-white;

        &.is-closable {
          padding-left: 20px;
          padding-right: 20px;

          .el-icon-close {
            width: 14px;
          }
        }
      }
      &.is-active.is-bottom {
        border-top: 1px solid $--color-white;
        border-bottom: none;
      }
    }
  }
  @include m(border-card) {
    background: $--color-white;
    border: $--border-base;
    box-shadow: $--box-shadow-dark;

    > .el-tabs__header {
      background-color: $--background-color-base;
      border-bottom: $--border-base;
      margin: 0;
    }
    > .el-tabs__header.is-left,
    > .el-tabs__header.is-right {
      border-bottom: none;
    }
    > .el-tabs__header .el-tabs__nav-wrap::after {
      content: none;
    }
    > .el-tabs__header .el-tabs__item {
      padding: 0 20px;
      transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
      border: 1px solid transparent;
      margin-top: -1px;
      color: $--color-text-primary;

      &:first-child {
        margin-left: -1px;
      }

      & + .el-tabs__item {
        margin-left: -1px;
      }

      &.is-active {
        color: $--color-primary;
        background-color: $--color-white;
        border-right-color: $--border-color-base;
        border-left-color: $--border-color-base;
      }
      &:not(.is-disabled):hover {
        color: $--color-primary;
      }
      &.is-disabled {
        color: $--disabled-color-base;
      }
    }

    //  去掉左右位置头部边线
    > .el-tabs__header .el-tabs__item.is-left:first-child.is-active,
    > .el-tabs__header .el-tabs__item.is-right:first-child.is-active {
      border-top-color: transparent;
    }
    > .el-tabs__header
      .is-scrollable
      .el-tabs__item.is-left:first-child.is-active,
    > .el-tabs__header
      .is-scrollable
      .el-tabs__item.is-right:first-child.is-active {
      border-top-color: $--border-color-base;
    }
    // > .el-tabs__header .el-tabs__item.is-left:last-child.is-active,
    // > .el-tabs__header .el-tabs__item.is-right:last-child.is-active {
    //   border-bottom-color: transparent;
    // }
    // > .el-tabs__header .is-scrollable .el-tabs__item.is-left:last-child.is-active,
    // > .el-tabs__header .is-scrollable .el-tabs__item.is-right:last-child.is-active {
    //   border-bottom-color:$--border-color-base;
    // }

    > .el-tabs__header
      .is-scrollable
      .el-tabs__item.is-top:first-child.is-active
      > .el-tabs__header
      .is-scrollable
      .el-tabs__item.is-bottom:first-child.is-active {
      border-top-color: $--border-color-base;
    }
    > .el-tabs__header .el-tabs__item.is-top:first-child.is-active,
    > .el-tabs__header .el-tabs__item.is-right:first-child.is-active {
      margin-left: -1px;
    }

    > .el-tabs__header .is-scrollable .el-tabs__item:first-child.is-active {
      margin-left: 0;
    }
    > .el-tabs__header .is-scrollable .el-tabs__item.is-left:first-child,
    > .el-tabs__header .is-scrollable .el-tabs__item.is-right:first-child {
      margin-top: 0;
    }
  }
  @include m((top, bottom)) {
    height: 100%;
    .el-tabs__header {
      display: flex;
      flex-direction: row;
    }
    .el-tabs__nav-wrap {
      flex: 1;
      display: flex;
      flex-direction: row;
    }
    .el-tabs__content {
      height: calc(100% - 34px);
    }
    .el-tab-pane {
      box-sizing: border-box;
      width: 100%;
      height: 100%;
      overflow: auto;
      padding: 10px;
    }
    // .el-tabs__item.is-top:last-child,
    // .el-tabs__item.is-bottom:last-child {
    //   padding-right: 0;
    // }

    .is-scrollable {
      .el-tabs__item.is-top:last-child,
      .el-tabs__item.is-bottom:last-child {
        padding-right: 16px;
      }
    }

    &.el-tabs--border-card,
    &.el-tabs--card,
    .el-tabs--left,
    .el-tabs--right {
      > .el-tabs__header {
        .el-tabs__item:nth-child(2) {
          padding-left: 20px;
        }
        .el-tabs__item:last-child {
          padding-right: 20px;
        }
      }
    }
    // .el-tabs__new-tab {
    //   top: 5px;
    // }
    .el-tabs__new-tab ~ .el-tabs__nav-wrap {
      margin-right: 30px;
    }
  }
  @include m(bottom) {
    // .el-tabs__header.is-bottom {
    // margin-bottom: 0;
    // margin-top: 10px;
    // }
    &.el-tabs--border-card {
      .el-tabs__header.is-bottom {
        border-bottom: 0;
        border-top: $--border-base;
        margin-top: 1px;
      }
      .el-tabs__nav-wrap.is-bottom {
        margin-top: -1px;
        margin-bottom: 0;
      }
      .el-tabs__item.is-bottom:not(.is-active) {
        border: 1px solid transparent;
      }
      .el-tabs__item.is-bottom {
        margin: 0 -1px -1px -1px;
      }
    }
  }
  @include m((left, right)) {
    overflow: hidden;

    .el-tabs__header.is-left,
    .el-tabs__header.is-right,
    .el-tabs__nav-wrap.is-left,
    .el-tabs__nav-wrap.is-right,
    .el-tabs__nav-scroll {
      height: 100%;
      display: flex;
      flex-direction: column;
    }

    @include e(content) {
      height: 100%;
      overflow: hidden;
      position: relative;
    }
    .el-tab-pane {
      box-sizing: border-box;
      width: 100%;
      height: 100%;
      overflow: auto;
      padding: 10px;
    }

    .el-tabs__active-bar.is-right {
      top: 0;
      bottom: auto;
      width: $--tab-active-bar;
      height: auto;
      padding: 0;
      border-radius: 0px $--border-radius-base $--border-radius-base 0px;
    }
    .el-tabs__active-bar.is-left {
      top: 0;
      bottom: auto;
      width: $--tab-active-bar;
      height: auto;
      padding: 0;
      border-radius: $--border-radius-base 0 0 $--border-radius-base;
    }

    .el-tabs__nav-wrap.is-left,
    .el-tabs__nav-wrap.is-right {
      margin-bottom: 0;
      .el-tabs__nav-btn {
        display: inline-block;
        margin: 0 2px;
        text-align: center;
        line-height: 1;
        .el-tabs__nav-prev,
        .el-tabs__nav-next {
          box-sizing: border-box;
          width: 100%;
          text-align: center;
          margin: 1px 0;
          cursor: pointer;
          i {
            transform: rotateZ(90deg);
          }
        }
      }

      &.is-scrollable {
        // padding: 30px 0;
        .el-tabs__nav-scroll {
          width: 100%;
          height: calc(100% - 34px);
        }
      }

      &::after {
        height: 100%;
        width: 1px;
        bottom: auto;
        top: 0;
      }
    }

    .el-tabs__nav.is-left,
    .el-tabs__nav.is-right {
      float: none;
    }
    .el-tabs__item.is-left,
    .el-tabs__item.is-right {
      display: block;
    }

    // .el-tabs__new-tab {
    //   bottom: 5px;
    // }
  }
  @include m(left) {
    .el-tabs__header.is-left {
      float: left;
      margin-bottom: 0;
      // margin-right: 10px;
      border-right: $--border-base;
    }
    .el-tabs__nav-wrap.is-left {
      margin-right: -1px;
      &::after {
        left: auto;
        right: 0;
      }
    }
    .el-tabs__active-bar.is-left {
      right: 0;
      left: auto;
    }
    .el-tabs__item.is-left {
      text-align: right;
    }

    &.el-tabs--card {
      .el-tabs__active-bar.is-left {
        display: none;
      }
      .el-tabs__item.is-left {
        border-left: none;
        border-right: $--border-base;
        border-bottom: none;
        border-top: $--border-base;
        text-align: left;
      }
      .el-tabs__item.is-left:first-child {
        border-right: $--border-base;
        border-top: none;
      }
      .el-tabs__item.is-left.is-active {
        border: $--border-base;
        border-right-color: $--color-white;
        border-left: none;
        border-bottom: none;

        &:first-child {
          border-top: none;
        }
        &:last-child {
          border-bottom: none;
        }
      }

      .el-tabs__nav {
        border-radius: $--border-radius-base 0 0 $--border-radius-base;
        border-bottom: $--border-base;
        border-right: none;
      }

      .el-tabs__new-tab {
        float: none;
      }
    }

    &.el-tabs--border-card {
      .el-tabs__header.is-left {
        border-right: $--border-base;
      }
      .el-tabs__item.is-left {
        border: 1px solid transparent;
        margin: 0;

        &.is-active {
          border-color: transparent;
          border-top-color: rgb(209, 219, 229);
          border-bottom-color: rgb(209, 219, 229);
        }
      }
    }
  }
  @include m(right) {
    .el-tabs__header.is-right {
      float: right;
      margin-bottom: 0;
      // margin-left: 10px;
      border-left: $--border-base;
    }

    .el-tabs__nav-wrap.is-right {
      margin-left: -1px;
      &::after {
        left: 0;
        right: auto;
      }
    }

    .el-tabs__active-bar.is-right {
      left: 0;
    }

    &.el-tabs--card {
      .el-tabs__active-bar.is-right {
        display: none;
      }
      .el-tabs__item.is-right {
        border-bottom: none;
        border-top: $--border-base;
      }
      .el-tabs__item.is-right:first-child {
        border-left: $--border-base;
        border-top: none;
      }
      .el-tabs__item.is-right.is-active {
        border: $--border-base;
        border-left-color: $--color-white;
        border-right: none;
        border-bottom: none;

        &:first-child {
          border-top: none;
        }
        &:last-child {
          border-bottom: none;
        }
      }

      .el-tabs__nav {
        border-radius: 0 $--border-radius-base $--border-radius-base 0;
        border-bottom: $--border-base;
        border-left: none;
      }
    }
    &.el-tabs--border-card {
      .el-tabs__header.is-right {
        border-left: $--border-base;
      }
      .el-tabs__item.is-right {
        border: 1px solid transparent;
        margin: 0;

        &.is-active {
          border-color: transparent;
          border-top-color: rgb(209, 219, 229);
          border-bottom-color: rgb(209, 219, 229);
        }
      }
    }
  }
  @include m(medium) {
    .el-tabs__item {
      height: 32px;
      line-height: 32px;
    }
    &.el-tabs--top,
    &.el-tabs--bottom {
      .el-tabs__content {
        height: calc(100% - 32px);
      }
    }
  }
  @include m(small) {
    .el-tabs__item {
      font-size: 12px;
      height: 30px;
      line-height: 30px;
    }
    .el-tabs__active-bar.is-right,
    .el-tabs__active-bar.is-left {
      width: 2px;
    }
    .el-tabs__active-bar.is-top,
    .el-tabs__active-bar.is-bottom {
      height: 2px;
    }
    &.el-tabs--top,
    &.el-tabs--bottom {
      .el-tabs__content {
        height: calc(100% - 30px);
      }
    }
  }
  @include m(mini) {
    .el-tabs__item {
      font-size: 12px;
      height: 28px;
      line-height: 28px;
    }
    .el-tabs__active-bar.is-right,
    .el-tabs__active-bar.is-left {
      width: 2px;
    }
    .el-tabs__active-bar.is-top,
    .el-tabs__active-bar.is-bottom {
      height: 2px;
    }
    &.el-tabs--top,
    &.el-tabs--bottom {
      .el-tabs__content {
        height: calc(100% - 28px);
      }
    }
  }
}

.slideInRight-transition,
.slideInLeft-transition {
  display: inline-block;
}
.slideInRight-enter {
  animation: slideInRight-enter 0.3s;
}
.slideInRight-leave {
  position: absolute;
  left: 0;
  right: 0;
  animation: slideInRight-leave 0.3s;
}
.slideInLeft-enter {
  animation: slideInLeft-enter 0.3s;
}
.slideInLeft-leave {
  position: absolute;
  left: 0;
  right: 0;
  animation: slideInLeft-leave 0.3s;
}

@keyframes slideInRight-enter {
  0% {
    opacity: 0;
    transform-origin: 0 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform-origin: 0 0;
    transform: translateX(0);
  }
}
@keyframes slideInRight-leave {
  0% {
    transform-origin: 0 0;
    transform: translateX(0);
    opacity: 1;
  }

  100% {
    transform-origin: 0 0;
    transform: translateX(100%);
    opacity: 0;
  }
}
@keyframes slideInLeft-enter {
  0% {
    opacity: 0;
    transform-origin: 0 0;
    transform: translateX(-100%);
  }

  to {
    opacity: 1;
    transform-origin: 0 0;
    transform: translateX(0);
  }
}
@keyframes slideInLeft-leave {
  0% {
    transform-origin: 0 0;
    transform: translateX(0);
    opacity: 1;
  }

  100% {
    transform-origin: 0 0;
    transform: translateX(-100%);
    opacity: 0;
  }
}
