onclick radio button active color change using css

when we click on the radio button background color and label color will change I have written CSS but it is not working. I don’t want to change my HTML structure with my code only how can I add color to the label on active. Can anyone suggest me.

const handleVisibility = (e) => {
  e.target.closest('.case-inner-info').querySelectorAll('.inner_div [data-ref]').forEach(i => i.style.display = i.dataset.ref === e.target.dataset.ref ? 'block' : 'none');
}
const allOnOffButtons = document.querySelectorAll("div.case-inner-info input");
allOnOffButtons.forEach(button => {
  button.addEventListener('click', handleVisibility);
})
.switch-label {
  position: relative;
  width: 58px;
  float: left;
  line-height: 26px;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  cursor: pointer;
  color: #051326;
  z-index: 2;
}

.switch-input {
  display: none;
}

.switch-input:checked .switch-label {
  color: #fff;
  -webkit-transition: 0.15s ease-out;
  -o-transition: 0.15s ease-out;
  transition: 0.15s ease-out;
  -webkit-transition-property: color;
  -o-transition-property: color;
  transition-property: color;
}

.switch-input:checked+.switch-label-off~.switch-selection {
  left: 60px;
}

.switch-selection {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  position: absolute;
  left: 0;
  width: 70px;
  height: 40px;
  border-radius: 4px;
  color: #fff;
  z-index: 1;
  -webkit-transition: left 0.15s ease-out;
  -o-transition: left 0.15s ease-out;
  transition: left 0.15s ease-out;
}

.case-switch .switch-selection {
  background-color: red;
}
<div class="case-inner-info">
  <div class="case-switch-wrap">
    <div class="inner_div">
      <div class="case-info" data-ref="on">
        <p> Paragrapgh1</p>
      </div>
      <div class="case-code-wrap" style="display: none;" data-ref="off">
        <p> Paragrapgh2</p>
      </div>
    </div>
    <div class="case-switch">
      <label class="switch-label switch-label-on">
      <input type="radio" class="switch-input" name="switch-toggle" data-ref="on" checked>
      On</label>
      <label class="switch-label switch-label-off">
      <input type="radio" class="switch-input" name="switch-toggle" data-ref="off">
      Off</label>
      <span class="switch-selection"></span>
    </div>
  </div>
</div>

Answer

Please check this, if this is something resolves your issue, I have removed the span

<div class="case-inner-info">
  <div class="case-switch-wrap">
    <div class="inner_div">
      <div class="case-info" data-ref="on">
        <p> Paragrapgh1</p>
      </div>
      <div class="case-code-wrap" style="display: none;" data-ref="off">
        <p> Paragrapgh2</p>
      </div>
    </div>
    <div class="case-switch">
      <label class="switch-label switch-label-on">
      <input type="radio" class="switch-input" name="switch-toggle" data-ref="on" checked>
      On</label>
      <label class="switch-label switch-label-off">
      <input type="radio" class="switch-input" name="switch-toggle" data-ref="off">
      Off</label>
      
    </div>
  </div>
</div>
const allOnOffButtons = document.querySelectorAll("div.case-inner-info input");
const handleVisibility = (e) => {
  
  e.target.closest('.case-inner-info').querySelectorAll('.inner_div [data-ref]')
  .forEach(i => 
     i.style.display = i.dataset.ref === e.target.dataset.ref ? 'block' : 'none');
     allOnOffButtons.forEach(i => i.parentNode.style.backgroundColor = i.dataset.ref === e.target.dataset.ref ? 'red' : 'transparent');
}

allOnOffButtons.forEach(button => {
  button.addEventListener('click', handleVisibility);
})

Here is the codepen