//
// Forms
// ------------------------------------------------------------

label {
  position: relative;
  cursor: pointer;

  &.disabled {
    cursor: not-allowed;
  }
}

// Text
// ------------------------------
input,
textarea {
  display: block;
  width: 200px;
  padding: 8px 12px 7px;
  font-family: $base-font-family;
  background: $white;
  border: 2px solid $border-light-color;
  border-radius: $base-radius;
  outline: 0;
  transition: $base-transition;
  -webkit-appearance: none;

  @include placeholder {
    color: $gray;
    opacity: 1;
  }

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

  &.input--xsmall {
    width: 80px;
  }

  &.input--small {
    width: 160px;
  }

  &.input--large {
    width: 300px;
  }

  &.input--full {
    width: 100%;
  }

  &.input--success {
    color: $success-color;
    background-color: lighten($success-color, 48%);
    border-color: $success-color;

    @include placeholder {
      color: $success-color;
    }
  }

  &.input--danger {
    color: $danger-color;
    background-color: lighten($danger-color, 45%);
    border-color: $danger-color;

    @include placeholder {
      color: $danger-color;
    }
  }

  &.input--warning {
    color: $warning-color;
    background-color: lighten($warning-color, 45%);
    border-color: $warning-color;

    @include placeholder {
      color: $warning-color;
    }
  }

  &.input--info {
    color: $info-color;
    background-color: lighten($info-color, 45%);
    border-color: $info-color;

    @include placeholder {
      color: $info-color;
    }
  }

  &:disabled {
    cursor: not-allowed;
    background-color: $gray-white;
    border-color: $gray-white;
  }
}

[type=password] {
  font-family: $mono-font-family;
}

textarea {
  vertical-align: top;
  resize: vertical;
}

// Radio & Checkbox
// ------------------------------
[type=radio],
[type=checkbox] {
  margin-right: 10px;
  outline: 0;
}

.input-styled {
  position: absolute;
  top: 0;
  left: 0;
  width: $input-style-size;
  height: $input-style-size;
  opacity: 0;

  + .icon {
    position: relative;
    display: inline-block;
    width: $input-style-size;
    height: $input-style-size;
    margin-right: 10px;
    vertical-align: middle;
    border: 2px solid $border-light-color;
    transition: $base-transition;

    &::after {
      position: absolute;
      display: block;
      opacity: 0;
      transition: $base-transition;
    }
  }

  &:hover + .icon,
  &:focus + .icon {
    border-color: darken($border-light-color, 15%);
  }

  &:active + .icon {
    border-color: $primary-color;
  }

  &:checked + .icon {
    border-color: $primary-color;

    &::after {
      opacity: 1;
    }
  }

  &:disabled {
    + .icon {
      cursor: not-allowed;
      opacity: .5;
    }

    + .icon + * {
      color: $gray;
      cursor: not-allowed;
    }

    &:hover + .icon,
    &:focus + .icon {
      border-color: $border-light-color;
    }
  }
}

[type="file"] {
  display: inline-block;
  width: auto;
  padding: 0;
  border: 0;
}

.input--radio {
  + .icon {
    border-radius: 50%;
  }

  + .icon::after {
    $checked-size: ($input-style-size / 2) - 2;
    $checked-margin: (($input-style-size - 4) / 2) - ($checked-size / 2);

    top: $checked-margin;
    left: $checked-margin;
    width: $checked-size;
    height: $checked-size;
    content: "";
    background-color: $primary-color;
    border-radius: 50%;
  }
}

.input--check {
  + .icon {
    border-radius: $base-radius;
  }

  &:checked + .icon {
    background-color: $primary-color;
  }

  + .icon::after {
    @include fontawesome("\f00c");

    top: -1px;
    left: 2px;
    font-size: 13px;
    color: $white;
  }
}

@-moz-document url-prefix() {
  .input--check + .icon::after {
    top: 0;
  }
}

// Select
// ------------------------------
select {
  font-family: $base-font-family;
  cursor: pointer;

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

.select-styled {
  position: relative;
  display: inline-block;

  select {
    display: inline;
    width: 100%;
    height: 40px;
    padding: 0 44px 0 10px;
    overflow: hidden;
    font-weight: bold;
    line-height: 40px;
    color: $text-color;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    background-color: $gray-lighter;
    border: 0;
    border-radius: $base-radius;
    outline: 0;
    transition: $base-transition;
    -moz-appearance: none !important;
    -webkit-appearance: none !important;

    &:hover {
      background-color: darken($gray-lighter, 5%);
    }

    &:disabled {
      pointer-events: none;
      cursor: not-allowed;
      opacity: .4;
    }

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

  &::after {
    @include fontawesome("\f0d7");

    position: absolute;
    top: 0;
    right: 0;
    display: block;
    width: 34px;
    height: 100%;
    font-size: 16px;
    line-height: 40px;
    color: $gray;
    text-align: center;
    pointer-events: none;
    border-left: 1px solid $white;
  }
}

@include mobile {
  input,
  textarea {
    width: 100%;

    &.input--small,
    &.input--large {
      width: 100%;
    }
  }
}
