//
// Input groups
// --------------------------------------------------

// Base styles
// -------------------------
.ai1ec-input-group {
  position: relative; // For dropdowns
  display: table;
  border-collapse: separate; // prevent input groups from inheriting border styles from table cells when placed within a table

  // Undo padding and float of grid classes
  &[class*="col-"] {
    float: none;
    padding-left: 0;
    padding-right: 0;
  }

  .ai1ec-form-control {
    width: 100%;
    margin-bottom: 0;
  }
}

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

.ai1ec-input-group-lg > .ai1ec-form-control,
.ai1ec-input-group-lg > .ai1ec-input-group-addon,
.ai1ec-input-group-lg > .ai1ec-input-group-btn > .ai1ec-btn { .ai1ec-input-lg(); }
.ai1ec-input-group-sm > .ai1ec-form-control,
.ai1ec-input-group-sm > .ai1ec-input-group-addon,
.ai1ec-input-group-sm > .ai1ec-input-group-btn > .ai1ec-btn { .ai1ec-input-sm(); }


// Display as table-cell
// -------------------------
.ai1ec-input-group-addon,
.ai1ec-input-group-btn,
.ai1ec-input-group .ai1ec-form-control {
  display: table-cell;

  &:not(:first-child):not(:last-child) {
    border-radius: 0;
  }
}
// Addon and addon wrapper for buttons
.ai1ec-input-group-addon,
.ai1ec-input-group-btn {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle; // Match the inputs
}

// Text input groups
// -------------------------
.ai1ec-input-group-addon {
  padding: @padding-base-vertical @padding-base-horizontal;
  font-size: @font-size-base;
  font-weight: normal;
  line-height: 1;
  color: @input-color;
  text-align: center;
  background-color: @input-group-addon-bg;
  border: 1px solid @input-group-addon-border-color;
  border-radius: @border-radius-base;

  // Sizing
  &.ai1ec-input-sm {
    padding: @padding-small-vertical @padding-small-horizontal;
    font-size: @font-size-small;
    border-radius: @border-radius-small;
  }
  &.ai1ec-input-lg {
    padding: @padding-large-vertical @padding-large-horizontal;
    font-size: @font-size-large;
    border-radius: @border-radius-large;
  }

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

// Reset rounded corners
.ai1ec-input-group .ai1ec-form-control:first-child,
.ai1ec-input-group-addon:first-child,
.ai1ec-input-group-btn:first-child > .ai1ec-btn,
.ai1ec-input-group-btn:first-child > .ai1ec-dropdown-toggle,
.ai1ec-input-group-btn:last-child > .ai1ec-btn:not(:last-child):not(.ai1ec-dropdown-toggle) {
  .ai1ec-border-right-radius(0);
}
.ai1ec-input-group-addon:first-child {
  border-right: 0;
}
.ai1ec-input-group .ai1ec-form-control:last-child,
.ai1ec-input-group-addon:last-child,
.ai1ec-input-group-btn:last-child > .ai1ec-btn,
.ai1ec-input-group-btn:last-child > .ai1ec-dropdown-toggle,
.ai1ec-input-group-btn:first-child > .ai1ec-btn:not(:first-child) {
  .ai1ec-border-left-radius(0);
}
.ai1ec-input-group-addon:last-child {
  border-left: 0;
}

// Button input groups
// -------------------------
.ai1ec-input-group-btn {
  position: relative;
  white-space: nowrap;

  // Negative margin to only have a 1px border between the two
  &:first-child > .ai1ec-btn {
    margin-right: -1px;
  }
  &:last-child > .ai1ec-btn {
    margin-left: -1px;
  }
}
.ai1ec-input-group-btn > .ai1ec-btn {
  position: relative;
  // Jankily prevent input button groups from wrapping
  + .ai1ec-btn {
    margin-left: -4px;
  }
  // Bring the "active" button to the front
  &:hover,
  &:active {
    z-index: 2;
  }
}
