@import '../style/core/layout';
@import '../style/theme/color';
@import '../style/core/_font';

.devui-form-horizontal :host.devui-form-controls {
  flex: 1 1 auto;
  margin-left: $element-spacing;
}

.devui-form-vertical :host.devui-form-controls {
  flex: 1 1 auto;
}

.devui-form-columns :host.devui-form-controls {
  flex: 1 1 auto;
  margin-right: $component-space;
}

.devui-form-control-extra-info {
  font-size: $devui-font-size;
  color: $devui-aide-text;
  min-height: 20px;
  line-height: 1.5;
  text-align: justify;
}

.devui-form-control-inner-content {
  line-height: 1;
}

.devui-form-message {
  display: inline-block;
  font-size: $devui-font-size;
  min-height: 20px;
  position: relative;
  left: 1px;
  color: $devui-danger;

  .devui-form-message-text {
    display: inline-flex;
    align-items: center;
    line-height: 1.5;
    border-top: 1px solid transparent;
    border-bottom: 1px solid transparent;

    .devui-form-message-svg {
      line-height: 1;
    }
  }

  .devui-icon.devui-icon-error {
    margin-right: 4px;
  }

  .devui-icon.devui-icon-error > g {
    & > path {
      fill: $devui-danger;
    }

    & > circle {
      fill: $devui-light-text;
    }
  }
}

.devui-form-item-icon {
  position: absolute;
  top: 50%;
  right: 0;
  z-index: 1;
  width: 32px;
  height: 16px;
  text-align: center;
  visibility: visible;
  pointer-events: none;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;

  &.devui-form-item-icon-error {
    svg circle {
      fill: $devui-danger;
    }

    svg polygon {
      fill: $devui-base-bg;
    }
  }

  &.devui-form-item-icon-success {
    svg circle {
      fill: $devui-success;
    }

    svg polygon {
      fill: $devui-base-bg;
    }
  }

  &.devui-form-item-icon-pending {
    svg {
      animation: devui-loading-keyframes 1s infinite linear;
    }

    svg path {
      fill: $devui-brand;
    }
  }
}

:host.devui-form-control-has-feedback,
:host.devui-form-control-has-suffix {
  .devui-form-control-container {
    position: relative;
  }
}

:host.devui-form-control-has-suffix {
  .devui-form-item-suffix {
    position: absolute;
    top: 50%;
    right: 0;
    z-index: 1;
    width: 32px;
    height: 16px;
    text-align: center;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .suffix {
    cursor: pointer;
  }
}

:host.devui-form-control-has-feedback.devui-form-control-has-suffix {
  .devui-form-item-icon {
    right: 32px;
  }
}

@keyframes devui-loading-keyframes {
  from {
    transform: rotateZ(0deg);
  }

  to {
    transform: rotateZ(360deg);
  }
}
