@import '_checkbox-radio.scss';

%forms-label {
  white-space: nowrap;
  font-size: $size-x-small;
  color: $grey-dark;
  font-weight: $font-regular;
  letter-spacing: $x-small-space;
}

input,
label,
select,
textarea {
  font-family: $primary-font;
  letter-spacing: $x-small-space;
  font-size: $size-x-small;
  font-weight: $font-regular;
}

input {
  border: 1px solid $blue-grey-100;
  width: 100%;
  border-radius: 3px;
}

label {
  display: flex;
}

textarea {
  border: 1px solid $blue-grey-100;
  padding: 10px;
  width: 100%;
}
/*all inputs styling apart from types excluded*/
input:not([type='submit']):not([type='file']):not([type='radio']):not([type='checkbox']) {
  padding: 10px;
}

input.input-search {
  border-color: $white;
}

select {
  font-size: 0.875rem;
  border: 1px solid $grey-light;
  border-radius: 3px;
  background: $white;
  padding: 5px 10px;
  height: 40px;
  /* Removes the default <select> styling */
  /*  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;*/
  /* Positions background arrow image */
  /*background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAHCAYAAAAxrNxjAAAAAXNSR0IArs4c6QAAAJVJREFUGBlt0EEKwkAMBdAkXdRjeImCJyiCu9JTqNsBz9DpLFvwEqKIl1M6v4laGWqzS/6bvxhu264aIoKwHJ3bPyiZpulKEM6c8UkUeSKsI4aL9/1ucl90s4y0iPWwJY5XgHJFT+GsAvDSJkOrz01qtoY5Jn2ZIucO9zdcwHbSdqkN2fKDtiTNnCLL/kZ/oQih38yDET+eUFeYCxvjAAAAAElFTkSuQmCC');
  background-repeat: no-repeat;
  background-position: 99.5% 50%;*/
  width: 100%;
}
/* Internet Explorer 10–11 and Edge */
select::-ms-expand {
  display: none;
}
/*option {
  padding: 5px;
  color: red;
}*/
label {
  @extend %forms-label;
  margin: 0 0 5px;

  &::first-letter {
    text-transform: capitalize;
  }

  &:empty {
    display: none;
  }

  > span {
    margin-left: 5px;
  }
}

input[type][disabled] {
  background-color: $grey-100;
  color: $grey;
  border: 0;
  cursor: default;
  text-indent: 10px;
}

input[type='checkbox'][disabled],
input[type='radio'][disabled] {
  background-color: $grey-lightest;
}

input[type][disabled] + label {
  color: $grey-medium;
  cursor: default;
}

select[disabled] {
  background-color: $grey-100;
  color: $grey;
  border: 0;
  cursor: default;
  padding: 10px;
}

select[disabled] + label {
  color: $grey-medium;
  cursor: default;
}

*:focus {
  outline: none;
}

.form {
  max-width: 760px;
}

.form-field {
  margin: 0 0 30px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  @include mq($from: tablet) {
    max-width: 400px;
  }

  &:last-of-type {
    margin: 0;
  }

  &--select {
    & label {
      margin-bottom: 5px;

      &::first-letter {
        text-transform: capitalize;
      }
    }
  }

  &--header {
    margin: 0;
  }

  &--small {
    max-width: 100px;

    & select {
      height: 30px;
    }
  }

  &--full-width {
    max-width: 100%;
  }

  &--title {
    @extend %forms-label;
    margin-bottom: 15px;
  }

  &--radio {
    flex-direction: row;
    align-items: center;
    max-width: 100%;

    & label {
      cursor: pointer;
      margin: 0;
      white-space: normal;
    }
  }

  &--check {
    margin: 0;
    width: auto;
  }

  &--checkbox {
    flex-direction: row;
    align-items: center;
    margin-bottom: 30px;

    & + .form-field--checkbox {
      margin-top: -20px;
    }

    & input {
      width: 20px;
      height: 20px;
    }

    & label {
      cursor: pointer;
      margin: 0;
      white-space: normal;
      width: 100%;
    }
  }

  &--checkbox-full {
    width: 100%;
    text-align: left;
  }

  &--pagination {
    flex-direction: row;
    align-items: center;
    margin: 0;

    & label {
      margin-right: 10px;
    }
  }

  &--password {
    position: relative;
    width: 100%;

    & .show-hide-password {
      position: absolute;
      bottom: 10px;
      right: 10px;
      font-size: 0.75rem;
      display: flex;
      align-items: center;
      cursor: pointer;
      color: $grey-medium;
      background-color: $white;
      padding-left: 5px;

      & i {
        width: 18px;
        font-size: 1rem;
        margin-left: 5px;
      }
    }
  }
  &--multiselect {
    margin-bottom: 0;
  }

  &--range {
    padding: 0 10px;
    .values {
      display: flex;
      width: 100%;
      justify-content: space-between;
      padding-left: 5px;
    }
    .range__filter {
      display: block;
      position: relative;
      height: 36px;
      width: 100%;
      user-select: none;
      &--left,
      &--right {
        box-sizing: border-box;
        display: block;
        position: absolute;
        height: 20px;
        width: 20px;
        z-index: 2;
        cursor: pointer;
      }
      &--left,
      &--right {
        span {
          display: block;
          width: 100%;
          height: 100%;
          background: $grey;
          border-radius: 50%;
        }
      }
      &--line {
        box-sizing: border-box;
        position: absolute;
        width: calc(100% - 20px);
        left: 18px;
        top: 8px;
        height: 4px;
        border-radius: 4px;
        background: $grey-lightest;
        z-index: 0;
        overflow: hidden;
        span {
          display: block;
          height: 100%;
          width: 0%;
          background: $grey-light;
        }
      }
    }
  }
}

.toggle {
  & input[type='checkbox'] {
    height: 0;
    width: 0;
    visibility: hidden;
  }

  & label {
    cursor: pointer;
    text-indent: -9999px;
    width: 40px;
    height: 18px;
    background: $grey;
    display: block;
    border-radius: 20px;
    position: relative;
  }

  & label:after {
    content: '';
    position: absolute;
    top: 2px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: $white;
    border-radius: 18px;
    transition: 0.3s;
  }

  & input:checked + label {
    background: $primary-button-color;
  }

  & input:checked + label:after {
    left: calc(100% - 3px);
    transform: translateX(-100%);
  }

  & label:active:after {
    width: 40px;
  }

  &__item {
    width: 100%;
    margin: 15px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  &__text {
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: $x-small-space;
  }
}

.form-group {
  width: 100%;
  margin: 20px 0;

  &__heading {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    font-size: 0.875rem;
    color: $nearly-black;
    margin-bottom: 20px;
    font-weight: $font-semi-bold;
  }

  &--required {
    position: relative;

    &:before {
      content: '*';
      color: $secondary-color;
      font-size: 1.125rem;
      position: absolute;
      left: -12px;
      top: -2px;
    }
  }

  & .form-field {
    margin: 0 0 10px;
  }
}

.required {
  position: relative;

  &::before {
    content: '*';
    color: $red;
    font-size: 1.125rem;
    position: absolute;
    top: 0;
    left: -12px;
  }
}

.input-search {
  border: 0;
  color: $nearly-black;
  background: none;
  padding: 10px 0;
  font-weight: $font-regular;
  font-size: $size-x-small;
  ::-webkit-input-placeholder {
    /* Chrome/Opera/Safari */
    color: $grey-dark;
  }

  ::-moz-placeholder {
    /* Firefox 19+ */
    color: $nearly-black;
  }

  :-ms-input-placeholder {
    /* IE 10+ */
    color: $nearly-black;
  }

  :-moz-placeholder {
    /* Firefox 18- */
    color: $nearly-black;
  }
}

::-webkit-input-placeholder {
  /* Chrome/Opera/Safari */
  color: $nearly-black;
}

::-moz-placeholder {
  /* Firefox 19+ */
  color: $grey-dark;
}

:-ms-input-placeholder {
  /* IE 10+ */
  color: $grey-dark;
}

:-moz-placeholder {
  /* Firefox 18- */
  color: $grey-dark;
}

input.form-password {
  padding-right: 60px !important;
}

.validation {
  display: flex;
  font-size: 0.813rem;
  color: $red;
  margin: 5px 0 0;

  & i {
    display: none;
  }
}

.form-field--checkbox + .validation {
  margin: -30px 0 10px;
}
