@import './../theme/vars.scss';
@import './../mixins/reset.scss';

$tabsPrefixCls: #{$vender-prefix}-tabs;

// $tabsColor: $primary-color;
$tabsColor: var(--primary-color);

.#{$tabsPrefixCls} {
  @include reset-component2;

  font-size: $font-size-lg;

  &-list {
    padding: 0 2em;
    margin: 0;
    list-style: none;
    border-bottom: 1px solid $border-color-split;
  }

  &-tabitem {
    display: inline-block;
    cursor: pointer;

    &-inner {
      display: block;
      padding: 0.6em 1em;
      color: $tab-color;
      border: 0;
      border-radius: 2px 2px 0 0;

      .#{$tabsPrefixCls}-tabitem-emove {
        margin-left: 0.5em;
        font-size: 12px;
      }

      &:hover {
        color: white;
        background: $primary-color-deep;
      }
    }

    &-active {
      .#{$tabsPrefixCls}-tabitem-inner {
        color: white;
        background: $tabsColor;
        border: 0;

        &:focus,
        &:hover {
          color: white;
          background: $tabsColor;
          border: 0;
        }
      }
    }
  }

  &-panel {
    display: none;
    padding-top: 10px;
    opacity: 0;

    &.#{$tabsPrefixCls}-panel-active {
      opacity: 1;
    }

    &.animate-enable {
      opacity: 0.6;
      // transform: scale(0.99);

      &.#{$tabsPrefixCls}-panel-active {
        opacity: 1;
        // transform: scale(1);
        transition: all $animation-duration-slow;
      }
    }
  }

  &-dynamic {
    .#{$tabsPrefixCls}-list {
      padding: 0;
      background: $tab-list-bg-color;
      border-bottom-color: $tab-list-border-color;
    }

    .#{$tabsPrefixCls}-tabitem {
      &-inner {
        padding: 0.5em 0.5em 0.5em 0;

        &:hover {
          color: $tab-hover-color;
          background: $tab-hover-bg-color;
        }
      }
    }

    .#{$tabsPrefixCls}-tabitem-active {
      .#{$tabsPrefixCls}-tabitem-inner {
        color: $tab-hover-color;
        background: $tab-hover-bg-color;

        &:focus,
        &:hover {
          color: $tab-hover-color;
          background: $tab-hover-bg-color;
        }
      }
    }

    .#{$tabsPrefixCls}-tabitem-content {
      display: inline-block;
      padding: 0.4em;
      vertical-align: middle;
    }

    // 针对 dynamic top 和 bottom 处理 boder
    &.#{$tabsPrefixCls}-bottom {
      .#{$tabsPrefixCls}-tabitem {
        &-inner {
          border-top: 3px solid transparent;

          &:hover {
            border-top-color: $tabsColor;
          }
        }
      }

      .#{$tabsPrefixCls}-tabitem-active {
        .#{$tabsPrefixCls}-tabitem-inner {
          border-top-color: $tabsColor;

          &:focus,
          &:hover {
            border-top: 3px solid $tabsColor;
          }
        }
      }
    }

    &.#{$tabsPrefixCls}-top {
      .#{$tabsPrefixCls}-tabitem {
        &-inner {
          border-bottom: 3px solid transparent;

          &:hover {
            border-bottom-color: $tabsColor;
          }
        }
      }

      .#{$tabsPrefixCls}-tabitem-active {
        .#{$tabsPrefixCls}-tabitem-inner {
          border-bottom-color: $tabsColor;

          &:focus,
          &:hover {
            border-bottom: 3px solid $tabsColor;
          }
        }
      }
    }
  }

  // extra
  &-extra-pre,
  &-extra {
    display: inline-block;
  }
}

// tab position bottom
.#{$tabsPrefixCls}.#{$tabsPrefixCls}-bottom {
  > .#{$tabsPrefixCls}-list {
    border-top: 1px solid $border-color-split;
    border-bottom: 0;
  }

  > .#{$tabsPrefixCls}-panel {
    padding-top: 0;
    padding-bottom: 10px;
  }
}

// tab position `left or right`
.#{$tabsPrefixCls}-vertical {
  > .#{$tabsPrefixCls}-list {
    border-bottom: 0;

    .#{$tabsPrefixCls}-tabitem {
      display: block;
      float: none;
      margin-right: 0;
      margin-bottom: 0.3em;

      &-inner {
        border-radius: 0;
      }

      &:last-child {
        margin-bottom: 0;
      }
    }
  }

  > .#{$tabsPrefixCls}-panel {
    width: auto;
    overflow: hidden;
  }
}

.#{$tabsPrefixCls}-vertical.#{$tabsPrefixCls}-left {
  > .#{$tabsPrefixCls}-list {
    float: left;
    padding: 0 0 0 0.5em;
    border-right: 1px solid $border-color-split;

    .#{$tabsPrefixCls}-tabitem-inner {
      text-align: right;
    }
  }

  > .#{$tabsPrefixCls}-panel {
    padding-left: 24px;
    border-left: 1px solid $border-color-split;
  }
}

.#{$tabsPrefixCls}-vertical.#{$tabsPrefixCls}-right {
  > .#{$tabsPrefixCls}-list {
    float: right;
    padding: 0 0.5em 0 0;
    margin-bottom: 0;
    margin-left: -1px;
    border-left: 1px solid $border-color-split;
  }

  > .#{$tabsPrefixCls}-panel {
    padding-right: 24px;
    border-right: 1px solid $border-color-split;
  }
}

// --- complex tab

.complex-tab-nav {
  display: flex;
  align-items: center;

  &-btn {
    i[class*='icon'] {
      display: inline-block;
      width: 2em;
      height: 2.8em;
      line-height: 2.8em;
      text-align: center;
      cursor: pointer;

      &.disabled {
        color: $disabled-btn-color;
        cursor: not-allowed;
      }
    }
  }

  &-scroll {
    flex: 1;
    position: relative;
    z-index: 0;
    display: inline-block;
    overflow: hidden;
    font-size: 12px;
    color: #555;
    white-space: nowrap;

    .complex-tab-nav-list {
      display: inline-block;
      transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);

      .amos-tabs-list {
        position: relative;
      }
    }
  }
}

$tab-mode-color: $main-color;

// --card tabs
%active-cardtab-class {
  color: $tab-mode-color;
  background: white;
  border: 1px solid #deddde;
  border-bottom: 1px solid $tab-mode-color;
}

%cardtab-inner-class {
  margin-left: 0.5em;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, #e4e4e4 0%, #e4e4e4 0%, #f2f2f2 100%, #f2f2f2 100%);
  border: 1px solid #deddde;
  border-radius: 4px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

// card
.#{$tabsPrefixCls}.#{$tabsPrefixCls}-card {
  > .#{$tabsPrefixCls}-list {
    padding: 0 0.5em;

    .#{$tabsPrefixCls}-tabitem {
      &-inner {
        @extend %cardtab-inner-class;

        padding: 0.7em 1.2em;

        &:hover {
          @extend %active-cardtab-class;
        }
      }

      &.#{$tabsPrefixCls}-tabitem-active {
        .#{$tabsPrefixCls}-tabitem-inner {
          @extend %active-cardtab-class;

          &:hover {
            @extend %active-cardtab-class;
          }
        }
      }
    }
  }
}

// mincard
.#{$tabsPrefixCls}.#{$tabsPrefixCls}-mincard {
  > .#{$tabsPrefixCls}-list {
    padding: 0 0.5em;

    .#{$tabsPrefixCls}-tabitem {
      &-inner {
        @extend %cardtab-inner-class;

        padding: 0.2em 1.2em;

        &:hover {
          @extend %active-cardtab-class;
        }
      }

      &.#{$tabsPrefixCls}-tabitem-active {
        .#{$tabsPrefixCls}-tabitem-inner {
          @extend %active-cardtab-class;

          &:hover {
            @extend %active-cardtab-class;
          }
        }
      }
    }
  }
}

// --line tabs
%active-linetab-class {
  color: $tab-mode-color;
  background: transparent;
  border: 0;
}

.#{$tabsPrefixCls}.#{$tabsPrefixCls}-line {
  > .#{$tabsPrefixCls}-list {
    padding: 0 0.5em;

    .#{$tabsPrefixCls}-tabitem {
      position: relative;

      &::before {
        position: absolute;
        bottom: -1px;
        left: 50%;
        width: 0;
        border-bottom: 2px solid $tab-mode-color;
        content: '';
        transition: all 0.2s ease-in-out;
      }

      &-inner {
        font-size: 14px;
        background: transparent;
        border: 0;

        &:hover {
          @extend %active-linetab-class;
        }
      }

      &.#{$tabsPrefixCls}-tabitem-active {
        &::before {
          left: 0;
          width: 100%;
        }

        .#{$tabsPrefixCls}-tabitem-inner {
          @extend %active-linetab-class;

          &:hover {
            @extend %active-linetab-class;
          }
        }
      }
    }
  }
}

// -- bulge tabs
%active-bulgetab-class {
  color: var(--tabs-bulge-active-color, #3f3f3f);
}

@mixin tab-bulge($normalBg, $activeBg) {
  > .#{$tabsPrefixCls}-list {
    display: flex;
    padding: 0;
    align-items: flex-end;
    flex-wrap: wrap;

    .#{$tabsPrefixCls}-tabitem {
      &-inner {
        height: 30px;
        padding: 6px 29px;
        margin-left: 0.5em;
        background: $normalBg;
        border: 1px solid #eaeaea;
        border-bottom: 0;
        border-radius: 6px 6px 0 0;

        &:hover {
          @extend %active-bulgetab-class;
        }
      }

      &.#{$tabsPrefixCls}-tabitem-active {
        .#{$tabsPrefixCls}-tabitem-inner {
          height: 36px;
          font-size: 16px;
          color: var(--tabs-bulge-active-color, #3f3f3f);
          background: $activeBg;

          &:hover {
            @extend %active-bulgetab-class;
          }
        }
      }
    }
  }


  &.#{$tabsPrefixCls}-dynamic {
    > .#{$tabsPrefixCls}-list {
      .#{$tabsPrefixCls}-tabitem {
        &-inner {
          padding: 0 29px;
        }

        &-remove {
          font-size: 12px;
        }
      }
    }
  }
}

$bulgeNormalBg: var(--tabs-bulge-normal-bg, white);
$bulgeActiveBg: var(--tabs-bulge-active-bg, linear-gradient(180deg, #eee 0%, #e1e1e1 100%));

// bulge
.#{$tabsPrefixCls}.#{$tabsPrefixCls}-bulge {
  @include tab-bulge($bulgeNormalBg, $bulgeActiveBg);
}

// unbulge 反转 颜色
.#{$tabsPrefixCls}.#{$tabsPrefixCls}-unbulge {
  @include tab-bulge($bulgeActiveBg, $bulgeNormalBg);
}


// -- bullet tabs
%active-bullettab-class {
  background: #ebecf0;
}

.#{$tabsPrefixCls}.#{$tabsPrefixCls}-bullet {
  > .#{$tabsPrefixCls}-list {
    padding: 0;

    .#{$tabsPrefixCls}-tabitem {
      &-inner {
        padding: 6px 12px;
        margin-right: -1px;
        color: #333;
        background: #f2f3f7;
        border: 1px solid #c4c6cf;
        border-right-color: transparent;
        border-radius: 0;
        transition: background 0.1s linear;

        &:hover {
          @extend %active-bullettab-class;
        }
      }

      &.#{$tabsPrefixCls}-tabitem-active {
        .#{$tabsPrefixCls}-tabitem-inner {
          color: white;
          background: $tab-mode-color;
          border-right: 1px solid #c4c6cf;
          border-color: $tab-mode-color;
        }
      }

      &:first-child {
        .#{$tabsPrefixCls}-tabitem-inner {
          border-radius: 6px 0 0 6px;
        }
      }

      &:last-child {
        .#{$tabsPrefixCls}-tabitem-inner {
          border-right: 1px solid #c4c6cf;
          border-radius: 0 6px 6px 0;
        }
      }
    }
  }
}

// -- divider tabs
%active-dividertab-class {
  background: transparent;
}

.#{$tabsPrefixCls}.#{$tabsPrefixCls}-divider {
  > .#{$tabsPrefixCls}-list {
    padding: 0;
    border: 0;

    .#{$tabsPrefixCls}-tabitem {
      position: relative;

      &::before {
        position: absolute;
        content: '';
        transition: all 0.3s ease;
      }

      &:not(:last-child)::after {
        position: absolute;
        top: calc(50% - 4px);
        right: 0;
        width: 1px;
        height: 8px;
        background: #888;
        content: '';
      }

      &-inner {
        padding: 6px 12px;
        color: #666;
        background: transparent;

        &:hover {
          @extend %active-dividertab-class;
        }
      }

      &.#{$tabsPrefixCls}-tabitem-active {
        .#{$tabsPrefixCls}-tabitem-inner {
          color: $tab-mode-color;
          background: transparent;
        }
      }
    }
  }
}
