// Copyright 2017 Palantir Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0.

@import "../../common/variables";
@import "../../common/mixins";
@import "common";

.#{$ns}-form-group {
  display: flex;
  flex-direction: column;
  margin: 0 0 ($pt-spacing * 4);

  label.#{$ns}-label {
    margin-bottom: $pt-spacing;
  }

  .#{$ns}-control {
    margin-top: $pt-spacing * 2;
  }

  .#{$ns}-form-group-sub-label,
  .#{$ns}-form-helper-text {
    color: $pt-text-color-muted;
    font-size: $pt-font-size-small;
  }

  .#{$ns}-form-group-sub-label {
    margin-bottom: $pt-spacing;
  }

  .#{$ns}-form-helper-text {
    margin-top: $pt-spacing;
  }

  /* stylelint-disable-next-line order/declaration-block-order */
  @each $intent, $color in $pt-intent-text-colors {
    &.#{$ns}-intent-#{$intent} {
      .#{$ns}-form-helper-text {
        color: $color;
      }
    }
  }

  &.#{$ns}-fill {
    width: 100%;
  }

  &.#{$ns}-inline {
    align-items: flex-start;
    flex-direction: row;

    &.#{$ns}-large label.#{$ns}-label {
      line-height: $pt-input-height-large;
      margin: 0 ($pt-spacing * 3) 0 0;
    }

    label.#{$ns}-label {
      line-height: $pt-input-height;
      margin: 0 ($pt-spacing * 3) 0 0;
    }
  }

  &.#{$ns}-disabled {
    .#{$ns}-label,
    .#{$ns}-text-muted,
    .#{$ns}-form-group-sub-label,
    .#{$ns}-form-helper-text {
      // disabled state always overrides over styles
      /* stylelint-disable-next-line declaration-no-important */
      color: $pt-text-color-disabled !important;
    }
  }

  .#{$ns}-dark & {
    @each $intent, $color in $pt-dark-intent-text-colors {
      &.#{$ns}-intent-#{$intent} {
        .#{$ns}-form-helper-text {
          color: $color;
        }
      }
    }

    .#{$ns}-form-group-sub-label,
    .#{$ns}-form-helper-text {
      color: $pt-dark-text-color-muted;
    }

    &.#{$ns}-disabled {
      .#{$ns}-label,
      .#{$ns}-text-muted,
      .#{$ns}-form-group-sub-label,
      .#{$ns}-form-helper-text {
        // disabled state always overrides over styles
        /* stylelint-disable-next-line declaration-no-important */
        color: $pt-dark-text-color-disabled !important;
      }
    }
  }
}
