//
// Base styles
//

.input-group {
  > .form-control,
  > .form-select {
    width: 1%;
  }

  // Bring the "active" form control to the top of surrounding elements
  > .form-control:focus,
  > .form-select:focus {
    z-index: 3;
  }

  .btn {
    position: relative;
    z-index: 2;

    &:focus {
      z-index: 3;
    }
  }
}

.input-group-lg > .form-select,
.input-group-sm > .form-select {
  padding-right: $form-select-padding-x + $form-select-indicator-padding;
}

// Rounded corners
//
// These rulesets must come after the sizing ones to properly override sm and lg
// border-radius values when extending. They're more specific than we'd like
// with the `.input-group >` part, but without it, we cannot override the sizing.

// stylelint-disable-next-line no-duplicate-selectors
.input-group {
  &:not(.has-validation) {
    > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu),
    > .dropdown-toggle:nth-last-child(n + 3) {
      @include border-end-radius(0);
    }
  }

  &.has-validation {
    > :nth-last-child(n + 3):not(.dropdown-toggle):not(.dropdown-menu),
    > .dropdown-toggle:nth-last-child(n + 4) {
      @include border-end-radius(0);
    }
  }

  $validation-messages: '';
  @each $state in map-keys($form-validation-states) {
    $validation-messages: $validation-messages +
      ':not(.' +
      unquote($state) +
      '-tooltip)' +
      ':not(.' +
      unquote($state) +
      '-feedback)';
  }

  > :not(:first-child):not(.dropdown-menu)#{$validation-messages} {
    margin-left: -$input-border-width;
    @include border-start-radius(0);
  }
}
