// Radio Buttons
//================================================== //

@mixin radio-unchecked-before-style {
  background-color: $radio-color-unchecked-initial-background;
  border: 1px solid $radio-color-unchecked-initial-border;
  border-radius: 50%;
  content: '';
  height: 14px;
  margin-left: -25px;
  position: absolute;
  width: 14px;
}

@mixin radio-checked-before-style {
  background-color: $radio-color-checked-initial-fill;
  border: 4px solid $radio-color-checked-initial-fill;
  height: 8px;
  width: 8px;
  transition: none;
}

@mixin radio-checked-after-style {
  background-color: $radio-color-checked-initial-background;
  border: 4px solid $radio-color-checked-initial-fill;
  border-radius: 50%;
  content: '';
  height: 8px;
  position: absolute;
  transition: all 0.2s ease 0s;
  width: 8px;
  left: 1px
}

.radio {
  margin: 0;
  opacity: 0;
  padding: 0;
  position: absolute;
  width: 0;
}

// Radio with hitbox
.radio.hitbox {
  + .radio-label {
    display: inline-flex;
    -webkit-box-align: center;
    align-items: center;
    vertical-align: middle;
    min-width: 44px;
    height: 44px;
    padding-left: 38px;
    padding-right: 14px;
  }

  + label {
    &::before {
      margin-top: 0;
    }

    &::after {
      left: 13px;
    }
  }
}

.inline-radio {
  margin-bottom: 0;
}

.inline .radio ~ .label-text,
.radio + label {
  color: $label-color;
  cursor: pointer;
  font-size: $input-size-regular-font-size;
  line-height: 20px;
  margin-block: 8px;
  outline: none;
  padding-left: 26px;
  padding-right: 10px;
  position: relative;
}

.inline .radio ~ .label-text::before,
.radio + label::before {
  @include radio-unchecked-before-style;
}

.inline .radio ~ .label-text::before {
  margin-top: 2px;
}

.inline .radio:hover ~ .label-text::before,
.radio:hover + label::before {
  @include css3(transition, border-color 300ms ease);

  border-color: $radio-color-unchecked-hover-border;
}

.inline .radio ~ .label-text,
.radio-label {
  display: inline-flex;
  line-height: 20px;
  align-items: center;
}

.inline .radio ~ .label-text::after,
.radio + label::after {
  @include radio-checked-after-style;
}

.inline .radio ~ .label-text::after {
  top: 6px;
}

.inline .radio:checked ~ .label-text::before,
.radio:checked + label::before {
  @include radio-checked-before-style;
}

// checked mark aspect changes
.inline .radio:not(:checked) ~ .label-text::after,
.radio:not(:checked) + label::after {
  @include opacity(0);

  transform: scale(0);
}

.inline .radio:checked ~ .label-text::after,
.radio:checked + label::after {
  @include opacity(1);

  transform: scale(1);
}

// disabled radio
.inline .radio:disabled ~ .label-text::before,
.radio:disabled + label::before {
  background-color: $radio-color-unchecked-disabled-background;
  border-color: $radio-color-disabled-border;
  cursor: default;
}

.inline .radio:disabled:checked ~ .label-text::before,
.radio:disabled:checked + label::before {
  background-color: $radio-color-unchecked-disabled-border;
  border-color: $radio-color-unchecked-disabled-border;
  cursor: default;
}

.inline .radio:disabled:checked ~ .label-text::before,
.radio:disabled:checked + label::after {
  background-color: $radio-color-checked-disabled-background;
  border-color: $radio-color-checked-disabled-border;
}

.inline .radio:disabled ~ .label-text,
.radio:disabled + label {
  color: $radio-color-disabled-label;
  cursor: default;
}

.inline .radio:not(.hide-focus):focus ~ .label-text::before,
.radio:not(.hide-focus):focus + label::before {
  box-shadow: 0 0 0 3px $radio-color-checked-initial-fill;
  outline: solid 2px $radio-focus-border-color;
}

// Print Support
@media print {
  .inline .radio ~ .label-text::before,
  .radio + label::before {
    content: none;
  }

  .radio {
    left: auto;
    position: static;
    width: auto;
  }

  .inline .radio ~ .label-text,
  .radio + label {
    padding-left: 9px;
  }

  .inline .radio ~ .label-text::after,
  .radio + label::after {
    border: 0;
  }
}

.radio-group {
  margin-bottom: $input-field-bottom-margin;
  margin-top: 0;
  position: relative;

  legend {
    color: $label-color;
    font-size: $input-size-regular-font-size;
    padding-bottom: 5px !important;
    position: relative;
  }

  &.is-disabled,
  &[disabled] {
    legend {
      color: $disabled-color;
    }
  }

  .field {
    margin-bottom: 0;
  }

  + .field {
    margin-top: 20px;
  }

  .icon-dirty {
    left: -1px;
    margin-top: 1px;
  }
}

.field {
  .radio-group {
    margin-bottom: -13px;
  }
}

.field-short,
.form-layout-compact .field {
  .radio-group {
    margin-bottom: -6px;
  }
}

// Radio Section
//================================================== //
.radio-section {
  margin-bottom: 10px !important;
  margin-top: 30px;

  .option {
    padding-left: 0;

    .btn-primary {
      margin-top: inherit;
      padding: inherit;

      &[disabled] {
        border: 0;
      }
    }

    .large-txt {
      font-size: $ids-size-font-base;
    }

    .line-through {
      text-decoration: line-through;
    }

    .radio-label {
      margin-bottom: 2.3em;

      .in-label {
        font-size: $label-size-regular-font-size;
        line-height: 25px;
        margin-top: -10px;
      }

      span {
        display: block;
      }
    }

    &:first-child {
      margin-left: 0;
      position: relative;

      &::after {
        border-right: 1px solid $ids-color-palette-slate-30;
        bottom: 15px;
        content: ' ';
        position: absolute;
        right: 0;
        top: 15px;
      }
    }
  }
}

.info {
  .radiosection .option {
    margin-left: inherit;

    &:first-child {
      margin-right: 10px;
    }
  }

  .row:last-child {
    margin-bottom: 0;
  }
}

@include respond-to(tabletdown) {
  .radio-section .option {
    margin-left: 0;
    text-align: left;
    width: 95%;

    .row:last-child {
      margin-bottom: 0;
    }

    &:first-child {
      margin-right: inherit;
      position: static;

      &::after {
        display: none;
      }
    }

    &:not(:first-child) {
      border-top: 1px solid $ids-color-palette-slate-30;
      padding-top: 15px;
    }
  }
}

// RTL Styles
html[dir='rtl'] {
  .radio {
    margin-left: inherit;
    margin-right: 7px;
  }

  .inline .radio ~ .label-text,
  .radio + label {
    padding-right: 27px;
  }

  .inline .radio ~ .label-text::before,
  .radio + label::before {
    margin-left: inherit;
    margin-right: -27px;
  }

  .inline .radio ~ .label-text::after,
  .radio + label::after {
    left: auto;
    right: 0;
  }

  // Adjust the label padding for RTL in short mode
  .field-short,
  .form-layout-compact .field {
    .inline .radio ~ .label-text,
    .radio + label {
      padding-right: 24px;
    }

    .inline .radio ~ .label-text::before,
    .radio + label::before {
      margin-right: -24px;
    }
  }

  // Radio Section
  .radio-section {
    .option {
      padding-left: inherit;
      padding-right: 0;

      &:first-child {
        margin-left: inherit;
        margin-right: 0;

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

  .info {
    .radiosection .option {
      margin-right: inherit;

      &:first-child {
        margin-left: inherit;
        margin-right: 10px;
      }
    }
  }

  @include respond-to(tabletdown) {
    .radio-section .option {
      margin-left: inherit;
      margin-right: 0;
      text-align: right;

      &:first-child {
        margin-left: inherit;
      }
    }
  }

  .radio.hitbox {
    + .radio-label {
      display: inline-flex;
      -webkit-box-align: center;
      align-items: center;
      vertical-align: middle;
      min-width: 44px;
      height: 44px;
      padding-right: 38px;
      padding-left: 14px;
    }

    + label {
      &::before {
        margin-top: 0;
      }

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

}

// Short Fields
.field-short,
.form-layout-compact .field {
  .radio-group legend {
    font-size: $input-size-compact-font-size;
    padding-bottom: 20px !important;
  }

  .radio-group {
    margin-bottom: -10px;
  }

  .inline .radio ~ .label-text,
  .radio + label {
    margin-top: -14px;
    padding-left: 20px;
    padding-top: 5px !important;
    text-align: initial;
    width: auto;
  }

  .inline .radio ~ .label-text::after,
  .radio + label::after {
    left: 4px;
    margin-left: -4px;
  }

  .inline .radio ~ .label-text::before,
  .radio + label::before {
    margin-left: -20px;
  }

  .inline .radio ~ .label-text.radio-label:first-of-type,
  .radio-label.radio-label:first-of-type {
    margin-top: -22px;
  }
}

.field-short,
.form-layout-compact .field {
  > .radio-label.radio-label:first-of-type {
    margin-top: -23px;
  }
}

.radio-group,
.form-layout-compact .field .radio-group {
  .field-short:first-of-type {
    margin-bottom: 8px;
    margin-top: 19px;
  }

  .field-short {
    margin-bottom: 8px;
  }
}

.field-short {
  .radio + label {
    &::before,
    &::after {
      margin-top: 4px;
    }
  }
}

// Error States
.inline .radio.error ~ .label-text,
.radio.error + label {
  color: $error-color;

  &::before {
    border-color: $error-color;
  }
}

// disabled radio
.inline .radio.error:disabled ~ .label-text,
.radio.error:disabled + label {
  color: rgba($error-color, 0.4);

  &::before {
    border-color: rgba($error-color, 0.4);
  }
}

.radio-group-error {
  margin-left: 2px;
  margin-top: 5px;
}
