$block = ".klara-ui-tabs";
$animation-duration = 150ms;
$tab-width = 175px;
$tab-height = 40px;

{$block} {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  overflow: hidden;
  margin: 0;
  padding: 8px 0 0;
  background: $c-gray-lightest;
  cursor: default;
  user-select: none;

  &::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 1px;
    background: $c-gray-light;
    content: "";
  }

  &__inner {
    display: flex;
    flex: 1;
    align-items: center;
    overflow-x: hidden;
    overflow-y: hidden;
    padding: 0 8px;

    &::-webkit-scrollbar {
      display: none;
    }
  }

  &__overflow-indicator--left, &__overflow-indicator--right {
    position: absolute;
    top: 8px;
    bottom: 1px;
    z-index: 200;
    display: flex;
    align-items: center;
    width: 0;
    transition: all $animation-duration;

    &.visible {
      width: 60px;

      & > svg {
        opacity: 1;
      }
    }

    & > svg {
      opacity: 0;
      transition: fill $animation-duration;
      fill: $c-gray-base;
    }

    &:hover {
      & > svg {
        fill: $c-gray-dark;
      }
    }
  }

  &__overflow-indicator--left {
    left: 0;
    background: linear-gradient(to right, $c-gray-lightest 50%, transparent);
  }

  &__overflow-indicator--right {
    right: 0;
    justify-content: flex-end;
    background: linear-gradient(to left, $c-gray-lightest 50%, transparent);
  }

  &__tab {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    padding: 0 12px 0 16px;
    max-width: $tab-width;
    height: $tab-height;
    color: $c-gray-dark;

    &-enter {
      .klara-ui-tabs__tab {
        top: $tab-height;
        transition: all $animation-duration;
      }

      &-active {
        .klara-ui-tabs__tab {
          top: 0;
        }
      }
    }

    &-exit {
      .klara-ui-tabs__tab {
        top: 0;
        transition: all $animation-duration;
      }

      &-active {
        .klara-ui-tabs__tab {
          top: $tab-height;
        }
      }
    }

    &--active {
      z-index: 100;
      color: $c-gray-darker;

      {$block}__tab__title {
        &::before {
          opacity: 0;
        }

        &::after {
          opacity: 1;
        }
      }

      {$block}__tab__background {
        border-color: $c-gray-light;
        background: $c-white-base;
      }
    }

    &__title {
      position: relative;
      flex: 1;
      overflow: hidden;
      white-space: nowrap;

      &::before, &::after {
        position: absolute;
        top: 0;
        right: 0;
        width: 30px;
        height: 100%;
        content: "";
      }

      &::before {
        background: linear-gradient(to left, $c-gray-lightest 20%, transparent);
        opacity: 1;
      }

      &::after {
        background: linear-gradient(to left, $c-white-base 20%, transparent);
        opacity: 0;
      }
    }

    &__close {
      z-index: 1;
      display: flex;
      justify-content: center;

      svg {
        fill: $c-gray-dark;
      }
    }

    &__background {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: 1px solid transparent;
      border-bottom: 0;
      border-top-left-radius: 8px;
      border-top-right-radius: 8px;
      background: $c-gray-lightest;
      pointer-events: none;
    }

    &::after {
      position: absolute;
      top: 20%;
      right: -1px;
      z-index: 1;
      width: 1px;
      height: 60%;
      background: $c-gray-base;
      content: "";
    }

    &--active {
      &::after {
        display: none;
      }
    }
  }

  [data-react-beautiful-dnd-drag-handle] {
    flex: 1;
    max-width: $tab-width;
    outline: 0;
    cursor: default;
  }

  &__transition-group {
    display: flex;
    flex: 1;
  }

  [data-react-beautiful-dnd-droppable] {
    display: flex;
    flex: 1;
  }

  &__add-tab {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    margin: 0 4px;

    button {
      width: 32px;
      outline: 0 !important; // @stylint ignore
      border-radius: 50%;
    }
  }
}
