/* ========================================================================
   Component: form-elements.less
 ========================================================================== */
 
/**
 * Custom form elements
 *    - Checkbox 
 *    - Radios
 *    - Switch
 *    - Rounded inputs
 */

//
// CHECKBOX AND RADIOS
// 

@ui-fg-color: @brand-primary;
@ui-bg-color: #ddd;

.c-checkbox,
.c-radio {
  margin-right: 4px;
  * {
    cursor: pointer;
  }
  input {
    opacity: 0;
    position: absolute;
    margin-left: 0 !important;
  }
  
  // the element that replaces the input
  span {
    position: relative;
    display: inline-block;
    vertical-align: top;
    margin-left: -20px;
    width: 20px; height: 20px;
    border-radius: 2px;
    border: 1px solid #ccc;
    margin-right: 5px;
  }

  &:hover span {
    border-color: @ui-fg-color;
  }

  .form-inline & span {
    margin-left: 0;
  }

  &.c-checkbox-rounded,
  &.c-radio-rounded {
    span {
      border-radius: 500px;
    }
  }
}

/* override for radio */
.c-radio span {
  border-radius: 500px;
}

/* the icon */
.c-checkbox,
.c-radio {
  span:before {
    //content: "\2713"; /* comment content to use custom icon classes */
    position: absolute;
    top: 0; left: 0;  right: 0; bottom: 0;
    opacity: 0;
    text-align: center !important;
    font-size: 12px;
    line-height: 18px;
    vertical-align: middle;
  }
}


/* Checked state */

input[type=checkbox]:checked + span:before,
input[type=radio]:checked + span:before{
  color: #fff;
  opacity: 1;
  transition: color .3 ease-out;
}

input[type=checkbox]:checked + span,
input[type=radio]:checked + span {
  border-color: @ui-fg-color;
  background-color: @ui-fg-color;
}

/* override for radio */
input[type=radio]:checked + span{
  background-color: #fff;
  &:before{ 
    color: @ui-fg-color;
  }
}

/* Disable state */

input[type=checkbox]:disabled + span,
input[type=radio]:disabled + span{
  border-color: @ui-bg-color !important;
  background-color: @ui-bg-color !important;
}
/* override for radio */
input[type=radio]:disabled + span {
  background-color: #fff !important;
  &:before {
    color: @ui-bg-color;
  }
}


//
// Form Rounded
//

.form-control-rounded {
  border-radius: 100px;
}

//
// Form SWITCH
//

@switch-wd: 60px;
@switch-hg: @switch-wd/2;

.switch * {
  cursor: pointer;
}

.switch input {
  opacity: 0;
  position: absolute;
  z-index: -1;
}
.switch span {
  position: relative;
  display: inline-block;
  width: @switch-wd; height: @switch-hg;
  background-color: #fff;
  border: 1px solid @ui-bg-color;
  border-radius: 100px;
  transition: all .5s;
  box-shadow: 1px 2px 3px rgba(0,0,0,0.1) inset;
}

.switch span:after {
 content: "";
 position: absolute;
 background-color: #fff;
 top: 0; left: 0;
 height: @switch-hg - 2; width: @switch-hg - 2;
 border: 1px solid #ddd;
 border-radius: 400px;
 box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
 -webkit-transition: all .2s;
}

.switch input:checked + span {
  background-color: @ui-fg-color;
  border-color: @ui-fg-color;
  transition: all .5s;
}

.switch input:checked + span:after {
  left: 50%;
  transition: all .2s;
}


// Support form feedback without labels
.has-feedback {
  .form-control-feedback {
    top: 0;
  }
}

.form-control-feedback {
  label + .form-control + & {
    top: 25px;
  }
}
