.form-control {
  padding: 0.65em 1em 0.45em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  &:focus {
    box-shadow: none;
  }
}

.btn {
  padding: 0.65em 2em 0.45em;
}

label {
  font-weight: 500;
  font-size: 0.9em;
}

.form {
  .input-wrapper {
    position: relative;
    display: inline-block;
  }

  #{$text-inputs-list} {
    @extend .form-control;

    &.alert {
      border-color: $red;
      box-shadow: 0 0 6px rgba($red, 0.2);
    }

    &[required],
    &.success {
      background-repeat: no-repeat;
      background-position: top right;
    }

    &[required] {
      background-image: url("#{$assets-path}/img/form/icon-required.svg");
    }

    &.success {
      background-image: url("#{$assets-path}/img/form/icon-success.svg");
    }

    &[disabled] {
      opacity: 0.8;
      background-color: lighten($light-grey, 8%);
    }

    & + div.alert {
      margin-top: -23px;
      margin-left: 1px;
      margin-right: 1px;
      border-top-left-radius: 0;
      border-top-right-radius: 0;
      font-size: 0.8em;
      padding: 4px 10px 2px;
    }
  }

  #{$text-inputs-list} {
    height: 2.6em;
  }

  .input-group {
    position: relative;
    width: 100%;

    .input-group-addon {
      position: absolute;
      z-index: 10;
      top: 1px;
      bottom: 1px;
      border: none;
      width: 2.5em;
      padding: 0.85em 0.1em;
      opacity: 0.3;
      font-size: inherit;

      & + input {
        text-indent: 2em;
      }

      @mixin icon($image) {
        background-image: url($image);
        background-position: center;
        background-size: 1.4em auto;
        background-repeat: no-repeat;
      }

      &.user {
        @include icon("#{$assets-path}/icons/user.svg");
      }

      &.search {
        @include icon("#{$assets-path}/icons/search.svg");
      }

      & + input {
        text-indent: 2em;
      }
    }

    input[type="text"] {
      font-size: inherit;

      &:not(:first-child):not(:last-child),
      &:not(:first-child),
      &:not(:last-child) {
        border-radius: $input-border-radius;
      }

      & + .input-group-addon {
        right: 0;
      }
    }
  }

  input[type=radio],
  input[type=checkbox] {
    position: absolute;
    left: 0;
    top: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
  }

  .radio-label,
  .checkbox-label {
    padding-left: 24px;

    @include user-select(none);

    position: relative;

    &::before,
    &::after {
      /* custom radio and check boxes */
      content: '';
      display: block;
      width: 16px;
      height: 16px;
      position: absolute;
      top: 50%;

      @include translate(0, -50%);
    }

    &::before {
      left: 0;
      border: 1px solid $light-grey;
      box-shadow: inset 1px 1px rgba(#000, 0.03);
    }

    &::after {
      left: 0;
      background: url('#{$assets-path}/img/form/icon-check.svg') no-repeat center center;
      display: none;
    }
  }

  .radio-label {
    &::after {
      background-image: url('#{$assets-path}/img/form/icon-radio.svg');
    }

    &::before {
      border-radius: 50%;
    }
  }

  .checkbox-label::before {
    border-radius: 3px;
  }

  input[type=radio]:checked + label::before,
  input[type=checkbox]:checked + label::before {
    background-color: $primary-colour;
    border: none;
    box-shadow: none;
  }

  input[type=radio]:checked + label::after,
  input[type=checkbox]:checked + label::after {
    display: block;
  }

  .select {
    box-shadow: none;

    select {
      position: relative;
      padding: 0 1em 0 0;
      cursor: pointer;
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
      outline: none;
      background-color: transparent;
      border: none;
      width: 100%;

      &::-ms-expand {
        display: none;
      }
    }

    &::after {
      /* switcher arrow for select element */
      content: '';
      position: absolute;
      z-index: 1;
      right: 14px;
      top: 50%;

      @include translate(0, -45%);

      display: block;
      width: 12px;
      height: 12px;
      background: url('#{$assets-path}/img/form/icon-select.svg') no-repeat center center;
      pointer-events: none;
    }
  }

  &.has-group-actions {
    padding-right: 42px;

    .form-group {
      position: relative;
    }

    .form-group-action {
      position: absolute;
      top: 5px;
      right: -34px;
      width: 32px;
      opacity: 0.3;
      cursor: pointer;
      padding: 4px;

      svg {
        width: 24px;
        height: 24px;
        fill: $gray;
      }

      &:hover {
        opacity: 1;
      }
    }
  }

  .upload-input {
    display: table;
    padding: 0;

    input[type="file"] {
      display: none;
    }

    .file-select,
    .file-display {
      display: table-cell;
      vertical-align: middle;
    }

    .file-select {
      width: 1%;
      padding-left: 4px;

      .btn {
        text-transform: uppercase;
        font-size: 12px;
      }
    }

    .file-display {
      height: auto;
      background-color: transparent !important;
      border: none;
      box-shadow: none;
      opacity: 1;
    }
  }

  .form-group.choice {
    .or {
      text-align: center;
      opacity: 0.7;
      padding-top: $padding-base-vertical;
      padding-bottom: $padding-base-vertical;

      &::before,
      &::after {
        content: '-';
      }
    }

    @media (min-width: $screen-sm-min) {
      display: table;
      width: 100%;
      table-layout: fixed;

      & > div {
        display: table-cell;
        vertical-align: middle;
      }

      .or {
        width: 5%;
      }
    }
  }
}

@mixin minimal-field {
  width: 100%;
  outline: 0;
  border-width: 0 0 1px;
  padding: 0 5px;
  font-size: 15px;

  &:focus {
    border-color: $primary-colour;
  }
}

@mixin minimal-textarea {
  width: 100%;
  outline: 0;
  border-width: 0 0 1px;
  height: 26px;
  resize: none;
  overflow: hidden;
  border-color: $light-grey;

  @include transition(height, 0.5s, ease-out);

  padding: 0 5px;
  font-size: 15px;

  &:focus {
    border-color: $primary-colour;
    height: 120px;
    overflow: auto;
    padding: 5px;
  }
}
