@use "../../variables/index" as *;

@mixin box-sizing($type) {
  box-sizing: $type;
}

// Form validation states
// Used to generate the form validation CSS for warnings, errors, and successes.
@mixin form-control-validation($text-color: #555, $border-color: #ccc, $background-color: #f5f5f5) {
  // Color the label and help text
  .help-block,
  .control-label,
  .radio,
  .checkbox,
  .radio-inline,
  .checkbox-inline,
  &.radio label,
  &.checkbox label,
  &.radio-inline label,
  &.checkbox-inline label {
    color: $text-color!important;
  }
  // Set the border and box shadow on specific inputs to match
  .form-control {
    box-shadow: inset 1px 0 0 0 $form-control-border-color-default,
      inset -1px 0 0 0 $form-control-border-color-default,
      inset 0 1px 0 0 $form-control-border-color-default, inset 0 -4px 0 $border-color!important;
    &:focus {
      color: $text-color;
      box-shadow: inset 2px 0 0 0 $form-control-border-color-focus,
        inset -2px 0 0 0 $form-control-border-color-focus,
        inset 0 2px 0 0 $form-control-border-color-focus, inset 0 -4px 0 $border-color!important;
    }
  }
  // validation states for radio and checkboxes
  label.c8y-checkbox,
  label.c8y-radio {
    input + span:before {
      box-shadow: inset 0 0 0 2px $border-color;
    }
    &:focus input + span::before,
    input:focus + span::before {
      box-shadow: inset 0 0 0 2px $form-control-border-color-focus;
    }
  }
  // Set validation states also for addons
  .input-group-addon {
    color: white;
    border-color: $border-color;
    background-color: $border-color;
  }

  // Optional feedback icon
  .form-control-feedback-message:before {
    color: $border-color;
  }
}

// Form control focus state
//
// Generate a customized focus state and for any input with the specified color,
// which defaults to the `$form-control-border-color-focus` variable.
//
// We highly encourage you to not customize the default value, but instead use
// this to tweak colors on an as-needed basis. This aesthetic change is based on
// WebKit's default styles, but applicable to a wider range of browsers. Its
// usability and accessibility should be taken into account with any change.
//
// Example usage: change the default blue border and shadow to white for better
// contrast against a dark gray background.
@mixin form-control-focus($border: $form-control-border-color-focus, $bg: $form-control-background-focus, $color: $form-control-color-focus) {
  &:focus {
    border-color: $border;
    outline: 0;
    box-shadow: inset 0 0 0 2px $border;
    background-color: $bg;
    color: $color;
  }
}

// Form control sizing
//
// Relative text size, padding, and border-radii changes for form controls. For
// horizontal sizing, wrap controls in the predefined grid classes. `<select>`
// element gets special love because it's special, and that's a fact!
@mixin input-size($input-height, $padding-vertical, $padding-horizontal, $font-size, $line-height, $border-radius) {
  height: $input-height;
  padding: $padding-vertical $padding-horizontal;
  font-size: $font-size;
  line-height: $line-height;
  border-radius: $border-radius;

  select& {
    height: $input-height;
    line-height: $input-height;
  }

  textarea&,
  select[multiple]& {
    height: auto;
  }
}

// Placeholder text
@mixin placeholder($color: $form-control-placeholder-color,$font-style: $form-control-placeholder-font-style) {
  // Firefox
  &::-moz-placeholder {
    color: $color;
    opacity: 1; // Override Firefox's unusual default opacity,see https://github.com/twbs/bootstrap/pull/11526
    font-style: $font-style;
  }
  // Internet Explorer 10+
  &:-ms-input-placeholder {
    color: $color;
    font-style: $font-style;
  }
  // Safari and Chrome
  &::-webkit-input-placeholder {
    color: $color;
    font-style: $font-style;
  }
}
