form {
  width: 100%;
}

.flex-form-label {
  padding: 0;
  line-height: 1.3;
  margin-bottom: 1rem;

  &--small {
    font-size: 1.4rem;
  }

  &--medium {
    font-size: 1.6rem;
  }

  &--large {
    font-size: 1.8rem;
  }
}

.form {
  width: 100%;
  position: relative;
  display: flex;
  flex-wrap: wrap;

  &-row {
    position: relative;
    display: flex;
    flex: 0 1 100%;
    flex-direction: row;
    flex-wrap: wrap;
    min-width: 0;
    margin: auto;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    align-items: stretch; // By default we make all items stretch to the row height.

    & > .flex,
    & > [class*="flex-"] {
      @include mobile-only {
        padding-left: calc(#{$grid-space-mobile} / 2);
        padding-right: calc(#{$grid-space-mobile} / 2);
      }

      @include breakpoint(568) {
        padding-left: calc(#{$grid-space-portrait-tablet} / 2);
        padding-right: calc(#{$grid-space-portrait-tablet} / 2);
      }

      @include tablet-landscape-up {
        padding-left: calc(#{$grid-space-landscape-tablet} / 2);
        padding-right: calc(#{$grid-space-landscape-tablet} / 2);
      }

      @include desktop-up {
        padding-left: calc(#{$grid-space-desktop} / 2);
        padding-right: calc(#{$grid-space-desktop} / 2);
      }

      @include big-desktop-up {
        padding-left: calc(#{$grid-space-big-desktop} / 2);
        padding-right: calc(#{$grid-space-big-desktop} / 2);
      }
    }
  }

  &-group {
    margin-bottom: 0;
  }

  &-control {
    width: 100%;
    border-radius: $radius-rounded;
    border: 1px solid $color-mid-gray-1;
    background-color: white;
    line-height: 1.2;
    padding: 8px 16px;
    height: 40px;
    margin-bottom: 2rem;

    &--small {
      height: 30px;
      padding: 2px 10px;
    }

    &--medium {
      height: 40px;
      padding: 8px 16px;
    }

    &--large {
      height: 50px;
      padding: 10px 20px;
    }

    &[type='text'] {
      appearance: none;
    }

    &[type='file'] {
      border: none;
      padding-left: 0;
      padding-right: 0;
    }

    &[type='radio'],
    &[type='checkbox'] {
      height: auto;
    }
  }
}

.custom {
  &-select {
    display: inline-block;
    width: 100%;
    min-height: 45px;
    padding: 12px 16px;
    line-height: 1;
    color: black;
    vertical-align: middle;
    background: #fff url("data:image/svg+xml;charset=utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/></svg>") no-repeat right .75rem center;
    background-size: 8px 16px;
    border: 1px solid $color-mid-gray-1;
    border-radius: $radius-rounded;
    appearance: none;
  }

  &-file {
    position: relative;
    display: inline-block;
    min-height: 45px;
    width: 100%;
    margin-bottom: 0;
    padding: 0;
    line-height: 1;
    background-color: white;
    border: 1px solid $color-mid-gray-1;
    border-radius: $radius-rounded;

    &-input {
      position: absolute;
      z-index: 2;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      width: 100%;
      height: 100%;
      margin: 0;
      opacity: 0;
      line-height: 1;
    }

    &-label {
      position: absolute;
      top: 50%;
      height: 100%;
      left: 0;
      right: 0;
      padding: 18px 16px;
      transform: translateY(-50%);
      z-index: 1;
      line-height: 1;
      color: black;
      margin-bottom: 0;
      overflow: hidden;

      &:after {
        content: 'Browse';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 3;
        line-height: 1.5;
        display: block;
        padding: 1.4rem 1.6rem;
        text-align: center;
        border-radius: 0 $radius-rounded $radius-rounded 0;
        background-color: $color-light-gray-1;
      }
    }
  }
}
