.tab-bar {
  display: flex;
  flex-direction: row;
  height: var(--tab-bar-height);

  &.vertical {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    flex-shrink: 0;
    padding: var(--spacing) 0;
  }

  &.switch:not(.vertical) {
    gap: var(--spacing);
  }

  &-item {
    // Reset styles from global buttons
    border: none;
    box-shadow: none;
    color: var(--text-color);
    background: var(--background-color);
    font-family: var(--font-family-sans-serif);
    font-size: var(--font-size);
  }

  .tab-bar-separator {
    width: 1px;
    background-color: var(--box-border-color);
  }

  &.tabs &-item {
    border-radius: 0;

    // Give each item equal space
    flex: 1;

    // Center item contest horizontally and vertically
    display: flex;
    align-items: center;
    justify-content: center;

    border-bottom: 1px solid var(--box-border-color);
    border-right: 1px solid var(--box-border-color);

    // This makes it so that we never render a double-width item border.
    // It has the unintended consequence of making it impossible to have a tab
    // bar with just one item but we can live with that.
    &:last-child {
      border-right: none;
    }

    // We intentionally swap foreground and background here to create
    // a more intense selected state. The tab bar is kind of a special snowflake
    // in so far that it doesn't have an active selection state, just a selected
    // one.
    &.selected {
      box-shadow: inset 0 -3px 0px var(--tab-bar-active-color);
    }

    &:hover {
      background: var(--tab-bar-hover-background-color);
    }

    .with-indicator {
      display: flex;
      align-items: center;
    }

    .indicator {
      color: var(--tab-bar-active-color);
      margin-left: 4px;
      margin-top: 1px;
    }

    .counter {
      color: var(--tab-bar-count-color);
      background-color: var(--tab-bar-count-background-color);
      margin-left: 4px;
      padding: 2px 5px;
      font-size: var(--font-size-xs);
      font-weight: var(--font-weight-semibold);
      border-radius: 20px;
      line-height: 1;
    }

    &:focus-visible {
      outline-offset: -4px;
    }
  }

  &.switch &-item {
    &,
    * {
      cursor: pointer;
    }

    // Give each item equal space
    flex: 1;

    // Center item contest horizontally and vertically
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;

    border: none;

    border-radius: var(--border-radius);

    // We intentionally swap foreground and background here to create
    // a more intense selected state. The tab bar is kind of a special snowflake
    // in so far that it doesn't have an active selection state, just a selected
    // one.
    &.selected {
      background-color: var(--tab-bar-active-color);
      color: var(--box-selected-active-text-color);
    }

    &:focus-visible {
      border-radius: var(--outlined-border-radius);
      outline-offset: 3px;
    }
  }

  &.vertical &-item {
    border-radius: var(--border-radius);
    min-width: 150px;

    &:focus-visible {
      border-radius: var(--outlined-border-radius);
      outline-offset: 3px;
    }

    // Center item contest horizontally and vertically
    display: flex;
    justify-content: left;

    padding: var(--spacing);
    margin: var(--spacing-third) var(--spacing-double);

    // This makes it so that we never render a double-width item border.
    // It has the unintended consequence of making it impossible to have a tab
    // bar with just one item but we can live with that.
    &:last-child {
      border-right: none;
    }

    // We intentionally swap foreground and background here to create
    // a more intense selected state. The tab bar is kind of a special snowflake
    // in so far that it doesn't have an active selection state, just a selected
    // one.
    &.selected {
      background-color: var(--tab-bar-active-color);
      color: var(--box-selected-active-text-color);
    }

    &:not(.selected) {
      .icon {
        color: #{$gray-500};
      }

      &:hover {
        background: var(--tab-bar-hover-background-color);
      }
    }

    .icon {
      vertical-align: bottom;
      margin-right: var(--spacing);
    }
  }
}
