/* ------------------------------------------------ */
/* ############### 3.5 Custom Forms ############### */
/* ------------------------------------------------ */

/* Checkbox */
.ckbox {
  font-weight: normal;
  position: relative;
  display: block;
  line-height: 18px;

  span {
    padding-left: 6px;

    &:empty { float: left; }

    &:before,
    &:after {
      line-height: 18px;
      position: absolute;
    }

    &:before {
      content: '';
      width: $ckbox-size;
      height: $ckbox-size;
      background-color: #fff;
      border: 1px solid $gray-500;
      border-radius: 2px;
      top: 1px;
      left: 0;
    }

    &:after {
      top: 1px;
      left: 0;
      width: $ckbox-size;
      height: $ckbox-size;
      content: '\f122';
      font-family: 'Ionicons';
      font-size: 9px;
      text-align: center;
      color: #fff;
      background-color: theme-color('primary');
      line-height: 1.65;
      border-radius: 2px;
      display: none;
    }
  }

  input[type='checkbox'] {
    opacity: 0;
    margin: 0 5px 0 0;

    &:checked {
      + span:after { display: block; }
    }

    &[disabled] {
      + span,
      + span:before,
      + span:after {
        opacity: .75;
      }
    }
  }
}

.ckbox-inline { display: inline-block; }

/* Checkbox color variant */
.ckbox-success { span::after { background-color: theme-color('success'); } }
.ckbox-warning { span::after { background-color: theme-color('warning'); } }
.ckbox-danger { span::after { background-color: theme-color('danger'); } }
.ckbox-info { span::after { background-color: theme-color('info'); } }
.ckbox-indigo { span::after { background-color: $indigo; } }
.ckbox-purple { span::after { background-color: $purple; } }
.ckbox-pink { span::after { background-color: $pink; } }
.ckbox-orange { span::after { background-color: $orange; } }
.ckbox-teal { span::after { background-color: $teal; } }
.ckbox-dark { span::after { background-color: $gray-800; } }

/* Radio Box */
.rdiobox {
  font-weight: normal;
  position: relative;
  display: block;
  line-height: 18px;

  span {
    padding-left: 6px;

    &:before,
    &:after {
      line-height: 18px;
      position: absolute;
    }

    &:before {
      content: '';
      width: $rdiobox-size;
      height: $rdiobox-size;
      background-color: #fff;
      border: 1px solid $gray-500;
      border-radius: 50px;
      top: 2px;
      left: 0;
    }

    &:after {
      content: '';
      width: $rdiobox-size - 10px;
      height: $rdiobox-size - 10px;
      background-color: #fff;
      border-radius: 50px;
      top: 7px;
      left: 5px;
      display: none;
    }
  }

  input[type='radio'] {
    opacity: 0;
    margin: 0 5px 0 0;

    &:checked {
      + span:before {
        border-color: transparent;
        background-color: theme-color('primary');
      }
      + span:after { display: block; }
    }

    &[disabled] {
      + span,
      + span:before,
      + span:after {
        opacity: .75;
      }
    }
  }
}

.rdiobox-inline { display: inline-block; }

/* Radiobox Color Variant */
.rdiobox-success { @include rdiobox-color-variant(theme-color('success')); }
.rdiobox-warning { @include rdiobox-color-variant(theme-color('warning')); }
.rdiobox-danger { @include rdiobox-color-variant(theme-color('danger')); }
.rdiobox-info { @include rdiobox-color-variant(theme-color('info')); }
.rdiobox-indigo { @include rdiobox-color-variant($indigo); }
.rdiobox-purple { @include rdiobox-color-variant($purple); }
.rdiobox-orange { @include rdiobox-color-variant($orange); }
.rdiobox-pink { @include rdiobox-color-variant($pink); }
.rdiobox-teal { @include rdiobox-color-variant($teal); }
.rdiobox-dark { @include rdiobox-color-variant($gray-800); }


/* Inside input group */
.input-group-text, {
  .ckbox,
  .rdiobox {
    &,input { margin: 0; }
  }
}


/* File Browser */
.custom-file { direction: ltr; }
.custom-file-label-primary::after {
  background-color: theme-color('primary');
  border-color: transparent;
  color: #fff;
}

.custom-file-label-inverse::after {
  background-color: $gray-800;
  border-color: transparent;
  color: #fff;
}

.custom-file-label-primary,
.custom-file-label-inverse {
  &::after {
    top: -1px;
    bottom: -1px;
    right: -1px;
    height: auto;
  }
}


/* Switch Button */
.br-switchbutton {
  margin: 0 25px;
  position: relative;
  background-color: rgba(#fff, .08);
  width: 30px;
  height: 15px;
  @include border-radius(2px);
  cursor: pointer;

  &::before,
  &::after {
    text-transform: uppercase;
    font-family: $font-family-roboto;
    position: absolute;
    top: 2px;
    font-size: 11px;
    display: block;
    line-height: 1.3;
  }

  &::before {
    content: 'off';
    left: -25px;
    color: $teal;
  }

  &::after {
    content: 'on';
    right: -20px;
    color: $body-color;
  }

  span {
    position: absolute;
    background-color: #fff;
    @include border-radius(2px);
    top: 2px;
    bottom: 2px;
    left: 2px;
    width: 11px;
    box-shadow: 0 0 2px rgba($gray-900, .3);
    @include transition($transition-base);
  }

  &.checked {
    background-color: $teal;
    &::before { color: $body-color; }
    &::after { color: $teal; }
    span { left: 17px; }
  }
}

/* ########## RTL SUPPORT ########## */

.rtl {
  .ckbox {
    span {
      padding-left: 0;
      padding-right: 6px;

      &:empty { float: right; }

      &:before,
      &:after {
        left: auto;
        right: 0;
      }
    }

    input[type='checkbox'] { margin: 0 0 0 5px; }
  }

  .rdiobox {
    span {
      padding-left: 0;
      padding-right: 6px;

      &:before {
        left: auto;
        right: 0;
      }

      &:after {
        left: auto;
        right: 5px;
      }
    }

    input[type='radio'] { margin: 0 0 0 5px; }
  }
}
