@import "../../../styles/themes";
@import "../../../styles/typography";

.tab--wrapper {
  position: relative;
  display: inline-block;
  padding-left: 1px;
  padding-right: 1px;
  border-top: 1px solid transparent;
  border-bottom: 2px solid;
  @include theme-prop(border-bottom-color, primary-background-hover-color);
  @include theme-prop(color, primary-text-color);
  text-align: center;
  height: 100%;

  &:after {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    content: '';
    border-bottom: solid 2px;
    @include theme-prop(border-bottom-color, primary-color);
    transform: scaleX(0);
    z-index: 0;
  }

  .tab-inner {
    $margin-bottom: 1px;
    height: calc(100% - #{$margin-bottom});
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 4px 16px;
    font-weight: 400;
    font-size: 16px;
    user-select: none;
    margin-bottom: $margin-bottom;
    cursor: pointer;

    &:focus {
      outline: none;
    }

    .tab-icon {
      @include theme-prop(color, icon-color);
      margin-right: 8px;

      &.right {
        margin-right: 0;
        margin-left: 8px;
      }
    }
  }

  &.focus-visible {
    position: relative;

    :after {
      content: "";
      position: absolute;
      left: -1px;
      right: -1px;
      top: -1px;
      bottom: -3px;
      border: 1px solid;
      @include theme-prop(border-color, primary-color);
      box-sizing: border-box;
      border-radius: 1px;
      padding-left: 0;
      padding-right: 0;
      z-index: 1;
    }

    :before {
      content: "";
      position: absolute;
      top: -4px;
      left: -4px;
      right: -4px;
      bottom: -6px;
      opacity: 0.4;
      border: 3px solid;
      @include theme-prop(border-color, primary-color);
      border-radius: 4px;
      z-index: 1;
    }
  }

  &.active {
    &:after {
      transform: scaleX(1);
      transition: transform 100ms cubic-bezier(0, 0, 0.35, 1);
    }
  }

  &.disabled {
    @include theme-prop(color, disabled-text-color);

    .tab-inner {
      cursor: not-allowed;
    }
  }

  &:not(.disabled) {
    .tab-inner {
      &:hover {
        border-radius: 4px;
        @include theme-prop(background-color, primary-background-hover-color);
      }
    }
  }
}
