.pf-c-tabs {
  // Primary tab items
  --pf-c-tabs__item--BackgroundColor: var(--pf-global--BackgroundColor--100);
  --pf-c-tabs__item--BorderColor: var(--pf-global--BorderColor--100);
  --pf-c-tabs__item--BorderWidth: var(--pf-global--BorderWidth--sm);
  --pf-c-tabs__item--m-current--ZIndex: var(--pf-global--ZIndex--sm);
  --pf-c-tabs__item--m-current--Color: var(--pf-global--active-color--100);
  --pf-c-tabs__item--m-current--BorderTopWidth: var(--pf-global--BorderWidth--md);

  // Secondary tab items
  --pf-c-tabs__item--hover--Color: var(--pf-global--Color--dark-200);

  // Tab buttons
  --pf-c-tabs__button--Color: var(--pf-global--Color--100);
  --pf-c-tabs__button--FontWeight: var(--pf-global--FontWeight--normal);
  --pf-c-tabs__button--Background: transparent;
  --pf-c-tabs__button--OutlineOffset: calc(-1 * var(--pf-global--spacer--xs));
  --pf-c-tabs__button--PaddingTop: var(--pf-global--spacer--sm);
  --pf-c-tabs__button--PaddingRight: var(--pf-global--spacer--sm);
  --pf-c-tabs__button--PaddingBottom: var(--pf-global--spacer--sm);
  --pf-c-tabs__button--PaddingLeft: var(--pf-global--spacer--sm);

  // Scroll buttons
  --pf-c-tabs__scroll-button--Width: var(--pf-global--spacer--xl);
  --pf-c-tabs__scroll-button--ZIndex: var(--pf-global--ZIndex--xs);
  --pf-c-tabs__scroll-button--m-secondary--hover--Color: var(--pf-global--active-color--100);
  --pf-c-tabs__scroll-button--m-secondary--hover--Color: var(--pf-global--active-color--100);
  --pf-c-tabs__scroll-button--m-secondary-right--m-start-current--Color: var(--pf-global--active-color--100);
  --pf-c-tabs__scroll-button--m-secondary--nth-of-type-1--BoxShadow: var(--pf-global--BoxShadow--lg-right);
  --pf-c-tabs__scroll-button--m-secondary--nth-of-type-2--BoxShadow: var(--pf-global--BoxShadow--lg-left);

  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;

  // Scroll buttons hidden by default
  .pf-c-tabs__scroll-button {
    display: none;
    visibility: hidden;
  }

  // Scroll buttons shown with modifiers
  &.pf-m-start .pf-c-tabs__scroll-button:nth-of-type(1),
  &.pf-m-end .pf-c-tabs__scroll-button:nth-of-type(2) {
    display: block;
    visibility: visible;
  }

  // Scroll button current state
  &.pf-m-start-current:not(.pf-m-tabs-secondary) .pf-c-tabs__scroll-button:nth-of-type(1),
  &.pf-m-end-current:not(.pf-m-tabs-secondary) .pf-c-tabs__scroll-button:nth-of-type(2) {
    &::after {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      margin-left: var(--pf-c-tabs__item--BorderWidth);
      content: "";
      border-top: var(--pf-c-tabs__item--m-current--BorderTopWidth) solid var(--pf-c-tabs__item--m-current--Color);
    }
  }

  // Scroll button current state
  &.pf-m-start-current.pf-m-tabs-secondary .pf-c-tabs__scroll-button:nth-of-type(1),
  &.pf-m-end-current.pf-m-tabs-secondary .pf-c-tabs__scroll-button:nth-of-type(2) {
    color: var(--pf-c-tabs__scroll-button--m-secondary-right--m-start-current--Color);
  }

  // Primary with secondary tabs style
  + &.pf-m-tabs-secondary {
    margin-top: calc(-1 * var(--pf-c-tabs__item--BorderWidth));
    border-top: var(--pf-c-tabs__item--BorderWidth) solid var(--pf-c-tabs__item--BorderColor);

    .pf-c-tabs__scroll-button {
      margin-top: calc(-1 * var(--pf-c-tabs__item--BorderWidth));
    }
  }

  // Filled style
  &.pf-m-fill {
    .pf-c-tabs__list {
      width: 100%;
    }

    .pf-c-tabs__item {
      flex: 1;
      white-space: nowrap;

      &:first-of-type .pf-c-tabs__button::before {
        border-left: none;
      }

      &:last-of-type .pf-c-tabs__button::before {
        border-right: none;
      }

      .pf-c-tabs__button {
        width: 100%;
      }
    }
  }
}

// Tab list
.pf-c-tabs__list {
  @include pf-overflow-hide-scroll;

  position: relative;
  display: flex;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;

  // Right border on last tab
  .pf-c-tabs__item:last-of-type .pf-c-tabs__button::before {
    border-right-width: var(--pf-c-tabs__item--BorderWidth);
  }
}

// Tab items
.pf-c-tabs__item {
  flex: none;

  // Tab item hover state
  &:not(.pf-m-current):hover .pf-c-tabs__button::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin-left: var(--pf-c-tabs__item--BorderWidth);
    content: "";
    border-top: var(--pf-c-tabs__item--m-current--BorderTopWidth) solid var(--pf-c-tabs__item--hover--Color);
  }

  // Tab item current state
  &.pf-m-current .pf-c-tabs__button {
    color: var(--pf-c-tabs__item--m-current--Color);

    &::before {
      border-bottom-color: var(--pf-c-tabs__item--BackgroundColor);
    }

    &::after {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      margin-left: var(--pf-c-tabs__item--BorderWidth);
      content: "";
      border-top: var(--pf-c-tabs__item--m-current--BorderTopWidth) solid var(--pf-c-tabs__item--m-current--Color);
    }
  }

  // Secondary tab states
  .pf-m-tabs-secondary & .pf-c-tabs__button {
    // Remove current state and hover state
    &::before,
    &::after,
    &:hover::after {
      content: none;
    }
  }

  // Secondary tab hover state
  .pf-m-tabs-secondary &:not(.pf-m-current) .pf-c-tabs__button:hover {
    color: var(--pf-c-tabs__item--hover--Color);
  }
}


// Tab button
.pf-c-tabs__button {
  position: relative;
  display: inline-block;
  padding: var(--pf-c-tabs__button--PaddingTop) var(--pf-c-tabs__button--PaddingRight) var(--pf-c-tabs__button--PaddingBottom) var(--pf-c-tabs__button--PaddingLeft);
  font-weight: var(--pf-c-tabs__button--FontWeight);
  color: var(--pf-c-tabs__button--Color);
  user-select: none;
  background: var(--pf-c-tabs__button--Background);
  border: 0;
  outline-offset: var(--pf-c-tabs__button--OutlineOffset);

  // Tab button borders
  &::before {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    content: "";
    border: solid var(--pf-c-tabs__item--BorderColor);
    border-width: var(--pf-c-tabs__item--BorderWidth) 0 var(--pf-c-tabs__item--BorderWidth) var(--pf-c-tabs__item--BorderWidth);
  }

  &.pf-m-hover,
  &:hover {
    text-decoration: none;
  }
}

.pf-c-tabs__scroll-item {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--pf-c-tabs__scroll-button--Width);

  &:first-of-type {
    left: 0;
  }

  &:last-of-type {
    right: 0;
  }
}

// Scroll buttons
.pf-c-tabs__scroll-button {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: var(--pf-c-tabs__scroll-button--ZIndex);
  width: var(--pf-c-tabs__scroll-button--Width);
  line-height: 1;
  background-color: var(--pf-c-tabs__item--BackgroundColor);
  border: 0;

  // Align right scroll button
  &:nth-of-type(2) {
    right: 0;
  }

  // Scroll button borders
  &:not(.pf-m-secondary) {
    &::before {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      content: "";
      border: var(--pf-c-tabs__item--BorderWidth) solid var(--pf-c-tabs__item--BorderColor);
    }

    &:hover::after {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      content: "";
      border-top: var(--pf-c-tabs__item--m-current--BorderTopWidth) solid var(--pf-c-tabs__item--hover--Color);
    }
  }


  &.pf-m-secondary {
    &.pf-m-hover,
    &:hover,
    &.pf-m-active,
    &:active,
    &.pf-m-focus,
    &:focus {
      color: var(--pf-c-tabs__scroll-button--m-secondary--hover--Color);
    }

    &:nth-of-type(1) {
      box-shadow: var(--pf-c-tabs__scroll-button--m-secondary--nth-of-type-1--BoxShadow);
    }

    &:nth-of-type(2) {
      box-shadow: var(--pf-c-tabs__scroll-button--m-secondary--nth-of-type-2--BoxShadow);
    }
  }
}
