.ui-field {
  align-content: start;
  display: grid;
  flex: 1 1 8rem;
  grid-auto-flow: row;
  line-height: 1;
  margin: var(--gutter);
  min-width: 1rem;
  padding: 5px 0;

  $base: unquote(".ui-field");

  &--inline {
    @include min-breakpoint(md) {
      --min-width: 1rem;
      grid-template-columns: auto minmax(var(--min-width), 100%);

      #{$base}__label {
        justify-self: end;
        padding: 0.75rem 0.25rem 0.25rem;
      }

      .ui-input,
      .ui-input__info,
      #{$base}__wrapper {
        grid-column: 2;
      }
    }
  }

  &--hint {
    display: inline;

    label {
      display: inline !important;

      span:last-child {
        padding: 0;
      }
    }

    .ui-field__hint-icon {
      cursor: pointer;

      ui-icon {
        color: #949fb3;
        margin-bottom: 2px;
      }
    }
  }

  &--required &__label {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  &--nolabel &__label {
    display: none;
  }

  &__label {
    width: 100%;
    display: inline-grid;
    font-size: 14px;
    justify-self: start;
    padding: 0.25rem;
    position: relative;

    span:first-child {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    span:last-child {
      padding: 0 2px;
      display: inline-block;
      font-family: serif;
    }
  }

  &--label-multi-line &__label {
    display: block;

    > span:first-child {
      width: initial;
      overflow: initial;
      text-overflow: initial;
      white-space: initial;
    }
  }

  &__wrapper {
    display: flex;
    flex-flow: row nowrap;
    grid-column: 1;
    min-height: 2rem;
    position: relative;
    transition: width 0.5s;
    border: solid;
    border-width: 1px;
    border-radius: $ui-input-border-radius;
    border-top-right-radius: $ui-input-border-radius;
    border-bottom-right-radius: $ui-input-border-radius;
    &--readonly {
      border: none !important;
      border-bottom: solid 1px $gray-50 !important;
      border-radius: 0;
      > ui-dropdown {
        background-color: $black-4 !important;
      }
      > ui-textarea {
        border-radius: 0;
      }
    }
    &--disabled {
      > ui-dropdown,
      > div {
        background-color: $black-4 !important;
        cursor: not-allowed;
        border-top-right-radius: 0.3rem;
        border-bottom-right-radius: 0.3rem;
      }
    }

    > .ui-btn__wrapper {
      align-self: stretch;
      font-size: 0.8em;
      margin: 0;

      &:first-child .ui-btn {
        border-bottom-right-radius: 0;
        border-top-right-radius: 0;
      }

      &:last-child .ui-btn {
        border-bottom-left-radius: 0;
        border-top-left-radius: 0;
      }
    }

    .ui-input {
      border-top: none;
      border-bottom: none;

      &:not(:first-child) {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        border-right: none;
      }

      &:first-child {
        border-left: none;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
      }
    }
  }

  &--plain &__wrapper,
  &--plain {
    .ui-input {
      input,
      textarea {
        cursor: default;
        height: auto;
        resize: none;
      }

      &::after {
        display: none;
      }

      &__counter,
      &__error,
      &__clear {
        display: none;
      }
    }

    .ui-dropdown {
      .ui-menu__item__caret {
        visibility: hidden;
      }
    }
  }

  & > &__wrapper + &__wrapper,
  & > &__wrapper + .ui-input,
  & > .ui-input + &__wrapper,
  & > .ui-input + .ui-input {
    margin-top: 1px;
  }
}

ui-field[no-label] > label {
  display: none;
}

ui-field-wrapper {
  &.readonly {
    padding-left: 0px;
    background-color: transparent !important;
    box-shadow: none !important;
    border-color: transparent !important;

    & > .ui-input__clear {
      display: none;
    }

    &::after {
      display: none;
    }

    &::before {
      content: "";
      cursor: default;
      background-color: transparent !important;
    }
  }
}
