
// FORM LAYOUT

.form-group {
  margin-bottom: 1.5rem;

  label {
    margin: 0 0 0.5rem 0.125rem;
    text-transform: uppercase;
    font-size: em(13);
    position: relative;
    width: 100%;

    &.form-check-label {
      font-family: $font-family-sans-serif;
      text-transform: none;
      font-size: .9375em;
    }

    &.required:after {
      content: "";
      display: inline-block;
      width: .625em;
      height: .625em;
      border-radius: 50%;
      font-size: 0.75em;
      position: relative;
      bottom: 1px;
      left: 5px;
    }
  }

  &.row .col {
    padding-left: rem(4);
    padding-right: rem(4);

    &:first-child {
      padding-left: rem(25);
    }

    &:last-child {
      padding-right: rem(25);
    }

    @include media-breakpoint-down(xs) {
      &.city {
        padding-right: rem(25);
      }

      &.state {
        padding-top: 1.5rem;
        padding-left: rem(25);
      }

      &.postal-code {
        padding-top: 1.5rem;
        padding-right: rem(25);
      }
    }

    @include media-breakpoint-between(md, lg) {
      &.postal-code label:after {
        content: "";
        right: rem(6);
      }
    }

    @include media-breakpoint-only(xxs) {
      &.postal-code label:after {
        content: "";
        right: rem(6);
      }
    }
  }
}

.form-text {
  margin: 0.625rem 0 0 0.125rem;
}

.form-control-inline {
  width: auto;
  display: inline-block;
}

select.form-control-inline {
  padding-right: rem(36);
}

// BASE CONTROL STYLES
input,
textarea,
select,
.form-control {
  cursor: text;
  transition: all .2s ease;
  font-size: rem(15);

  &::placeholder {
    font-family: $font-family-sans-serif;
    transition: color .2s ease;
  }
}

// TEXTAREA
textarea,
textarea.form-control {
  padding: 0.8rem;
}

// PASSWORD INPUT
.password-input .input-group-addon {
  font-size: 0.85em;
  cursor: pointer;
  padding-right: rem(14);
}

.complexity-meter {
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  height: 0.125rem;
  z-index: 10;
  margin-bottom: 0;
  transition: width 1s ease, background-color 1s ease;
  border-bottom-right-radius: 0.25rem;
  border-bottom-left-radius: 0.25rem;

  &.complexity-meter-state0 {
    width: 0;
    background-color: $red-700;
  }

  &.complexity-meter-state1 {
    width: 5%;
    background-color: $red-700;
  }

  &.complexity-meter-state2 {
    width: 25%;
    background-color: $red-700;
  }

  &.complexity-meter-state3 {
    width: 50%;
    background-color: $yellow-700;
  }

  &.complexity-meter-state4 {
    width: 75%;
    background-color: $yellow-700;
  }

  &.complexity-meter-state5 {
    width: 85%;
    background-color: $green-700;
  }

  &.complexity-meter-state6 {
    width: 100%;
    background-color: $green-700;
  }

  &.complexity-meter-hidden {
    display: none;
  }
}

// DROP-DOWN / SELECTS
select.form-control, select.form-control:focus {
  -webkit-appearance: none;
  -moz-appearance: none;
  background-position: calc(100% - 1.25rem) 1em, calc(100% - 0.9375rem) 1em, calc(100% - 2.5em) 0.5em;
  background-size: rem(5) rem(6), rem(5) rem(6), rem(1) 1.5em;
  background-repeat: no-repeat;
}

select.form-control:not([size]):not([multiple]),
date-picker select.custom-select:not([size]):not([multiple]),
.form-blend select.form-blend-control:not([size]):not([multiple]) {
  height: 2.25rem;
}

// RADIO BUTTONS
.form-check input[type="radio"] {
  display: none;

  +.radio {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    position: relative;
    transition: background .2s ease;
    top: 0.25rem;
    margin-right: .5em;

    &:before {
      content: "";
      display: block;
      width: rem(2);
      height: rem(2);
      border-radius: 50%;
      margin: .625em 0 0 .625em;
      opacity: 0;
      transition: all .2s ease;
    }
  }

  &:checked+.radio:before {
    margin: rem(5) 0 0 rem(5);
    width: .5em;
    height: .5em;
    opacity: 1;
  }
}

// "TOGGLE" CHECKBOX
.form-check input[type="checkbox"] {
  display: none;

  +.checkbox {
    display: inline-block;
    width: 3.75em;
    min-width: 3.75em;
    height: 1.6875em;
    border-radius: rem(13);
    transition: all .3s ease;
    position: relative;
    top: .5em;
    margin-top: -.4375em;
    margin-right: .5em;

    &:before {
      content: "";
      width: 1.4375em;
      height: 1.4375em;
      border-radius: 50%;
      position: absolute;
      top: 0.125em;
      left: 0.125em;
      transition: left .3s ease;
    }
  }

  &:checked + .checkbox:before {
    left: 2.125em;
  }
}

.form-check-label {
  @extend .d-flex;
  cursor: pointer;
  padding-left: 0;
  align-items: baseline !important;
}

label input[type="checkbox"] {
  margin-right: 0.3125rem;
}

// INPUT GROUPS
.input-group {
  > .form-control:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
  }

  > .form-control:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: none;
  }

  .dropdown-menu .form-control {
    display: inline-block;
    flex: inherit;
    width: auto;
  }
}

.input-group .form-control {
  &:hover, &:focus {
    z-index: inherit;
  }
}

.input-group-addon {
  font-size: rem(20);
  padding: rem(2) rem(12);
  border-top-right-radius: 0.25rem;
  border-bottom-right-radius: 0.25rem;
  transition: all .2s ease;

  &.btn-sm {
    font-size: rem(14);
    padding: 0.5em 1.2em 0.25em;
  }

  &:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  &:first-child {
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
    padding: rem(2) 0 rem(2) rem(2);
  }

  &.input-group-addon-label {
    background-color: $gray-75;
    label {
      color: $gray-800;
    }
  }
}

.input-group-addon-link {
  color: $link-color;
  font-size: rem(14);
  cursor: pointer;
}

input[type="range"] {
  -webkit-appearance: none; // Hides the slider so that custom slider can be made
  width: 100%; // Specific width is required for Firefox.
  background: transparent; // Otherwise white in Chrome

  // &::-webkit-slider-thumb {
  //   -ms-track-ms-track-ms-track-webkit-appearance: none;
  // }

  &:focus {
    outline: none; // Removes the blue border. You should probably do some kind of focus styling for accessibility reasons though.
  }

  &::-ms-track {
    width: 100%;
    cursor: pointer;

    // Hides the slider so custom styles can be added
    background: $white;
    border: 0.0625rem solid $gray-200;
    border-radius: 0;
    height: 0.3125rem;
  }

  &::-webkit-slider-thumb {
    -webkit-appearance: none;
    background: $white;
    border-radius: 50%;
    border: 0.0625rem solid $gray-300;
    cursor: pointer;
    height: 1.375rem;
    margin-top: -0.625rem;
    width: 1.375rem;
  }

  &::-moz-range-thumb {
    background: $white;
    border-radius: 50%;
    border: 0.0625rem solid $gray-300;
    cursor: pointer;
    height: 1.375rem;
    margin-top: -0.625rem;
    width: 1.375rem;
  }

  &::-ms-thumb {
    background: $white;
    border-radius: 50%;
    border: 0.0625rem solid $gray-300;
    cursor: pointer;
    height: 1.375rem;
    margin-top: -0.625rem;
    width: 1.375rem;
  }

  &::-webkit-slider-runnable-track {
    background: $white;
    border: 0.0625rem solid $gray-200;
    border-radius: 0;
    cursor: pointer;
    height: 0.3125rem;
    width: 100%;
  }

  &::-moz-range-track {
    background: $white;
    border: 0.0625rem solid $gray-200;
    border-radius: 0;
    cursor: pointer;
    height: 0.3125rem;
    width: 100%;
  }
}


// blended inputs

.form-blend {
  .form-control {
    &:not(:hover):not(:active):not(:focus) {
      background-color: transparent;
      border-color: transparent;
    }
  }

  h1 .form-control { @extend h1; }
  h2 .form-control { @extend h2; }
  h3 .form-control { @extend h3; }
  h4 .form-control { @extend h4; }
  h5 .form-control { @extend h5; }
  h6 .form-control { @extend h6; }
  p .form-control { @extend p; }
}

.input-group a {
  font-size: 0.875rem;
  display: block;
  margin-top: 0.0625rem;
}

//removes clear button + extra dropdown arrow IE10 + IE11
.filterbar-search-input::-ms-clear,
select.form-control::-ms-expand {
  display: none;
}

.form-inline .form-group {
  align-items: baseline;

  label {
    @extend .pb-0;
    width: auto;
  }
}


// Animate submit button when form becomes valid
form button[type="submit"] {
  display: inline-block;
}

form.ng-valid button[type="submit"] {
  animation: pulse .4s ease 1;
}


.unstyled-form {
  .form-control, .form-control:active, .form-control:focus, .form-control:hover,
  .input-group,
  .input-group-addon {
    background-color: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }
}


.font-weight-bold {
  .form-control { font-weight: bold; }
  date-picker ngb-datepicker { font-weight: normal !important; }
}
