// Lightning Design System 2.8.0
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license

@mixin form-input-container {
  background-color: $color-background-input;
  border: $border-width-thin solid $color-border-input;
  border-radius: $border-radius-medium;
  width: 100%;
}

@mixin form-input-focus {
  outline: 0;
  border-color: $color-border-input-active;
  background-color: $color-background-input-active;
  box-shadow: $shadow-button-focus;
}

@mixin form-input-disabled {
  background-color: $color-background-input-disabled;
  border-color: $color-border-input-disabled;
  cursor: not-allowed;
  user-select: none;

  &:focus,
  &:active {
    box-shadow: none;
  }
}

@mixin form-element-vertical-spacing {
  margin-top: $spacing-small;

  @include mq-small-min {
    margin-top: $spacing-x-small;
  }
}

@mixin form-element-required($element: null) {
  @if $element != null {

    > #{$element}:before {
      content: '*';
      color: $color-text-error;
      position: absolute;
      left: ($spacing-x-small * -1);
    }
  }
}

@mixin form-input-error($element: null) {
  @if $element != null {

    #{$element} {
      background-color: $color-background-input;
      border-color: $color-border-error;
      box-shadow: $color-border-error 0 0 0 $border-width-thin inset;
      background-clip: padding-box;

      &:focus,
      &:active {
        box-shadow: $color-border-error 0 0 0 $border-width-thin inset, $shadow-button-focus;
      }
    }
  }
}

@mixin form-states {
  @include form-input-container;
  transition: border $duration-quickly linear, background-color $duration-quickly linear;

  &:required {
    box-shadow: none;
  }

  &:focus,
  &:active {
    @include form-input-focus;
  }

  &[disabled],
  &.slds-is-disabled {
    @include form-input-disabled;
  }
}
