%btn-group {
  position: relative;
  display: inline-flex;
  margin: .2em;

  > .btn,
  > .btn-flat,
  > .dropdown > .dropdown-button {
    flex: 0 1 auto;
    margin: 0;
  }

  > .btn,
  > .btn-flat {
    &:not(:first-child):not(:last-child) {
      border-radius: 0;
    }
  }

  > .dropdown:not(:first-child):not(:last-child) {
    > .dropdown-button {
      border-radius: 0;
    }
  }
}

.btn-group {
  @extend %btn-group;

  > .btn,
  > .btn-flat {
    &:first-child {
      @include border-right-radius(0);
    }

    &:last-child {
      @include border-left-radius(0);
    }
  }

  > .dropdown:first-child {
    > .dropdown-button {
      @include border-right-radius(0);
    }
  }

  > .dropdown:last-child {
    > .dropdown-button {
      @include border-left-radius(0);
    }
  }
}

.btn-group-vertical {
  @extend %btn-group;
  flex-direction: column;

  > .btn,
  > .btn-flat {
    &:first-child {
      @include border-bottom-radius(0);
    }

    &:last-child {
      @include border-top-radius(0);
    }
  }

  > .dropdown:first-child {
    > .dropdown-button {
      @include border-bottom-radius(0);
    }
  }

  > .dropdown:last-child {
    > .dropdown-button {
      @include border-top-radius(0);
    }
  }
}
