/**Variable**/
%ButtonHover {
  color: lighten($vhb-primary-color, 6%);
  border-color: lighten($vhb-primary-color, 10%);
}

.vhb-form {
  position: relative;
  font-size: $vhb-font-size;
  color: $vhb-font-color;
  font-family: $vhb-font-family;
  background-color: $vhb-form-background-color;
  text-align: left;
}

.vhb-form-slots {
  display: none;
}

.vhb-form--item-content,
.vhb-form--item-trigger-node {
  display: inline-block;
  vertical-align: middle;
}

.vhb-form--item-title {
  display: flex;
  flex-direction: row;
  max-width: 320px;
  padding-right: 0.8em;
  &.is--ellipsis {
    .vhb-form--item-title-content {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  .vhb-form--item-title-prefix,
  .vhb-form--item-title-suffix,
  .vhb-form--item-title-postfix {
    flex-shrink: 0;
  }
  .vhb-form--item-title-prefix,
  .vhb-form--item-title-suffix {
    cursor: help;
    vertical-align: middle;
    & > i {
      vertical-align: middle;
    }
  }
  .vhb-form--item-title-prefix {
    margin-right: 0.25em;
  }
  .vhb-form--item-title-suffix {
    margin-left: 0.2em;
  }
  .vhb-form--item-title-postfix {
    display: flex;
    align-items: center;
  }
  .vhb-form--item-title-content {
    flex-grow: 1;
  }
  .vhb-form--item-title-label {
    vertical-align: middle;
  }
}

.vhb-form--item-trigger-node {
  font-size: 12px;
  min-width: 100px;
  color: #909399;
  text-align: center;
  user-select: none;
  cursor: pointer;
  .vhb-form--item-trigger-icon {
    margin: 0 0.25em;
    transition: all 0.1s;
  }
}

.vhb-form--item-valid {
  position: absolute;
  width: 100%;
  font-size: 12px;
  line-height: 1.2em;
  color: $vhb-form-validate-error-color;
  background-color: $vhb-form-validate-error-background-color;
  z-index: 1;
  opacity: 0;
  transform-origin: center top;
  transform: scaleY(0);
  transition: all 0.2s ease-in-out;
}

.vhb-form {
  .vhb-form--gather {
    display: inline-block;
  }
  .vhb-form--item {
    display: none;
    padding: 0.5em 0.8em 0.5em 0;
    &.is--active {
      &:not(.is--hidden) {
        display: inline-block;
      }
    }
  }
  &.is--asterisk {
    .vhb-form--item {
      &.is--required {
        .vhb-form--item-title-content {
          &:before {
            content: "*";
            color: $vhb-form-validate-error-color;
            font-family: Verdana,Arial,Tahoma;
            margin-right: 0.2em;
            font-weight: normal;
            vertical-align: middle;
          }
        }
      }
    }
  }
  &.is--colon {
    .vhb-form--item-title-postfix {
      &:after {
        content: ":";
        font-weight: normal;
        margin-left: 0.2em;
      }
    }
  }
}

.vhb-form--item {
  &.is--span {
    .vhb-default-input:not([type="submit"]):not([type="reset"]),
    .vhb-default-textarea,
    .vhb-default-select,
    .vhb-input,
    .vhb-textarea,
    .vhb-select {
      width: 100%;
    }
  }
  &.is--error {
    .vhb-input > .vhb-input--inner,
    .vhb-textarea > .vhb-textarea--inner,
    .vhb-select,
    .vhb-select.is--active > .vhb-input .vhb-input--inner,
    .vhb-default-input,
    .vhb-default-textarea,
    .vhb-default-select {
      border-color: $vhb-form-validate-error-color;
    }
    .vhb-input>.vhb-input--inner,
    .vhb-textarea>.vhb-textarea--inner,
    .vhb-default-input[type="text"],
    .vhb-default-input[type="search"],
    .vhb-default-textarea,
    .vhb-default-select {
      &:focus {
        border-color: $vhb-form-validate-error-color;
      }
    }
    .vhb-form--item-valid {
      opacity: 1;
      transform: scaleY(1);
    }
  }
  .vhb-form--item-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    .vhb-form--item-title {
      flex-shrink: 0;
    }
    .vhb-form--item-content {
      position: relative;
      flex-grow: 1;
    }
  }
  .vhb-default-input,
  .vhb-default-textarea,
  .vhb-default-select {
    outline: 0;
    border: 1px solid $vhb-input-border-color;
    border-radius: $vhb-border-radius;
  }
  .vhb-default-input,
  .vhb-default-select {
    height: $vhb-button-height-default;
  }
  .vhb-default-input {
    padding: 0 0.8em;
  }
  .vhb-default-textarea {
    padding: 0.3em 0.6em;
  }
  .vhb-default-input[type="number"] {
    padding-right: 0.2em;
  }
  .vhb-default-input[type="text"],
  .vhb-default-input[type="search"] {
    padding: 0 1em;
  }
  .vhb-default-input[type="text"],
  .vhb-default-input[type="search"],
  .vhb-default-textarea,
  .vhb-default-select {
    color: $vhb-font-color;
    &:focus {
      border: 1px solid $vhb-primary-color;
    }
    &[disabled] {
      cursor: not-allowed;
      background-color: $vhb-input-disabled-background-color;
    }
  }
  .vhb-default-input[type="submit"],
  .vhb-default-input[type="reset"] {
    line-height: $vhb-button-height-default - 2px;
    background-color: #fff;
    cursor: pointer;
    &:hover {
      @extend %ButtonHover;
    }
    &:active {
      color: darken($vhb-primary-color, 2%);
      border-color: darken($vhb-primary-color, 2%);
    }
  }
  .vhb-default-input {
    &[type="date"]::-webkit-inner-spin-button {
      margin-top: 6px;
    }
    &[type="date"]::-webkit-inner-spin-button,
    &[type="number"]::-webkit-inner-spin-button {
      height: 24px;
    }
    &::placeholder {
      color: $vhb-input-placeholder-color;
    }
  }
  .vhb-default-input[type="text"],
  .vhb-default-input[type="search"],
  .vhb-default-textarea,
  .vhb-default-select {
    width: 180px;
  }
  .vhb-default-textarea {
    resize: none;
    vertical-align: middle;
    &::placeholder {
      color: $vhb-input-placeholder-color;
    }
  }
}

.vhb-form {
  .vhb-form--item-inner {
    min-height: $vhb-form-item-min-height-default;
    & > .align--center {
      text-align: center;
    }
    & > .align--left {
      text-align: left;
    }
    & > .align--right {
      text-align: right;
    }
  }
  &.size--medium {
    font-size: $vhb-font-size-medium;
    .vhb-form--item-inner {
      min-height: $vhb-form-item-min-height-medium;
    }
    .vhb-default-input[type="submit"],
    .vhb-default-input[type="reset"] {
      line-height: $vhb-button-height-medium - 2px;
    }
    .vhb-default-input,
    .vhb-default-input,
    .vhb-default-select {
      height: $vhb-button-height-medium;
    }
  }
  &.size--small {
    font-size: $vhb-font-size-small;
    .vhb-form--item-inner {
      min-height: $vhb-form-item-min-height-small;
    }
    .vhb-default-input[type="submit"],
    .vhb-default-input[type="reset"] {
      line-height: $vhb-button-height-small - 2px;
    }
    .vhb-default-input,
    .vhb-default-input,
    .vhb-default-select {
      height: $vhb-button-height-small;
    }
  }
  &.size--mini {
    font-size: $vhb-font-size-mini;
    .vhb-form--item-inner {
      min-height: $vhb-form-item-min-height-mini;
    }
    .vhb-default-input[type="submit"],
    .vhb-default-input[type="reset"] {
      line-height: $vhb-button-height-mini - 2px;
    }
    .vhb-default-input,
    .vhb-default-input,
    .vhb-default-select {
      height: $vhb-button-height-mini;
    }
  }
}