// general
input:not([type="file"]),
optgroup,
option,
textarea,
select {
  border: 1px solid var(--secondary-light);
  border-radius: var(--border-radius);
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  font-size: 1rem;
  height: 2.5rem;
  line-height: normal;
  margin: 0;
  padding: 0 0.5rem;
  max-width: 100%;
  min-width: 15rem;
  text-transform: none;
  vertical-align: middle;
  width: 15rem;

  &:invalid {
    border-color: var(--error);
  }

  &:invalid:hover {
    border: 1px solid #aa0000;
  }

  &[disabled],
  &:disabled {
    background: var(--secondary-lighter);
    color: var(--secondary-light);
  }

  &::-webkit-calendar-picker-indicator {
    display: none;
    background: none;
  }
}

input[type="button"],
input[type="image"],
input[type="reset"],
input[type="submit"],
input[size] {
  min-width: auto;
  width: auto;
}

input:not([type="file"]):not([type="image"]),
textarea,
select {
  &:not(:invalid):not(:disabled):not([disabled]):not([readonly]):hover {
    border: 1px solid var(--secondary);
  }
}

input[type="color"] {
  padding: 0.125rem;
}

input[type="range"] {
  padding: 0;
}

textarea {
  height: 5rem;
  line-height: 1.5rem;
  min-height: 3rem;
  overflow: auto;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  height: auto;
}

input[type="search"] {
  -webkit-appearance: textfield;
  appearance: textfield;
}

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

input[type="radio"],
input[type="checkbox"],
input[type="image"],
input[type="file"] {
  border: 0;
  box-sizing: border-box;
  height: auto;
  max-width: initial;
  min-width: auto;
  padding: 0;
}

// buttons
button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
  -webkit-appearance: button;
  appearance: button;
  background-color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--border-radius);
  box-sizing: border-box;
  color: var(--primary-bg);
  cursor: pointer;
  display: inline-block;
  font-size: 0.8rem;
  font-weight: var(--font-weight-bold);
  margin: 0;
  max-width: auto;
  min-height: 2.5rem;
  min-width: auto;
  overflow: visible;
  padding: 0 1rem;
  text-transform: uppercase;

  &[disabled],
  &:disabled {
    background: var(--secondary-lighter);
    border: 1px solid var(--secondary-lighter);
    color: var(--secondary-light);
  }

  &:not(:disabled):not([disabled]):hover {
    background-color: var(--primary-dark);
    border: 1px solid transparent;
  }
}

input[type="reset"] {
  background-color: var(--primary-bg);
  border: 1px solid var(--primary);
  color: var(--primary);

  &:not(:disabled):not([disabled]):hover {
    background-color: var(--primary-lighter);
  }

  &:disabled,
  &[disabled] {
    background: var(--secondary-lighter);
    border: 1px solid var(--secondary-lighter);
    color: var(--secondary-light);
  }
}

button[disabled],
html input[disabled] {
  cursor: default;
}

button::-moz-focus-inner,
input::-moz-focus-inner {
  border: 0;
  padding: 0;
}

// radios and checkboxes
input[type="radio"],
input[type="checkbox"] {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1px solid var(--secondary-light);
  box-shadow: inset 0 0 0 0.185rem var(--secondary-bg);
  background: var(--secondary-bg);
  vertical-align: text-top;

  &[type="checkbox"] {
    border-radius: var(--border-radius);
  }

  &:checked {
    background: var(--primary);
    -moz-print-color-adjust: exact;
    -ms-print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  &:disabled {
    box-shadow: inset 0 0 0 0.185rem var(--secondary-lighter);
    background: var(--secondary-lighter);
  }
}

// select
select:not([multiple]):not([disabled]) {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'><path d='M0,10 20,30 40,10' fill='none' stroke='%23999' stroke-width='2'/></svg>");
  background-size: 1em 1em;
  background-repeat: no-repeat;
  background-position: right 0.5em center;
  background-color: Field;
  padding-right: 2em;

  &:hover, &:active {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'><path d='M0,10 20,30 40,10' fill='none' stroke='%23222' stroke-width='2'/></svg>");
  }
}

select[multiple] {
  min-height: 10rem;
  padding: 0;

  & option:checked {
    background: var(--secondary-light)
      linear-gradient(0deg, var(--secondary-light) 0%, var(--secondary-light) 100%);
  }

  &:focus option:checked {
    background: var(--primary) linear-gradient(0deg, var(--primary) 0%, var(--primary) 100%);
    color: var(--primary-bg);
  }
}

optgroup {
  border: 0;
  border-radius: 0;
  font-weight: var(--font-weight-bolder);
  padding: 0.5rem;
}

option {
  border: 0;
  border-radius: 0;
  display: flex;
  font-weight: var(--font-weight-normal);
  align-items: center;
  justify-content: flex-start;

  &:hover {
    border: 0;
    background: var(--primary-lighter);
  }
}
