/* Containers and Labels for Checkbox/Radio */
.bs-boolean {
  display: inline-flex;
  align-items: center;
  font-size: var(--bs-text-base);
  font-weight: 400;
  line-height: 115%;
}

.bs-boolean:where([data-size="sm"]) input {
  width: var(--bs-text-xs);
  height: var(--bs-text-xs);
}

.bs-boolean label {
  font-size: var(--bs-text-base);
  font-weight: 400;
  line-height: 1.5;
  width: auto;
}

/* not using gap on .bs-boolean due to dead click zone */
.bs-boolean label {
  padding-inline-end: 0.5em;
}

.bs-boolean input + label {
  padding-inline: 0.5em 0;
}

.bs-boolean:where([data-size="sm"]),
.bs-boolean:where([data-size="sm"]) label {
  font-size: var(--bs-text-xs);
}

/* Checkbox & Radio Input */
:where(input[type="checkbox"], input[type="radio"]) {
  --box-shadow: var(--bs-ink-base);
  appearance: none;
  background-color: var(--bg-base);
  box-shadow: inset 0 0 0 0.125rem var(--box-shadow);
  cursor: pointer;
  display: grid;
  height: 1rem;
  margin: 0;
  place-content: center;
  position: relative;
  width: 1rem;
}

:where(input[type="checkbox"], input[type="radio"]):focus-visible {
  box-shadow: inset 0 0 0 0.125rem var(--box-shadow), 0 0 0 2px var(--offset-color, var(--bs-bg-base)), 0 0 0 4px var(--outline-color, var(--bs-blue-base));
  outline: 2px solid transparent;
}

:where(input[type="checkbox"]) {
  border-radius: 0.125rem;
}

:where(input[type="radio"]) {
  border-radius: 50%;
}

/* Checkbox's checkmark  */
input:where([type="checkbox"])::before {
  --filled-size: 1rem;
  --check-fill-color: var(--bs-blue-base);
  content: "";
  border-radius: 0.125rem;
  box-shadow: inset var(--filled-size) var(--filled-size) var(--check-fill-color);
  height: var(--filled-size);
  visibility: hidden;
  width: var(--filled-size);
}

input:where([type="checkbox"])::after {
  border: solid var(--bs-white);
  border-width: 0 0.125rem 0.125rem 0;
  content: "";
  height: 0.75em;
  left: 50%;
  position: absolute;
  top: 50%;
  transform-origin: center;
  transform: translate(-50%, -60%) rotate(45deg);
  visibility: hidden;
  width: 0.375em;
}

input:where([type="checkbox"]):where(:indeterminate)::after {
  border: none;
  background-color: var(--bs-white);
  height: 0.125rem;
  transform: translate(-50%, -0.0625rem) rotate(0deg);
  width: 0.625em;
}

/* Radio's dot */
input:where([type="radio"])::before {
  --filled-size: 1rem;
  --radio-fill-color: var(--bs-blue-base);
  background-color: var(--radio-fill-color);
  border-radius: 50%;
  box-sizing: content-box;
  content: "";
  height: var(--filled-size);
  visibility: hidden;
  width: var(--filled-size);
}

input:where([type="radio"])::after {
  --inner-size: 0.375rem;
  --inner-fill-color: var(--bs-white);
  background-color: var(--inner-fill-color);
  border-radius: 50%;
  box-sizing: content-box;
  content: "";
  height: var(--inner-size);
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  visibility: hidden;
  width: var(--inner-size);
}

input:where([type="checkbox"]:checked, [type="checkbox"]:indeterminate, [type="radio"]:checked)::before,
input:where([type="checkbox"]:checked, [type="checkbox"]:indeterminate, [type="radio"]:checked)::after {
  visibility: visible;
}

.bs-boolean:where([data-size="sm"]) input::before {
  --filled-size: var(--bs-text-xs);
}

.bs-boolean:where([data-size="sm"]) input[type=checkbox]::after {
  height: 0.5625rem;
  width: 0.3125rem;
}

.bs-boolean:where([data-size="sm"]) input[type=checkbox]:where(:indeterminate)::after {
  height: 0.125rem;
  width: 0.75em;
}

.bs-boolean:where([data-size="sm"]) input[type=radio]::after {
  --inner-size: 0.25rem;
}

/* Disabled State */
input:where([type="checkbox"], [type="radio"]):disabled {
  --box-shadow: var(--bs-bg-disabled);
  background-color: transparent;
  cursor: default;
}

input:where([type="checkbox"]):checked:disabled::before,
input:where([type="checkbox"]):indeterminate:disabled::before {
  --check-fill-color: var(--bs-bg-disabled);
}

input:where([type="radio"]):checked:disabled::before {
  --radio-fill-color: var(--bs-bg-disabled);
}

/* Error state */
input:where([type="checkbox"], [type="radio"])[data-error] {
  --box-shadow: var(--bs-red-base);
  --outline-color: var(--bs-red-base);
}

bs-switch {
  /* Toggle "ball" */
  /* Inner "on/off" text */
  /* Focus state */
  /* Disabled state */
}
bs-switch .bs-switch {
  --box-shadow: var(--bs-ink-base);
  --ball-background: var(--bs-white);
  --ball-diameter: 1rem;
  --inner-text-width: 1rem;
  --inner-text-padding: 0.5rem;
  --offset: 0.25rem;
  --switch-background: var(--bs-gray-400);
  border: none;
  border-radius: 100vw;
  cursor: pointer;
  height: calc(var(--ball-diameter) + var(--offset) * 2);
  position: relative;
}
bs-switch .bs-switch:where([data-size="sm"]) {
  --ball-diameter: var(--bs-text-xs);
  --inner-text-width: .75rem;
  --inner-text-padding: 0.375rem;
}
bs-switch .bs-switch input,
bs-switch .bs-switch:where([data-size="sm"]) input {
  cursor: pointer;
  height: 100%;
  opacity: 0;
  position: absolute;
  width: 100%;
}
bs-switch .bs-switch span {
  align-items: center;
  background-color: var(--switch-background);
  border-radius: 100vw;
  display: inline-flex;
  height: 100%;
  padding: 0 var(--inner-text-padding);
  pointer-events: none;
  position: relative;
  transition: 250ms;
  width: calc(var(--ball-diameter) * 2 + var(--offset) * 2);
  height: calc(var(--ball-diameter) + var(--offset) * 2);
}
bs-switch .bs-switch input:where(:checked) ~ span,
bs-switch .bs-switch:where([aria-pressed]):where(:not([aria-pressed="false"])) span {
  --switch-background: var(--bs-blue-base);
}
bs-switch .bs-switch span::before {
  background-color: var(--ball-background);
  border-radius: 50%;
  box-sizing: border-box;
  content: "";
  height: var(--ball-diameter);
  left: var(--offset);
  position: absolute;
  top: 50%;
  transform: translate(0, -50%);
  transition: inherit;
  width: var(--ball-diameter);
  z-index: 2;
}
bs-switch .bs-switch input:where(:checked) ~ span::before,
bs-switch .bs-switch:where([aria-pressed]):where(:not([aria-pressed="false"])) span::before {
  transform: translate(var(--ball-diameter), -50%);
}
bs-switch .bs-switch input:where(:checked) ~ span:where([data-inner-on-label][data-inner-off-label])::before,
bs-switch .bs-switch:where([aria-pressed]):where(:not([aria-pressed="false"])) span:where([data-inner-on-label][data-inner-off-label])::before {
  transform: translate(calc(var(--ball-diameter) + var(--inner-text-width)), -50%);
}
bs-switch .bs-switch span:where([data-inner-on-label][data-inner-off-label]) {
  color: white;
  width: calc(var(--ball-diameter) * 2 + var(--offset) * 2 + var(--inner-text-width));
}
bs-switch .bs-switch span::after {
  align-items: center;
  color: var(--ball-background);
  display: flex;
  height: 100%;
  justify-content: flex-start;
  left: 0;
  padding: var(--inner-text-padding);
  position: absolute;
  text-transform: capitalize;
  top: 0;
  width: 100%;
}
bs-switch .bs-switch input:where(:not(:checked)) ~ span:where([data-inner-on-label][data-inner-off-label])::after,
bs-switch .bs-switch:where([aria-pressed="false"]) span:where([data-inner-on-label][data-inner-off-label])::after {
  content: attr(data-inner-off-label);
  justify-content: flex-end;
}
bs-switch .bs-switch input:where(:checked) ~ span:where([data-inner-on-label][data-inner-off-label])::after,
bs-switch .bs-switch:where([aria-pressed]):where(:not([aria-pressed="false"])) span:where([data-inner-on-label][data-inner-off-label])::after {
  content: attr(data-inner-on-label);
  justify-content: flex-start;
}
bs-switch .bs-switch :where(input:focus-visible) + span {
  box-shadow: 0 0 0 2px var(--offset-color, var(--bs-bg-base)), 0 0 0 4px var(--outline-color, var(--bs-blue-base));
  outline: 2px solid transparent;
}
bs-switch :where(.box) .bs-switch :where(input:focus-visible) + span {
  --offset-color: var(--bs-bg-medium);
}
bs-switch :where(.box[data-invert]) .bs-switch :where(input:focus-visible) + span {
  --offset-color: var(--bs-bg-invert-base);
}
bs-switch .bs-switch:where([data-disabled]) {
  --ball-background: var(--bs-ink-disabled);
  --switch-background: var(--bs-bg-disabled);
}
bs-switch .bs-switch input:where(:disabled) {
  cursor: default;
}