@import '../base/colors';
@import 'colors';
@import 'variables';

// General attributes
@include input-elements-mixin {
  // Removes awkward default styles on some inputs for iOS
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;

  background-color: $form-color-background;
  border: 1px solid $form-color-border;
  border-radius: 4px;
  box-sizing: border-box;
  color: $normal-black;
  height: 40px;
  padding: 0 10px;
  transition: border .3s, background-color .3s, box-shadow .3s;
}

// Dim the form elements when they're disabled
@include input-elements-mixin(':disabled') {
  background-color: $form-color-disabled;
  border-color: $form-color-disabled;
  color: $form-color-disabled-text;
  -webkit-text-fill-color: $form-color-disabled-text;
}

// Dropdown arrow for everyone!
select {
  background: $select-dropdown-arrow;
  background-color: $form-color-background;
  background-position: 98% 50%;
  outline: 0 !important;

  // Firefox outline bug
  &:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 $normal-black;
  }
}

textarea {
  min-height: 65px;
  padding: 6px 10px;
}

// Blue light animation when the form elements get focus
@include input-elements-mixin(':focus') {
  background-color: $white;
  // border: 1px solid $form-color-border;
  // box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) inset, 0 0 8px rgba(41, 92, 161, 0.6);
  outline: 0 !important;
}

@include input-elements-mixin('.error') {
  border: 1px $button-color-red solid;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1) inset, 0 0 8px $button-color-red;
}

@include input-elements-mixin('.warning') {
  border: 1px $button-color-orange solid;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1) inset, 0 0 8px $button-color-orange;
}

@include input-elements-mixin('.success') {
  border: 1px $button-color-green solid;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1) inset, 0 0 8px $button-color-green;
}

// Label and Legend normalization
label,
legend {
  display: block;
  font-weight: normal;
  margin-bottom: .5rem;
}

// Fieldset normalization
fieldset {
  border: 2px solid $text-color;
  border-radius: 5px;
  margin: 10px 5px;
  padding: 20px;
}

// Checkbox and Radio normalization
@include checkradio-mixin {
  display: inline;

  // Make the actual boxes invisible
  opacity: 0;
  position: absolute;

  // Checkbox and radio normalization
  cursor: pointer;
  margin: 5px;
  vertical-align: middle;
}


// Labels for checkboxes and radios have relative position to their parent
label {
  .checkbox,
  .radio {
    cursor: pointer;
    margin: 5px;
    position: relative;
    vertical-align: middle;
  }
}

// General attributes for checkboxes and radio buttons
input[type='checkbox'] + label.checkbox::before,
input[type='radio'] + label.radio::before {
  background-color: transparent;
  border: 2px solid $text-color;
  border-radius: 5px;
  content: '';
  display: inline-block;
  height: 10px;
  margin: auto 10px 3px auto;
  padding: 2px;
  text-align: center;
  transition: background-color .3s, box-shadow .3s;
  vertical-align: middle;
  width: 10px;
}

// Round shape for radio boxes
input[type='radio'] + label.radio::before {
  border-radius: 20px;
}

// When the checkbox is checked
input[type='checkbox']:checked + label.checkbox:before {
  background-color: $form-checkradio-color;
}

// When the radio button is checked
input[type='radio']:checked + label.radio:before {
  background-color: $form-checkradio-color;
}

// Remove outlines of checkboxes and radio buttons, especially for Firefox
input[type='checkbox']:focus + label.checkbox,
input[type='radio']:focus + label.radio {
  outline: none !important;
}

input[type='checkbox'] + label, input[type='radio'] + label,
label.checkbox, label.radio {
  cursor: pointer;
}

// Fancy switch
/* The switch - the box around the slider */
.switch {
  font-size: 17px;
  position: relative;
  display: inline-block;
  width: 2.90em;
  height: 1.5em;

  /* Hide default HTML checkbox */
  input {
    opacity: 0;
    width: 0;
    height: 0;
  }

  /* The slider */
  .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    border: 2px solid $text-color;
    border-radius: 8px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 2.7em;

    &:before {
      position: absolute;
      content: "";
      height: 1.1em;
      width: 1.1em;
      left: 1px;
      bottom: 0.1em;
      background-color: $text-color;
      border-radius: 6px;
      transition: all 0.4s cubic-bezier(0.23, 1, 0.320, 1);
    }
  }
}

.switch input:checked + .slider:before {
  transform: translateX(1.45em);
}

.switch input:checked + .slider {
  box-shadow: 0 0 10px $button-color-simple;
  border: 2px solid $button-color-simple;
}

.switch input:checked + .slider:before {
  background-color: $button-color-simple;
}

// Colors
.switch.blue input:checked + .slider {
  box-shadow: 0 0 10px rgba(9, 117, 241, 0.8);
  border: 2px solid #0974f1;
}

.switch.blue input:checked + .slider:before {
  background-color: #0974f1;
}

.switch.green input:checked + .slider {
  box-shadow: 0 0 10px #2ecc70d0;
  border: 2px solid #2ecc71;
}

.switch.green input:checked + .slider:before {
  background-color: #2ecc71;
}

.switch.orange input:checked + .slider {
  box-shadow: 0 0 10px #e67d22d2;
  border: 2px solid #e67e22;
}

.switch.orange input:checked + .slider:before {
  background-color: #e67e22;
}

.switch.red input:checked + .slider {
  box-shadow: 0 0 10px #e74d3ccc;
  border: 2px solid #e74c3c;
}

.switch.red input:checked + .slider:before {
  background-color: #e74c3c;
}

// Range
input[type='range'] {
  // Style input range
  appearance: none;
  -webkit-appearance: none;
  background-color: transparent;
  margin: 0 5px;
  transition: .3s;

  &:focus {
    outline: none;
  }

  &::-webkit-slider-runnable-track {
    background: $meshki-black;
    border: 2px solid $form-color-background;
    border-radius: 8px;
    cursor: pointer;
    height: 26px;
    width: 100%;
  }

  &::-webkit-slider-thumb {
    -webkit-appearance: none;
    background-color: $form-color-background;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    height: 20px;
    width: 50px;
    position: relative;
    top: 1px;
    left: 1px;
  }

  &::-webkit-slider-thumb:hover:active, &::-webkit-slider-thumb:active {
    background-color: #0b60c2;
    border-color: #0b60c2;
    transition: .3s;
  }

  &::-webkit-slider-thumb:hover {
    background-color: #0974f1;
    border-color: #0974f1;
    transition: .3s;
  }

  &::-moz-range-track {
    background-color: $meshki-black;
    border: 2px solid $form-color-background;
    border-radius: 8px;
    cursor: pointer;
    height: 22px;
    width: 100.5%;
    transition: .3s;
  }

  &::-moz-range-thumb {
    background-color: $form-color-background;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    height: 16px;
    width: 45px;
    transition: .3s;
  }

  &::-moz-range-thumb:hover {
    background-color: #0974f1;
    border-color: #0974f1;
    transition: .3s;
  }

  &::-moz-range-thumb:hover:active, &::-moz-range-thumb:active {
    background-color: #0b60c2;
    border-color: #0b60c2;
    transition: .3s;
  }

  &::-moz-range-thumb:hover {
    background-color: #0974f1;
    border-color: #0974f1;
    transition: .3s;
  }

  // Fix Firefox outline bug
  &::-moz-focus-outer {
    border: 0;
  }

  &::-ms-track {
    background-color: transparent;
    border-color: transparent;
    color: transparent;
    cursor: pointer;
    height: 26px;
    width: 100%;
  }

  &::-ms-fill-lower,
  &::-ms-fill-upper {
    background-color: $meshki-black;
    border: 2px solid $form-color-background;
    border-radius: 8px;
  }

  &::-ms-thumb {
    background-color: $form-color-background;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    height: 20px;
  }
}

// Change placeholder color for text inputs
// Chrome
::placeholder {
  color: $form-color-placeholder;
  opacity: 1;
}

