.control {
  margin-bottom: 20px;

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

  &.control--horizontal,
  &.control--horizontal-variable {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
}

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

.control__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  @include flex-align-items(3px);

  & + :not(.control__description) {
    margin-top: 16px;
  }

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

    & + :not(.control__description) {
      margin-top: 4px;
    }
  }

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

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

.control__label-icon {
  font-size: 16px;
}

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

.control__elements {
  .control--horizontal & {
    flex-basis: 70%;
    margin-top: 0;
  }

  .control--horizontal-variable & {
    margin-top: 0;
    margin-left: 16px;
  }

  &.control__elements--small {
    margin-bottom: 16px;
  }
}

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

.control__context {
  cursor: pointer;
  color: $color-neutral-900;
  font-size: 16px;

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

.input {
  appearance: none;
  display: block;
  width: 100%;
  border: 1px solid $palette-neutral-400;
  padding: 12px 16px;
  outline: none;
  line-height: 100%;
  height: 44px;
  box-sizing: border-box;
  @include add-elevation($elevation-low);

  &::placeholder {
    color: $palette-neutral-700;
  }

  @include rounded($rounded-md);

  &:active,
  &:focus {
    border-color: $palette-blue-500;
  }

  &.input--error {
    border-color: $palette-red-600;
  }

  &.input--monospace {
    font-family: monospace;
  }

  &.input--small {
    height: 36px;
    padding: 8px 12px;
  }

  &.input--invisible {
    color: $white;
  }

  &[disabled] {
    color: $palette-neutral-700;
    box-shadow: none;
    background-color: $palette-neutral-100;
  }
}

.textarea--modal {
  resize: vertical;
  height: 22px * 6;
  line-height: 22px;
  font-size: 13px;
}

.input__with-icon {
  position: relative;

  .input {
    padding-right: 32px;
  }

  i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: $color-neutral-500;
    font-size: 16px;
  }

  &.input__with-icon--left {
    .input {
      padding-left: 32px;
      padding-right: 8px;
    }

    i {
      right: auto;
      left: 12px;
    }
  }

  &.input__with-icon--loading {
    &::after {
      content: ' ';
      margin-top: -7px;

      @include loading(14px);
      @include absolute(50%, 10px, auto, auto);
    }

    i {
      display: none;
    }

    &.input__with-icon--left::after {
      left: 10px;
      right: auto;
    }
  }
}

.radio {
  display: flex;
  align-items: center;
  cursor: pointer;
  height: 28px;
  line-height: 28px;
}

.radio__label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;

  .radio.radio--disabled & {
    color: $color-neutral-700;
  }

  *[class^='iconoir-'],
  *[class*=' iconoir-'],
  *[class^='baserow-icon-'],
  *[class*=' baserow-icon-'] {
    font-size: 14px;
  }
}

.radio__input {
  position: relative;
  width: 16px;
  height: 16px;
  margin-right: 8px;
}

.radio__input input[type='radio'] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.radio__input label {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #fff;
  border: 1px solid $color-neutral-600;
  box-shadow: 0 1px 2px 0 rgba(7, 8, 16, 0.1);
  cursor: pointer;
}

.radio--error {
  .radio__input label {
    border: 1px solid $palette-red-600;
  }
}

.radio__input input[type='radio']:disabled + label {
  background-color: $palette-neutral-100;
  box-shadow: none;
}

.radio__input input[type='radio']:checked + label {
  // The filling color is hard coded here. we cannot set to $palette-blue-500 because of interpolation issue within a background-image property.
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"><rect width="16" height="16" rx="8" fill="%235190ef"/><circle cx="8" cy="8" r="3" fill="white"/></svg>');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  border: none;
}

.radio__input input[type='radio']:checked + label:hover {
  // The filling color is hard coded here. we cannot set to $palette-blue-500 because of interpolation issue within a background-image property.
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"><rect width="16" height="16" rx="8" fill="%234783db"/><circle cx="8" cy="8" r="3" fill="white"/></svg>');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  border: none;
}

.radio__input input[type='radio']:disabled:checked + label {
  // The filling color is hard coded here. we cannot set to $palette-blue-500 because of interpolation issue within a background-image property.
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"><rect width="16" height="16" rx="8" fill="%23CDCECF"/><circle cx="8" cy="8" r="3" fill="white"/></svg>');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  border: none;
}

.radio__loading {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  position: relative;
  cursor: wait;
  user-select: none;

  &:hover,
  &:focus {
    box-shadow: none;
  }

  &::after {
    content: ' ';
    position: absolute;
    left: 50%;
    top: 50%;
    margin: -7px;
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 0.2em solid;
    border-color: $palette-blue-500 transparent $palette-blue-500 transparent;
    animation: spin infinite 1800ms;
    animation-timing-function: cubic-bezier(0.785, 0.135, 0.15, 0.86);
  }
}

.radio__input .radio__loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #007bff;
  border-top-color: transparent;
  animation: radio__loading 0.5s linear infinite;
}

.error {
  margin-top: 14px;
  color: $palette-red-800;
  font-size: 12px;
  @include flex-align-items(4px);
}

.warning {
  margin-top: 14px;
  color: $color-warning-600;
  font-size: 12px;
}

.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;
    }
  }
}
