@import "variables";


label {
  // margin-top: 0.5rem;
}

//
// Checkboxes
// --------------------------------------------------

$font-family-icon: 'Font Awesome 5 Pro' !default;
$fa-var-check: "\f00c" !default;
$check-icon: $fa-var-check !default;
$form-check-input-gutter: 20px;
$input-border-color: $gray-200;

@mixin checkbox-variant($parent, $color) {
  #{$parent} input[type="checkbox"]:checked + label,
  #{$parent} input[type="radio"]:checked + label {
    &::before {
      background-color: $color;
      border-color: $color;
    }
    &::after{
      color: #fff;
    }
  }
}

@mixin checkbox-variant-indeterminate($parent, $color) {
  #{$parent} input[type="checkbox"]:indeterminate + label,
  #{$parent} input[type="radio"]:indeterminate + label {
    &::before {
      background-color: $color;
      border-color: $color;
    }
    &::after{
      background-color: #fff;
    }
  }
}

.abc-checkbox{
  cursor: default;
  padding-left: 4px;

  label{
    cursor: pointer;
    display: inline;
    vertical-align: top;
    position: relative;
    padding-left: 5px;

    &::before{
      cursor: pointer;
      content: "";
      display: inline-block;
      position: absolute;
      width: 17px;
      height: 17px;
      top: 2px;
      left: 0;
      margin-left: -$form-check-input-gutter;
      border: 1px solid $input-border-color;
      border-radius: 3px;
      background-color: #fff;
      transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
    }

    &::after{
      cursor: pointer;
      display: inline-block;
      position: absolute;
      width: 16px;
      height: 16px;
      left: 0;
      top: 2px;
      margin-left: -$form-check-input-gutter;
      padding-left: 3px;
      padding-top: 1px;
      font-size: 11px;
      color: $gray-600;
    }
  }

  input[type="checkbox"],
  input[type="radio"] {
    position: static;
    margin-left: 0;
    cursor: pointer;
    opacity: 0;
    z-index: 1;

    &:focus + label::before{
      outline: thin dotted;
      outline: 5px auto -webkit-focus-ring-color;
      outline-offset: -2px;
    }

    &:checked + label::after{
      font-family: $font-family-icon;
      content: $check-icon;
    }

    &:indeterminate + label::after{
      display: block;
      content: "";
      width: 10px;
      height: 3px;
      background-color: #555555;
      border-radius: 2px;
      margin-left: -16.5px;
      margin-top: 7px;
    }

    &:disabled + label{
      opacity: 0.65;

      &::before{
        background-color: $gray-600;
        cursor: not-allowed;
      }

      &::after{
        cursor: not-allowed;
      }
    }

  }

  &.abc-checkbox-circle label::before{
    border-radius: 50%;
  }

  &.checkbox-inline{
    margin-top: 0;
  }
}

@include checkbox-variant('.abc-checkbox-primary', $primary);
@include checkbox-variant('.abc-checkbox-danger', $red);
@include checkbox-variant('.abc-checkbox-info', $blue);
@include checkbox-variant('.abc-checkbox-warning', $orange);
@include checkbox-variant('.abc-checkbox-success', $green);


@include checkbox-variant-indeterminate('.abc-checkbox-primary', $primary);
@include checkbox-variant-indeterminate('.abc-checkbox-danger', $red);
@include checkbox-variant-indeterminate('.abc-checkbox-info', $blue);
@include checkbox-variant-indeterminate('.abc-checkbox-warning', $orange);
@include checkbox-variant-indeterminate('.abc-checkbox-success', $green);

//
// Radios
// --------------------------------------------------

@mixin radio-variant($parent, $color) {
  #{$parent} input[type="radio"]{
    + label{
      &::after{
        background-color: $color;
      }
    }
    &:checked + label{
      &::before {
        border-color: $color;
      }
      &::after{
        background-color: $color;
      }
    }
  }
}

.abc-radio{
  cursor: default;
  padding-left: 4px;

  label{
    cursor: pointer;
    display: inline;
    vertical-align: top;
    position: relative;
    padding-left: 5px;

    &::before{
      cursor: pointer;
      content: "";
      display: inline-block;
      position: absolute;
      width: 17px;
      height: 17px;
      top: 2px;
      left: 0;
      margin-left: -20px;
      border: 1px solid $input-border-color;
      border-radius: 50%;
      background-color: #fff;
      transition: border 0.15s ease-in-out;
    }

    &::after{
      cursor: pointer;
      display: inline-block;
      position: absolute;
      content: " ";
      width: 11px;
      height: 11px;
      left: 3px;
      top: 5px;
      margin-left: -20px;
      border-radius: 50%;
      background-color: $gray-600;
      transform: scale(0, 0);

      transition: transform .1s cubic-bezier(.8,-0.33,.2,1.33);
      //curve - http://cubic-bezier.com/#.8,-0.33,.2,1.33
    }
  }

  input[type="radio"]{
    position: static;
    margin-left: 0;
    cursor: pointer;
    opacity: 0;
    z-index: 1;

    &:focus + label::before{
      outline: thin dotted;
      outline: 5px auto -webkit-focus-ring-color;
      outline-offset: -2px;
    }

    &:checked + label::after{
      transform: scale(1, 1);
    }

    &:disabled + label{
      opacity: 0.65;

      &::before{
        cursor: not-allowed;
      }

      &::after{
        cursor: not-allowed;
      }
    }

  }

  &.radio-inline{
    margin-top: 0;
  }
}

@include radio-variant('.abc-radio-primary', $primary);
@include radio-variant('.abc-radio-danger', $red);
@include radio-variant('.abc-radio-info', $blue);
@include radio-variant('.abc-radio-warning', $orange);
@include radio-variant('.abc-radio-success', $green);


// Validation states
// TODO: keep in sync with bootstrap since strange comment 'redo check markup lol crap'
.form-check-input {
  .was-validated &:invalid,
  &.is-invalid {
    .abc-checkbox,
    .abc-radio {
      label &:before {
        border-color: $red;
      }
    }
  }
}

//
// Reset Bootstrap outline
// --------------------------------------------------
.form-control {
  border: 1px solid $gray-200;
}

.form-control:focus {
  border-color: $purple-100;
  box-shadow: none;
}

.form-control, .form-check-label {
  font-size: $font-size-base;
}

.form-row .form-group label {
  margin-bottom: 0.1rem;
}

.input-group-text {
  font-size: $font-size-base;
}

.input-group-prepend {
  min-width: 40px;
}

@media (min-width: 576px) {
  .card-filters .form-group {
    margin-bottom: 0;
  }
}

.form-control.datepicker {
  padding: .25rem .5rem;
}


.form-control::placeholder {
  color: $gray-500;
}
::-webkit-input-placeholder { /* WebKit, Blink, Edge */
  color: $gray-500;
  font-style: italic;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
  color: $gray-500;
  opacity:  1;
  font-style: italic;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
  color: $gray-500;
  opacity:  1;
  font-style: italic;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
  color: $gray-500;
  font-style: italic;
}
::-ms-input-placeholder { /* Microsoft Edge */
  color: $gray-500;
  font-style: italic;
}

::placeholder { /* Most modern browsers support this now. */
  color: $gray-500;
  font-style: italic;
}

.select2-container .select2-search--inline .select2-search__field::placeholder {
  padding-top: 5px;
}
