/**Variable**/
@import './helpers/mixin.scss';
@import './base/common.scss';

/*radio-group*/
.vhb-radio-group {
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  font-size: 0;
  &+.vhb-radio-group {
    margin-left: 10px;
  }
}

/*radio*/
.vhb-radio {
  display: inline-block;
  vertical-align: middle;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
  cursor: pointer;
  color: $vhb-font-color;
  > input {
    &[type="radio"] {
      position: absolute;
      width: 0;
      height: 0;
      border: 0;
      appearance: none;
    }
    &+.vhb-radio--icon {
      position: relative;
      display: inline-block;
      width: 1em;
      height: 1em;
      border: $vhb-radio-border-width solid $vhb-input-border-color;
      background-color: $vhb-radio-icon-background-color;
      vertical-align: middle;
      border-radius: 50%;
    }
    &:checked+.vhb-radio--icon {
      background-color: $vhb-primary-color;
      border-color: $vhb-primary-color;
      &:before {
        content: "";
        position: absolute;
        background-color: $vhb-radio-checked-icon-background-color;
        border-radius: 50%;
        height: 0.25em;
        width: 0.25em;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
      }
      &+.vhb-radio--label {
        color: $vhb-primary-color;
      }
    }
  }
  &:not(.is--disabled) {
    & > input {
      &:focus {
        &+.vhb-radio--icon {
          border-color: $vhb-primary-color;
          box-shadow: 0 0 0.2em 0 $vhb-primary-color;
        }
      }
    }
    &:hover {
      > input {
        &+.vhb-radio--icon {
          border-color: $vhb-primary-color;
        }
      }
    }
  }
  &.is--disabled {
    cursor: not-allowed;
    > input {
      &+.vhb-radio--icon {
        border-color: $vhb-input-disabled-color;
        background-color: $vhb-input-disabled-background-color;
        &:before {
          border-color: $vhb-primary-disabled-color;
          background-color: $vhb-primary-disabled-color;
        }
        &+.vhb-radio--label {
          color: $vhb-disabled-color;
        }
      }
    }
  }
  .vhb-radio--label {
    padding-left: 0.5em;
    vertical-align: middle;
    display: inline-block;
    max-width: 50em;
    @extend %TextEllipsis;
  }
  &:not(.vhb-radio-button) {
    &+.vhb-radio {
      margin-left: 10px;
    }
  }
}

.vhb-radio-button {
  .vhb-radio--label {
    background-color: $vhb-radio-button-default-background-color;
  }
  &:first-child {
    .vhb-radio--label {
      border-left: 1px solid $vhb-input-border-color;
      border-radius: $vhb-border-radius 0 0 $vhb-border-radius;
    }
  }
  &:last-child {
    .vhb-radio--label {
      border-radius: 0 $vhb-border-radius $vhb-border-radius 0;
    }
  }
  > input {
    &:checked+.vhb-radio--label {
      color: #fff;
      background-color: $vhb-primary-color;
      border-color: $vhb-primary-color;
    }
  }
  .vhb-radio--label {
    padding: 0 1em;
    line-height: $vhb-button-height-default - 2;
    display: inline-block;
    border-style: solid;
    border-color: $vhb-input-border-color;
    border-width: 1px 1px 1px 0;
    max-width: 50em;
    @extend %TextEllipsis;
  }
  &.is--disabled {
    cursor: not-allowed;
    > input {
      &:not(:checked) {
        &+.vhb-radio--label {
          color: $vhb-input-disabled-color;
        }
      }
      &:checked {
        &+.vhb-radio--label {
          border-color: lighten($vhb-primary-color, 20%);
          background-color: lighten($vhb-primary-color, 20%);
        }
      }
    }
  }
  &:not(.is--disabled) {
    & > input {
      &:focus {
        &+.vhb-radio--label {
          border-color: $vhb-primary-color;
          box-shadow: 0 0 0.2em 0 $vhb-primary-color;
        }
      }
    }
    &:hover {
      > input {
        &:not(:checked) {
          &+.vhb-radio--label {
            color: $vhb-primary-color;
          }
        }
      }
    }
  }
  &.size--medium {
    .vhb-radio--label {
      line-height: $vhb-button-height-medium - 2;
    }
  }
  &.size--small {
    .vhb-radio--label {
      line-height: $vhb-button-height-small - 2;
    }
  }
  &.size--mini {
    .vhb-radio--label {
      line-height: $vhb-button-height-mini - 2;
    }
  }
}

.vhb-radio {
  font-size: $vhb-font-size;
  .vhb-radio--icon {
    font-size: $vhb-radio-font-size-default;
  }
  &.size--medium {
    font-size: $vhb-font-size-medium;
    .vhb-radio--icon {
      font-size: $vhb-radio-font-size-medium;
    }
  }
  &.size--small {
    font-size: $vhb-font-size-small;
    .vhb-radio--icon {
      font-size: $vhb-radio-font-size-small;
    }
  }
  &.size--mini {
    font-size: $vhb-font-size-mini;
    .vhb-radio--icon {
      font-size: $vhb-radio-font-size-mini;
    }
  }
}