@import '../../style/themes/index';
@import '../../style/mixins/index';
@import './card-style';

@yee-tab-prefix-cls: ~'@{yee-prefix}-tabs';

// Hidden content
.yee-tabs-hidden-content() {
  height: 0;
  padding: 0 !important;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  input {
    visibility: hidden;
  }
}

.@{yee-tab-prefix-cls} {
  .yee-reset-component;

  position: relative;
  overflow: hidden;
  .yee-clearfix;

  &-ink-bar {
    position: absolute;
    bottom: 1px;
    left: 0;
    z-index: 1;
    box-sizing: border-box;
    width: 0;
    height: 2px;
    background-color: @yee-tabs-ink-bar-color;
    transform-origin: 0 0;
  }

  &-bar {
    margin: @yee-tabs-bar-margin;
    border-bottom: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
    outline: none;
    transition: padding 0.3s @yee-ease-in-out;
  }

  &-nav-container {
    position: relative;
    box-sizing: border-box;
    margin-bottom: -1px;
    overflow: hidden;
    font-size: @yee-tabs-title-font-size;
    line-height: @yee-line-height-base;
    white-space: nowrap;
    transition: padding 0.3s @yee-ease-in-out;
    .yee-clearfix;

    &-scrolling {
      padding-right: @yee-tabs-scrolling-size;
      padding-left: @yee-tabs-scrolling-size;
    }
  }

  // https://github.com/ant-design/ant-design/issues/9104
  &-bottom &-bottom-bar {
    margin-top: 16px;
    margin-bottom: 0;
    border-top: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
    border-bottom: none;
  }

  &-bottom &-bottom-bar &-ink-bar {
    top: 1px;
    bottom: auto;
  }

  &-bottom &-bottom-bar &-nav-container {
    margin-top: -1px;
    margin-bottom: 0;
  }

  &-tab-prev,
  &-tab-next {
    position: absolute;
    z-index: 2;
    width: 0;
    height: 100%;
    color: @yee-text-color-secondary;
    text-align: center;
    background-color: transparent;
    border: 0;
    cursor: pointer;
    opacity: 0;
    transition:
      width 0.3s @yee-ease-in-out,
      opacity 0.3s @yee-ease-in-out,
      color 0.3s @yee-ease-in-out;
    user-select: none;
    pointer-events: none;

    &.@{yee-tab-prefix-cls}-tab-arrow-show {
      width: @yee-tabs-scrolling-size;
      height: 100%;
      opacity: 1;
      pointer-events: auto;
    }

    &:hover {
      color: @yee-text-color;
    }

    &-icon {
      position: absolute;
      top: 50%;
      left: 50%;
      font-weight: bold;
      font-style: normal;
      font-variant: normal;
      line-height: inherit;
      text-align: center;
      text-transform: none;
      transform: translate(-50%, -50%);

      &-target {
        display: block;
        .yee-iconfont-size-under-12px(10px);
      }
    }
  }

  &-tab-btn-disabled {
    cursor: not-allowed;
    &,
    &:hover {
      color: @yee-disabled-color;
    }
  }

  &-tab-next {
    right: 2px;
  }

  &-tab-prev {
    left: 0;
    :root & {
      filter: none;
    }
  }

  &-nav-wrap {
    margin-bottom: -1px;
    overflow: hidden;
  }

  &-nav-scroll {
    overflow: hidden;
    white-space: nowrap;
  }

  &-nav {
    position: relative;
    display: inline-block;
    box-sizing: border-box;
    margin: 0;
    padding-left: 0;
    list-style: none;
    transition: transform 0.3s @yee-ease-in-out;

    &::before,
    &::after {
      display: table;
      content: ' ';
    }

    &::after {
      clear: both;
    }

    .@{yee-tab-prefix-cls}-tab {
      position: relative;
      display: inline-block;
      box-sizing: border-box;
      height: 100%;
      margin: @yee-tabs-horizontal-margin;
      padding: @yee-tabs-horizontal-padding;
      text-decoration: none;
      cursor: pointer;
      transition: color 0.3s @yee-ease-in-out;

      &::before {
        position: absolute;
        top: -1px;
        left: 0;
        width: 100%;
        border-top: 2px solid transparent;
        border-radius: @yee-border-radius-base @yee-border-radius-base 0 0;
        transition: all 0.3s;
        content: '';
        pointer-events: none;
      }

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

      &:hover {
        color: @yee-tabs-hover-color;
      }

      &:active {
        color: @yee-tabs-active-color;
      }

      .@{yee-iconfont-css-prefix} {
        margin-right: 8px;
      }

      &-active {
        color: @yee-tabs-highlight-color;
        // https://github.com/vueComponent/ant-design-vue/issues/4241
        // Remove font-weight to keep pace with antd (#4241)
        text-shadow: 0 0 0.25px currentColor;
        // font-weight: 500;
      }

      &-disabled {
        &,
        &:hover {
          color: @yee-disabled-color;
          cursor: not-allowed;
        }
      }
    }
  }

  .@{yee-tab-prefix-cls}-large-bar {
    .@{yee-tab-prefix-cls}-nav-container {
      font-size: @yee-tabs-title-font-size-lg;
    }
    .@{yee-tab-prefix-cls}-tab {
      padding: @yee-tabs-horizontal-padding-lg;
    }
  }

  .@{yee-tab-prefix-cls}-small-bar {
    .@{yee-tab-prefix-cls}-nav-container {
      font-size: @yee-tabs-title-font-size-sm;
    }
    .@{yee-tab-prefix-cls}-tab {
      padding: @yee-tabs-horizontal-padding-sm;
    }
  }

  // Create an empty element to avoid margin collapsing
  // https://github.com/ant-design/ant-design/issues/18103
  &-content::before {
    display: block;
    overflow: hidden;
    content: '';
  }

  // Horizontal Content
  .@{yee-tab-prefix-cls}-top-content,
  .@{yee-tab-prefix-cls}-bottom-content {
    width: 100%;

    > .@{yee-tab-prefix-cls}-tabpane {
      flex-shrink: 0;
      width: 100%;
      -webkit-backface-visibility: hidden;
      opacity: 1;
      transition: opacity 0.45s;
    }

    > .@{yee-tab-prefix-cls}-tabpane-inactive {
      .yee-tabs-hidden-content();
    }

    &.@{yee-tab-prefix-cls}-content-animated {
      display: flex;
      flex-direction: row;
      transition: margin-left 0.3s @yee-ease-in-out;
      will-change: margin-left;
    }
  }

  // Vertical Bar
  .@{yee-tab-prefix-cls}-left-bar,
  .@{yee-tab-prefix-cls}-right-bar {
    height: 100%;
    border-bottom: 0;

    .@{yee-tab-prefix-cls}-tab-arrow-show {
      width: 100%;
      height: @yee-tabs-scrolling-size;
    }

    .@{yee-tab-prefix-cls}-tab {
      display: block;
      float: none;
      margin: @yee-tabs-vertical-margin;
      padding: @yee-tabs-vertical-padding;

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

    .@{yee-tab-prefix-cls}-extra-content {
      text-align: center;
    }

    .@{yee-tab-prefix-cls}-nav-scroll {
      width: auto;
    }

    .@{yee-tab-prefix-cls}-nav-container,
    .@{yee-tab-prefix-cls}-nav-wrap {
      height: 100%;
    }

    .@{yee-tab-prefix-cls}-nav-container {
      margin-bottom: 0;

      &.@{yee-tab-prefix-cls}-nav-container-scrolling {
        padding: @yee-tabs-scrolling-size 0;
      }
    }

    .@{yee-tab-prefix-cls}-nav-wrap {
      margin-bottom: 0;
    }

    .@{yee-tab-prefix-cls}-nav {
      width: 100%;
    }

    .@{yee-tab-prefix-cls}-ink-bar {
      top: 0;
      bottom: auto;
      left: auto;
      width: 2px;
      height: 0;
    }

    .@{yee-tab-prefix-cls}-tab-next {
      right: 0;
      bottom: 0;
      width: 100%;
      height: @yee-tabs-scrolling-size;
    }

    .@{yee-tab-prefix-cls}-tab-prev {
      top: 0;
      width: 100%;
      height: @yee-tabs-scrolling-size;
    }
  }

  // Vertical Content
  .@{yee-tab-prefix-cls}-left-content,
  .@{yee-tab-prefix-cls}-right-content {
    width: auto;
    margin-top: 0 !important;
    overflow: hidden;
  }

  // Vertical - Left
  .@{yee-tab-prefix-cls}-left-bar {
    float: left;
    margin-right: -1px;
    margin-bottom: 0;
    border-right: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
    .@{yee-tab-prefix-cls}-tab {
      text-align: right;
    }
    .@{yee-tab-prefix-cls}-nav-container {
      margin-right: -1px;
    }
    .@{yee-tab-prefix-cls}-nav-wrap {
      margin-right: -1px;
    }
    .@{yee-tab-prefix-cls}-ink-bar {
      right: 1px;
    }
  }
  .@{yee-tab-prefix-cls}-left-content {
    padding-left: 24px;
    border-left: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
  }

  // Vertical - Right
  .@{yee-tab-prefix-cls}-right-bar {
    float: right;
    margin-bottom: 0;
    margin-left: -1px;
    border-left: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
    .@{yee-tab-prefix-cls}-nav-container {
      margin-left: -1px;
    }
    .@{yee-tab-prefix-cls}-nav-wrap {
      margin-left: -1px;
    }
    .@{yee-tab-prefix-cls}-ink-bar {
      left: 1px;
    }
  }
  .@{yee-tab-prefix-cls}-right-content {
    padding-right: 24px;
    border-right: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
  }
}

.@{yee-tab-prefix-cls}-top .@{yee-tab-prefix-cls}-ink-bar-animated,
.@{yee-tab-prefix-cls}-bottom .@{yee-tab-prefix-cls}-ink-bar-animated {
  transition:
    transform 0.3s @yee-ease-in-out,
    width 0.2s @yee-ease-in-out,
    left 0.3s @yee-ease-in-out;
}

.@{yee-tab-prefix-cls}-left .@{yee-tab-prefix-cls}-ink-bar-animated,
.@{yee-tab-prefix-cls}-right .@{yee-tab-prefix-cls}-ink-bar-animated {
  transition:
    transform 0.3s @yee-ease-in-out,
    height 0.2s @yee-ease-in-out,
    top 0.3s @yee-ease-in-out;
}

// No animation
.yee-tabs-no-animation() {
  > .@{yee-tab-prefix-cls}-content-animated {
    margin-left: 0 !important;
    transform: none !important;
  }
  > .@{yee-tab-prefix-cls}-tabpane-inactive {
    .yee-tabs-hidden-content();
  }
}

.no-flex,
.@{yee-tab-prefix-cls}-no-animation {
  > .@{yee-tab-prefix-cls}-content {
    .yee-tabs-no-animation();
  }
}

.@{yee-tab-prefix-cls}-left-content,
.@{yee-tab-prefix-cls}-right-content {
  .yee-tabs-no-animation();
}
