@import "../config";

.form-control {
  border: solid 1px var(--input-border-color);
  outline: none;
  padding: 0 1rem;
  line-height: 2.5rem;
  height: 2.5rem;
  width: 100%;
  background-color: var(--background-primary-color);
  border-radius: $border-radius;
  margin: 1px;
  transition: border-color $transitionTime;
  color: var(--text-primary-color);

  &:focus {
    border-color: var(--primary-color);
    border-width: 2px;
  }
}

textarea.form-control {
  height: 16rem;
  line-height: 1.1rem;
  padding: 0.6rem 1rem;
}

select:-moz-focusring {
  color: transparent;
  text-shadow: 0 0 0 var(--text-primary-color);
}

.form-group {
  padding-bottom: 1rem;
  display: block;
  position: relative;
  clear: both;

  label {
    display: block;
    padding-bottom: 0.3rem;
    padding-left: 0.2rem;
  }
}

.form-switch {
  line-height: 24px;

  input {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    opacity: 0;
    z-index: 0;
  }

  label {
    display: block;
    padding: 0 0 0 44px;
    cursor: pointer;

    &:before {
      content: '';
      position: absolute;
      top: 5px;
      left: 0;
      width: 36px;
      height: 14px;
      background-color: var(--bg-disabled-color);
      border-radius: 14px;
      z-index: 1;
      transition: background-color 0.28s cubic-bezier(.4, 0, .2, 1);
    }

    &:after {
      content: '';
      position: absolute;
      top: 2px;
      left: 0;
      width: 20px;
      height: 20px;
      background-color: var(--lever-disabled-color);
      border-radius: 14px;
      box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
      z-index: 2;
      transition: all 0.28s cubic-bezier(.4, 0, .2, 1);
      transition-property: left, background-color;
    }

    @include no-select
  }

  input:checked + label {
    &:before {
      background-color: var(--bg-enabled-color);
    }

    &:after {
      left: 16px;
      background-color: var(--lever-enabled-color);
    }
  }
}

.form-switch-group {
  padding: 0.5rem 0;
}

.form-btn {
  border: solid 1px var(--input-border-color);
  outline: none;
  padding: 0 1rem;
  line-height: 2rem;
  background-color: var(--background-primary-color);
  color: var(--primary-color);

  display: inline-block;
  margin-right: 0.6rem;

  border-radius: $border-radius;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.9rem;

  transition: border-color $transitionTime, outline-color $transitionTime;

  cursor: pointer;

  &:focus, &:hover {
    border-color: var(--primary-color);
    outline-color: var(--primary-color);
  }
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--primary-text-color);
  border-color: var(--primary-color);
}

.btn-danger {
  background-color: var(--error-color);
  color: var(--error-text-color);
  border-color: var(--error-color);
}

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

form {
  margin-bottom: 2rem;
  width: 100%;
}

@media (min-width: 768px) {
  form {
    width: 24rem;
  }
}

.input-group {
  display: flex;

  .form-btn {
    height: 2.5rem;
    line-height: 2.5rem;
    margin-top: 1px;
  }

  span {
    white-space: nowrap;
  }

  & > * {
    margin-right: 0;
    flex-grow: 1;
    flex-shrink: 1;

    &:not(:first-child) {
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
      margin-left: -1px;
    }

    &:not(:last-child) {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }
  }
}
