fieldset {
  border: none;
  margin: 0;
  padding: 0;

  legend {
    display: block;
    padding: 1em 0 0 0;
    width: 100%;
    font-size: 14px;
    font-weight: 600;
    color: #757575;
  }

  p.switch {
    position: relative;

    label {
      color: initial;
      font-size: 14px;
      position: static;
    }

    input[type="checkbox"] {
      margin: 0;
      appearance: none;
      outline: none;
      position: absolute;
      right: 0;
      width: 100%;
      height: 100%;

      &:before {
        content:"";
        position:absolute;
        right: 16px;
        top: -4px;
        height:24px;
        width:24px;
        border-radius:50%;
        display:block;
        background: @secondary_color;
        border:none;
        z-index:2;
        box-shadow:inset 0 0 0 16px #e5e5e5,0 0 2px 0 #c5c5c5;
        transform: translateZ(0);
        transition: transform 150ms ease-in-out 0s;
      }

      &:after {
        content:"";
        right: 0;
        width:36px;
        height:16px;
        background:@secondary_color;
        box-shadow: inset 0 0 0 16px #c5c5c5;
        border-radius:16px;
        display:block;
        position:absolute;
        z-index:1;
      }

      &:checked:before {
        transform: translateX(16px);
        box-shadow:inset 0 0 0 0 @secondary_color, 0 0 2px 0 #c5c5c5;
      }

      &:checked:after {
        box-shadow: inset 0 0 0 0 @secondary_color;
        opacity: .5;
      }
    }
  }

  p.radio {
    position: relative;
    min-height: 16px;

    label {
      position: static;
      margin-left: 24px;
    }

    input[type="radio"] {
      margin: 0;
      appearance: none;
      outline: none;
      position: absolute;
      right: 0;
      width: 100%;
      height: 100%;

      &:before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        border: 2px solid #757575;
      }

      &:after {
        content: '';
        position: absolute;
        left: 5px;
        top: 5px;
        width: 10px;
        height: 10px;
        background-color: @primary_color;
        border-radius: 50%;
        transform: scale3d(0, 0, 1);
        transition: transform 150ms ease-in-out;
      }

      &:checked {
        &:before {
          border-color: @primary_color;
        }

        &:after {
          transform: scale3d(1, 1, 1);
        }
      }
    }
  }
}

fieldset > p {
  position: relative;
  margin-top: 1em;
  textarea {
    resize: none;
    overflow: hidden;
    height: 4em;
  }
  input[type="text"],
  textarea, select {
    appearance: none;
    outline: none;
    border-radius: 0;
    height: 2em;
    box-sizing: border-box;
    background-color: transparent;
    width: 100%;
    font-size: 17px;
    padding: 5px 0;
    display: block;
    border: none;
    border-bottom: 1px solid #757575;
    margin-top: 1em;

    &:focus {
      outline: none;
      & ~ .bar:after {
        transform: scale3d(1, 1, 1);
      }
      & ~ .highlight {
        animation: inputHighlighter 150ms ease-in-out;
      }
    }

    &:not(select):valid ~ label {
      transform: translate3d(0, -13px, 0) scale3d(.8, .8, 1);
      color: @primary_color;
    }
  }

  label {
    color: #757575;
    font-size: 16px;
    transform: translate3d(0, 5px, 0) scale3d(1, 1, 1);
    font-weight: normal;
    position: absolute;
    pointer-events: none;
    left: 0;
    top: 0;
    transition: transform 150ms ease-in-out;
  }
  .bar {
    position: relative;
    display: block;
    width: auto;
    &:after {
      content: "";
      height: 2px;
      width: 100%;
      bottom: 0;
      position: absolute;
      background: @primary_color;
      box-sizing: border-box;
      transform: scale3d(0, 0, 0);
      transition: transform 150ms ease-in-out;
    }
  }
  .highlight {
    position: absolute;
    height: 60%;
    width: 100px;
    top: 25%;
    left: 0;
    pointer-events: none;
    opacity: 0.5;
  }


  select {
    direction: rtl;
    color: #757575;
    option {
      direction: ltr;
    }

    & ~ label {
      color: inherit;
    }
  }
}


@-webkit-keyframes inputHighlighter {
  from {
    background: @primary_color;
  }
  to {
    width: 0;
    background: transparent;
  }
}
@-moz-keyframes inputHighlighter {
  from {
    background: @primary_color;
  }
  to {
    width: 0;
    background: transparent;
  }
}
@keyframes inputHighlighter {
  from {
    background: @primary_color;
  }
  to {
    width: 0;
    background: transparent;
  }
}
