.control {
  display: flex;
  flex-direction: column;

  &.control--align-right {
    display: flex;
    justify-content: right;
  }

  &.control--horizontal {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;

    &.control--messages {
      align-items: flex-start;
    }
  }
}

.control--error {
  .form-input,
  .dropdown__selected,
  .form-textarea {
    border-color: $palette-red-600;
  }

  .form-input__icon {
    color: $palette-red-600;
  }
}

.control__elements--flex {
  display: flex;
  align-items: center;
  gap: 5px;
}

.control__elements-wrapper {
  flex-grow: 1;
  max-width: 100%;
}

.control__description {
  font-size: 13px;
  line-height: 160%;
  color: $palette-neutral-800;
  margin-bottom: 16px;
}

.control__label {
  display: flex;
  font-size: 16px;
  font-weight: 500;
  color: $palette-neutral-1300;
  margin-bottom: 8px;
  align-items: center;
  gap: 5px;

  &.control__label--small {
    font-size: 13px;
  }

  .control--horizontal & {
    flex-basis: 30%;
    font-weight: 500;
    margin: 0;
  }

  .control--horizontal-narrow & {
    flex-basis: 40%;
  }

  .control--horizontal-variable & {
    flex: auto 0 0;
    font-weight: 500;
    margin: 0;
  }
}

.control__wrapper {
  display: flex;
  flex-direction: column;

  .control--horizontal & {
    flex-basis: 100%;
  }

  .control--horizontal.control--after-input & {
    max-width: calc(70% - 5px);
    flex-basis: 70%;
    margin-top: 0;
  }

  .control--horizontal-narrow.control--after-input & {
    max-width: calc(60% - 5px);
    flex-basis: 60%;
    margin-top: 0;
  }
}

.control__label-icon {
  margin-right: 6px;
}

.control__label-right-icon {
  height: 16px;
  position: relative;
}

.control__context {
  color: $palette-neutral-1100;
  margin-left: 6px;

  &:hover {
    text-decoration: none;
    color: $palette-neutral-500;
  }
}

.error {
  font-size: 12px;
  margin-top: 6px;
  color: $palette-red-800;
}

.warning {
  margin-top: 6px;
  color: $palette-yellow-600;
}

.actions {
  @extend %first-last-no-margin;

  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin: 30px 0;

  > div {
    width: 100%;
  }

  &.actions--right {
    justify-content: right;
  }
}

.action__links {
  list-style: none;
  margin: 0;
  padding: 0;

  li {
    display: inline;
    margin-right: 20px;
    white-space: nowrap;

    &:last-child {
      margin-right: 0;
    }
  }
}

.control__after-label {
  margin-left: auto;
  font-size: 12px;
}

.control__required {
  margin-left: auto;
  color: $palette-neutral-900;
  font-size: 13px;
  font-weight: normal;

  .control--horizontal & {
    display: none;
  }
}

.control__label-after {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
}

.control__messages {
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  color: $palette-neutral-1100;

  p {
    margin: 0;
  }
}

.control__messages--error {
  margin: 0;
  color: $palette-red-800;
  white-space: wrap;

  @include flex-align-items(3px);
}

.control__messages--warning {
  margin: 0;
  color: $palette-yellow-600;

  @include flex-align-items(3px);
}

.form-section {
  border-bottom: 1px solid $color-neutral-200;
  padding-bottom: 15px;
  margin-bottom: 15px;

  // If we have an horizontal FormGroup
  // these labels should be grayer for better effect.
  & .control--horizontal .control__label {
    color: $color-neutral-700;
  }

  &:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border: none;
  }
}

.form-section__title {
  font-size: 13px;
  font-weight: 500;
}

.form-section__title-container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
