input {
  padding: $input-padding;
  color: $color;
}

input[type='file'] {
  padding: 0;
  cursor: pointer;
}

textarea {
  vertical-align: text-top;
  max-width: 100%;
}

.input {
  color: $color;
  padding: $input-padding;
  outline: none;
  border: 1px solid $color-input-border;
  line-height: 0.28rem;
  min-height: 0.3rem;
  box-sizing: border-box;
  background-color: #fff;
  border-radius: $input-border-radius;
}

.input:hover,
.input:focus {
  border-color: $color-input-border-hover;
}

.input.readonly:hover,
.input.readonly:focus {
  border-color: $color-input-border;
}

input[readonly],
input[disabled],
.input[readonly],
.input[disabled],
.readonly {
  background-color: $color-input-disabled;
}

.input[readonly]:hover,
.input[readonly]:focus,
.input[disabled]:hover,
.input[disabled]:focus {
  border: 1px solid $color-input-border;
}

.input.container {
  display: inline-flex;
  align-items: center;
  background-color: #fff !important;
  padding: 0;
}

.input.container.readonly {
  background-color: $color-button-disabled !important;
}

.input.container input {
  border: none;
  outline: none;
  padding: $input-padding;
  flex-grow: 1;
}

.input.container button {
  border: none;
  outline: none;
  padding: $input-padding;
  background-color: transparent;
  cursor: pointer;
}

.input.container button:hover {
  color: $color-url-hover;
}

.input.container .left:nth-child(1n + 0) {
  padding: $input-padding;
  border-right: 1px solid $color-border;
  background-color: transparentize($color-border, 0.6);
}

.input.container .right:nth-child(1n + 0) {
  padding: $input-padding;
  border-left: 1px solid $color-border;
  background-color: transparentize($color-border, 0.6);
}

.input.container i.left {
  color: $color-placeholder;
  background-color: transparent !important;
  border: none !important;
  padding-right: 0 !important;
}

.input.container i.right {
  color: $color-placeholder;
  background-color: transparent !important;
  border: none !important;
  padding-left: 0 !important;
}

.input-error {
  border: 1px solid $color-error !important;
}

.input.ng-touched.ng-invalid,
.submited .input.ng-invalid {
  border: 1px solid $color-error;
}

.comment.input textarea {
  border: none;
  outline: none;
  resize: none;
}

.comment.input .user {
  position: absolute;
  color: $color-url-hover;
  top: 0.02rem;
  left: $input-padding;
}

.comment.input .user > label {
  color: $color;
}

.checkbox input[type='checkbox'],
.radio input[type='radio'] {
  display: none;
}

.radio > span,
.checkbox > span {
  position: relative;
  vertical-align: middle;
  padding-left: 0.2rem;
  cursor: pointer;
}

.radio.disabled > span,
.checkbox.disabled > span {
  cursor: default;
}

.radio input[type='radio']:checked + span:before,
.checkbox input[type='checkbox']:checked + span:before,
.radio:hover > span:before,
.checkbox:hover > span:before {
  border-color: $color-primary;
}

.checkbox input[type='checkbox']:checked + span:before {
  background-color: $color-primary;
}

.radio input[disabled] + span:before,
.checkbox input[disabled] + span:before {
  border-color: transparentize($color-primary, 0.6) !important;
  background-color: transparentize($color-primary, 0.6) !important;
}

.radio > span:before {
  position: absolute;
  top: 0;
  left: 0;
  width: 0.12rem;
  height: 0.12rem;
  content: '';
  border: 1px solid #c0c0c0;
  border-radius: 50%;
}

.radio > span:after {
  display: none;
  position: absolute;
  top: 0.01rem;
  left: 0.01rem;
  content: '';
  width: 0.12rem;
  height: 0.12rem;
  border-radius: 50%;
  background: $color-primary;
  transform: scale(0.5);
}

.radio input:checked + span:after,
.checkbox input:checked + span:after {
  display: block;
}

.radio input:checked + span:after,
.checkbox input:checked + span:after {
  display: block;
}

.radio.square > span {
  position: relative;
  display: inline-flex;
  width: 1rem;
  height: 1rem;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.15rem;
  border: 1px solid $color-border;
  border-radius: $input-border-radius;
  box-sizing: border-box;
}

.radio.square > span > .img {
  font-size: 0.3rem;
  width: 0.3rem;
  line-height: 1;
}

.radio.square > span > .desc {
  word-break: break-all;
  word-break: break-word;
  line-height: 1.8;
  margin-top: 0.05rem;
}

.radio.square > span:before {
  display: none;
}

.radio.square > span:hover {
  border-color: $color-primary;
  color: $color-primary;
}

.radio.square input:checked + span {
  border-color: $color-primary;
  color: #fff !important;
  background: $color-primary;
}

.radio.square input:checked + span:after {
  background: transparent;
}

.checkbox > span:before {
  position: absolute;
  top: 0;
  left: 0;
  width: 0.12rem;
  height: 0.12rem;
  content: '';
  border: 1px solid #c0c0c0;
  border-radius: 0.03rem;
}

.checkbox.disabled > span:before {
  border: 1px solid #ddd;
  background-color: #eee;
}

.checkbox > span:after {
  display: none;
  position: absolute;
  content: '';
  top: 0.02rem;
  left: 0.05rem;
  box-sizing: border-box;
  width: 0.05rem;
  height: 0.08rem;
  transform: rotate(42deg);
  border: 2px solid #fff;
  border-top: 0;
  border-left: 0;
}

ui-switch {
  display: inline-block;
  height: 0.14rem;
  vertical-align: middle;
}

.ui-switch {
  position: relative;
  display: inline-block;
  width: 0.22rem;
  height: 0.12rem;
  color: #fff;
  border-radius: 0.1rem;
  border: 1px solid $color-primary;
  background-color: $color-primary;
  cursor: pointer;
  transition: all 0.36s;
}

.ui-switch:after {
  content: ' ';
  position: absolute;
  left: 0;
  width: 0.1rem;
  height: 0.1rem;
  border-radius: 50%;
  background-color: #fff;
  transition: left 0.36s;
}

.ui-switch.off {
  border: 1px solid $color-gray !important;
  background-color: $color-lightgray !important;
}

.ui-switch.on:after {
  left: 0.1rem;
}

.ui-switch.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ui-switch .blank {
  background: #fff;
  color: #fff;
}

.ui-switch.success {
  border: 1px solid $color-success;
  background-color: $color-success;
}

.ui-switch.warning {
  border: 1px solid $color-warning;
  background-color: $color-warning;
}

.ui-switch.error {
  border: 1px solid $color-error;
  background-color: $color-error;
}

.input-group {
  position: relative;
  white-space: nowrap;
  vertical-align: middle;
  text-align: left;
}

.input-group > i {
  position: absolute;
  left: 0.16rem;
  font-size: 0.16rem;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(0, 0, 0, 0.55);
}

.input-group .input {
  padding-left: 0.3rem;
  box-sizing: border-box;
}

.input-group .right {
  position: absolute;
  right: 0.1rem;
  top: -55%;
  bottom: 0;
}

.required::after {
  content: '*' !important;
  color: #f30;
  font-size: 0.2rem;
  vertical-align: middle;
  line-height: 1;
  height: 0.14rem;
  display: inline-block;
}

input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
  /* WebKit browsers */
  color: $color-placeholder;
}
input:-moz-placeholder,
textarea:-moz-placeholder {
  /* Mozilla Firefox 4 to 18 */
  color: $color-placeholder;
}
input::-moz-placeholder,
textarea::-moz-placeholder {
  /* Mozilla Firefox 19+ */
  color: $color-placeholder;
}
input:-ms-input-placeholder,
textarea:-ms-input-placeholder {
  /* Internet Explorer 10+ */
  color: $color-placeholder;
}

.input + .status {
  position: relative;
  display: block;
  color: $color-error;
  line-height: 1.5;
  margin-top: 0.03rem;
}

.input + .status::after {
  position: absolute;
  right: 0.05rem;
  top: -0.38rem;
}

.input.ng-pristine.ng-untouched + .status,
.input.ng-valid + .status {
  color: transparent;
  height: 0;
}

.input.ng-pristine.ng-untouched + .status::after {
  content: '' !important;
}

.input.ng-valid + .status::after {
  font-size: 0.16rem;
  content: '\e656';
  color: $color-success;
}

.input.ng-invalid + .status::after {
  font-size: 0.16rem;
  content: '\e658';
  color: $color-error;
}

form {
  .error {
    display: none;
    &.ng-touched {
      display: block;
    }
  }

  &.ng-touched {
    .error {
      display: block;
    }
  }

  .flex > label {
    margin-right: 0.2rem;
    flex-shrink: 0;
    &::after {
      content: ' ';
      width: 0.05rem;
      display: inline-block;
    }
  }
}
