.#{$input-prefix-cls}-group {
  position: relative;
  display: flex;
  width: 100%;

  .#{$input-prefix-cls}-wrapper {
    // Ensure that the input is always above the *appended* addon button for
    // proper border colors.
    position: relative;
    z-index: 2;
    flex: 1 1 auto;
    // Add width 1% and flex-basis auto to ensure that button will not wrap out
    // the column. Applies to IE Edge+ and Firefox. Chrome does not require this.
    width: 1%;
    margin-bottom: 0;

    // Bring the "active" form control to the front
    @include hover-focus-active {
      z-index: 3;
    }
  }

  .#{$input-prefix-cls}-group-icon--right + .#{$input-prefix-cls}-wrapper{
    .#{$input-prefix-cls}-close-icon {
      right: $input-height;
    }
  }
}

.#{$input-prefix-cls}-group-addon,
.#{$input-prefix-cls}-group-icon,
.#{$input-prefix-cls}-group-btn,
.#{$input-prefix-cls}-group .form-input {
  // Vertically centers the content of the addons within the input group
  display: flex;
  align-items: center;

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

.#{$input-prefix-cls}-group-addon,
.#{$input-prefix-cls}-group-btn {
  white-space: nowrap;
  vertical-align: middle; // Match the inputs
}


// Sizing options
//
// Remix the default form control sizing classes into new ones for easier
// manipulation.

.#{$input-prefix-cls}-group--lg {
  > .#{$input-prefix-cls}-wrapper .#{$input-prefix-cls},
  > .#{$input-prefix-cls}-group-addon,
  > .#{$input-prefix-cls}-group-icon {
    @extend .#{$input-prefix-cls}--lg;
  }

  > .#{$input-prefix-cls}-group-btn > .#{$btn-prefix-cls} {
    @extend .#{$btn-prefix-cls}-lg;
  }
  > .#{$input-prefix-cls}-group-btn > .#{$btn-prefix-cls}-group {
    @extend .#{$btn-prefix-cls}-group-lg;
  }

  > .#{$input-prefix-cls}-group-icon .aid,
  > .#{$input-prefix-cls}-group-addon .aid{
    font-size: $input-icon-font-size-lg;
  }

  > .#{$input-prefix-cls}-group-icon {
    padding: 0;
    .aid{
      width: 34px;
    }
    + .#{$input-prefix-cls}-wrapper .#{$input-prefix-cls}{
      padding-left: $input-height-lg;
    }
  }
  > .#{$input-prefix-cls}-group-icon.#{$input-prefix-cls}-group-icon--right {
    + .#{$input-prefix-cls}-wrapper .#{$input-prefix-cls}{
      padding-right: $input-height-lg;
      padding-left: $input-padding-x-lg;

      .#{$input-prefix-cls}-close-icon {
        right: $input-height-lg;
      }
    }
  }
}

.#{$input-prefix-cls}-group--sm{
  > .#{$input-prefix-cls}-wrapper .#{$input-prefix-cls},
  > .#{$input-prefix-cls}-group-addon,
  > .#{$input-prefix-cls}-group-icon {
    @extend .#{$input-prefix-cls}--sm;
  }

  > .#{$input-prefix-cls}-group-btn > .#{$btn-prefix-cls} {
    @extend .#{$btn-prefix-cls}-sm;
  }
  > .#{$input-prefix-cls}-group-btn > .#{$btn-prefix-cls}-group {
    @extend .#{$btn-prefix-cls}-group-sm;
  }

  > .#{$input-prefix-cls}-group-icon .aid,
  > .#{$input-prefix-cls}-group-addon .aid{
    font-size: $input-icon-font-size-sm;
  }

  > .#{$input-prefix-cls}-group-icon {
    padding: 0;
    .aid{
      width: $input-height-sm;
    }
    + .#{$input-prefix-cls}-wrapper .#{$input-prefix-cls}{
      padding-left: $input-height-sm;
    }
  }
  > .#{$input-prefix-cls}-group-icon.#{$input-prefix-cls}-group-icon--right {
    + .#{$input-prefix-cls}-wrapper .#{$input-prefix-cls}{
      padding-right: $input-height-sm;
      padding-left: $input-padding-x-sm;

      .#{$input-prefix-cls}-close-icon {
        right: $input-height-sm;
      }
    }
  }

}


.#{$input-prefix-cls}-group-addon,
.#{$input-prefix-cls}-group-icon{
  font-size: $input-font-size; // Match inputs
  line-height: $input-height - $input-btn-border-width * 2;
  color: $input-color;
  .aid{
    font-size: $input-icon-font-size;
  }
}


//
// Text input groups
//

.#{$input-prefix-cls}-group-addon{
  padding: 0 $input-padding-x;
  margin-bottom: 0; // Allow use of <label> elements by overriding our default margin-bottom
  font-weight: $font-weight-normal;
  text-align: center;
  background-color: $input-group-addon-bg;
  border: $input-btn-border-width solid $input-group-addon-border-color;
  @include border-radius($border-radius);

  // scss-lint:disable QualifyingElement
  // Nuke default margins from checkboxes and radios to vertically center within.
  input[type="radio"],
  input[type="checkbox"] {
    margin-top: 0;
  }
  // scss-lint:enable QualifyingElement

}


//
// icon input groups
//

.#{$input-prefix-cls}-group-icon{
  position: absolute;
  z-index: 4;
  display: block;
  width: 34px;
  font-size: 0 !important;
  line-height: $input-height;

  + .#{$input-prefix-cls}-wrapper .#{$input-prefix-cls}{
    padding-left: $input-height;
    border-radius: $border-radius !important;
  }

  .aid{
    width: 100%;
    line-height: 1;
    //border-right: $border-width solid $input-border-color;
    color: $input-icon-color;
    text-align: center;
    vertical-align: middle;
  }
}
.#{$input-prefix-cls}-group-icon.#{$input-prefix-cls}-group-icon--right {
  right: 0;
  + .#{$input-prefix-cls}-wrapper .#{$input-prefix-cls}{
    padding-right: $input-height;
    padding-left: $input-padding-x;
    border-radius: $border-radius !important;
  }
}


//
// Reset rounded corners
//

.#{$input-prefix-cls}-group .#{$input-prefix-cls}-wrapper:not(:last-child) .#{$input-prefix-cls},
.#{$input-prefix-cls}-group-addon:not(:last-child),
.#{$input-prefix-cls}-group-btn:not(:last-child) > .#{$btn-prefix-cls},
.#{$input-prefix-cls}-group-btn:not(:last-child) > .#{$btn-prefix-cls}-group > .#{$btn-prefix-cls},
.#{$input-prefix-cls}-group-btn:not(:last-child) > .#{$dropdown-prefix-cls}-toggle,
.#{$input-prefix-cls}-group-btn:not(:first-child) > .#{$btn-prefix-cls}:not(:last-child):not(.#{$dropdown-prefix-cls}-toggle),
.#{$input-prefix-cls}-group-btn:not(:first-child) > .#{$btn-prefix-cls}-group:not(:last-child) > .btn {
  @include border-right-radius(0);
}
.#{$input-prefix-cls}-group-addon:not(:last-child) {
  border-right: 0;
}
.#{$input-prefix-cls}-group .#{$input-prefix-cls}-wrapper:not(:first-child) .#{$input-prefix-cls},
.#{$input-prefix-cls}-group-addon:not(:first-child),
.#{$input-prefix-cls}-group-btn:not(:first-child) > .#{$btn-prefix-cls},
.#{$input-prefix-cls}-group-btn:not(:first-child) > .#{$btn-prefix-cls}-group > .#{$btn-prefix-cls},
.#{$input-prefix-cls}-group-btn:not(:first-child) > .#{$dropdown-prefix-cls}-toggle,
.#{$input-prefix-cls}-group-btn:not(:last-child) > .#{$btn-prefix-cls}:not(:first-child),
.#{$input-prefix-cls}-group-btn:not(:last-child) > .#{$btn-prefix-cls}-group:not(:first-child) > .#{$btn-prefix-cls} {
  @include border-left-radius(0);
}
.#{$input-prefix-cls}-wrapper + .#{$input-prefix-cls}-group-addon:not(:first-child) {
  border-left: 0;
}


//
// Button input groups
//

.#{$input-prefix-cls}-group-btn {
  position: relative;
  // Jankily prevent input button groups from wrapping with `white-space` and
  // `font-size` in combination with `inline-block` on buttons.
  font-size: 0;
  white-space: nowrap;

  // Negative margin for spacing, position for bringing hovered/focused/actived
  // element above the siblings.
  > .#{$btn-prefix-cls} {
    position: relative;

    + .#{$btn-prefix-cls} {
      margin-left: (-$input-btn-border-width);
    }

    // Bring the "active" button to the front
    @include hover-focus-active {
      z-index: 3;
    }
  }

  // Negative margin to only have a single, shared border between the two
  &:not(:last-child) {
    > .#{$btn-prefix-cls},
    > .#{$btn-prefix-cls}-group {
      margin-right: (-$input-btn-border-width);
    }
  }
  &:not(:first-child) {
    > .#{$btn-prefix-cls},
    > .#{$btn-prefix-cls}-group {
      z-index: 2;
      margin-left: (-$input-btn-border-width);
      // Because specificity
      @include hover-focus-active {
        z-index: 3;
      }
    }
  }
  .#{$btn-prefix-cls}-secondary{
    background-color: $input-group-addon-bg;
  }
}
