//  Bootstrap overrides for forms
// TODO: use the recommended way to customize boostrap (Sass/CSS variables) instead of overriding everything
// Specially, try to remove the :before :after hacks for checkboxes and radio buttons
.form-group {
  margin-bottom: 1rem;

  .form-control-label {
    @include t11;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 0.5rem;
  }

  &.form-check {
    margin-top: 0.5rem;
    margin-bottom: 1.25rem;

    .form-control-label {
      @include t11;
      margin-bottom: 0.25rem;
    }
  }
}

label {
  margin: 0;
  font-size: 0.875rem;
  font-family: $open-sans;
  font-weight: 600;
}

textarea {
  border: 1px solid $borderGrey;
  background-color: $lightGrey;
  border-radius: 4px;
  font-size: 0.875rem;
  font-family: $open-sans;
  width: 100%;
  padding: 6px 10px;
}

input {
  &[type='submit'] {
    border: 1px solid;
    @include btn-coloring-base($blue, $blueHover);
    color: $white;
    border-radius: 0.25rem;
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    padding: 0.5rem 1.5rem;
    line-height: normal;
  }

  &[type='text'],
  &[type='password'],
  &[type='email'],
  &[type='number'],
  &[type='date'] {
    border: 1px solid $borderGrey;
    background-color: $lightGrey;
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: $open-sans;
    height: 44px;
    width: 100%;
    padding: 6px 10px;
  }

  &.form-control {
    font-size: 1rem;
    border: 1px solid #d4d4d4;
    background: #f6f6f6;
    color: $black;

    &[readonly] {
      border: none;
    }
  }
}

.form-check {
  padding-left: 1.8rem;
  position: relative;

  input {
    &[type='radio'] {
      opacity: 0;
      width: 0;

      &:checked ~ label {
        &:after {
          content: '';
          position: absolute;
          top: 6px;
          left: 4px;
          background-color: $grey;
          border-radius: 50%;
          width: 14px;
          height: 14px;
          opacity: 1;
          transition: all 0.1s linear;
        }
      }

      & ~ label {
        margin: 0;
        font-size: 0.875rem;
        font-family: $open-sans;
        font-weight: 600;

        &:before {
          content: '';
          position: absolute;
          left: 0;
          top: 2px;
          border: 1px solid $borderGrey;
          background-color: $lightGrey;
          border-radius: 50%;
          width: 22px;
          height: 22px;
        }

        &:after {
          content: '';
          position: absolute;
          opacity: 0;
          width: 0;
          height: 0;
          top: 14px;
          left: 12px;
        }
      }
    }

    &[type='checkbox'] {
      opacity: 0;
      position: absolute;

      &:checked ~ label {
        &:after {
          content: '';
          display: block;
          position: absolute;
          left: 0;
          top: 2px;
          background: $data-check-black-svg;
          background-repeat: no-repeat;
          background-position: center;
          background-size: 17px 17px;
          width: 22px;
          height: 22px;
          opacity: 1;
          transition: opacity 0.25s linear;
        }
      }

      & ~ label {
        margin: 0;
        font-size: 0.875rem;
        font-family: $open-sans;
        font-weight: 600;

        &:before {
          content: '';
          position: absolute;
          left: 0;
          top: 2px;
          border: 1px solid $borderGrey;
          background-color: $lightGrey;
          width: 22px;
          height: 22px;
        }

        &:after {
          content: '';
          display: block;
          position: absolute;
          opacity: 0;
        }
      }
    }
  }
}

.form-check-inline {
  &.form-check {
    padding-left: 1.8rem;
  }
}

.select-wrapper {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 0.25em;
  font-size: 0.875rem;
  font-family: $open-sans;

  &::after {
    content: '';
    color: $white;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    padding: 0 1em;
    pointer-events: none;
    background: $blue $data-arrow-collapse-white-svg no-repeat center;
    display: inline-block;
    width: 44px;
    background-size: 1rem;
  }

  select {
    height: 44px;
  }
}

fieldset {
  legend {
    font-family: $open-sans;
    font-size: 1rem;
    color: $black;
    line-height: 1.5;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 0.25em;
  }
}
