@use '../styles/variables' as *;

@mixin inputFieldDisabled {
  border: 0;
  box-shadow: none;
  color: $main-color;
  background-color: $muted-background-color;
}

@mixin inputField {
  align-items: center;
  border: 1px solid #868e96;
  box-shadow: none;
  display: inline-flex;
  font-size: 1rem;
  height: 2.5em;
  justify-content: flex-start;
  line-height: 1.5;
  padding: calc(0.5em - 1px) calc(0.75em - 1px);
  position: relative;
  vertical-align: top;
  width: 100%;
}

.error {
  label {
    color: $error-color;
  }
  input {
    border: 1px solid $error-color !important;
  }
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.fieldLabel {
  font-weight: 600;
  padding-bottom: 0.25em;

  &[for] {
    cursor: pointer;
  }
}

.field {
  display: flex;
  align-items: flex-start;
  flex-direction: column;

  > label {
    @extend .fieldLabel;
  }

  input,
  textarea {
    @include inputField;
    height: auto;
  }

  input[type='color'] {
    height: 2.5em;
  }

  :global {
    .control {
      align-self: center;
      box-sizing: border-box;
      clear: both;
      font-size: 1rem;
      position: relative;
      text-align: inherit;
      width: 100%;
      word-break: break-word;
    }

    .control.has-icons-left .input {
      padding-left: 2.5em;
    }

    .icon {
      left: 0;
      color: #898989;
      height: 2.5em;
      pointer-events: none;
      position: absolute;
      top: 0;
      width: 2.5em;
      z-index: 4;
      align-items: center;
      display: inline-flex;
      justify-content: center;
    }
  }
}

.mandatoryHelper {
  margin-left: 0.25em;

  &::before {
    content: '(' / '';
  }

  &::after {
    content: ')' / '';
  }
}

.textEditor {
  border: 1px solid $main-color;

  .margin-view-overlays {
    display: none;
  }
}

.footer {
  margin: 1rem 0 0;
}

.inlineFields {
  display: flex;
  gap: 0.5rem;

  > * {
    flex: 0 0 auto;
  }
}

.fullWidth {
  flex: 1 0 auto;

  :global {
    .input {
      width: 100%;
    }
  }
}

.combobox {
  position: relative;

  > label {
    cursor: pointer;
  }
}

.comboboxController {
  position: relative;
}

.autocompleteField input {
  padding-right: 6.25rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comboboxControllerActions {
  position: absolute;
  right: 0;
  top: 0;
}
/* (without label) .field border-top-width  */
.combobox > label:empty ~ * .comboboxControllerActions {
  top: 1px;
}

.comboboxGroup {
  /*
    because we cannot add padding on generated content,
    we add to the container (padding-top) and the first child (margin-top)
  */
  &[data-label]:not([data-label='']) {
    padding-top: 1em;

    &:before {
      content: attr(data-label);
      height: 2em;
      font-weight: 500;
      padding: 0 0.5em;
    }

    > li {
      &:first-of-type {
        margin-top: 0.5em;
      }

      padding-left: 1.5em;
    }
  }
}

.comboboxResults:not(:empty) {
  background-color: #fff;
  border: 1px solid black;
  padding: 0;
  position: absolute;
  width: 100%;
  z-index: 900;
  max-height: min(30cqh, 20rem);
  overflow-y: auto;
}

.comboboxItem {
  cursor: pointer;
  padding: 0.5em 1em;
}

.comboboxHighlightedItem {
  background-color: rgba(0, 0, 0, 0.2);
}
