.bootcn-switch {
  --bootcn-switch-width: 2.25rem;
  --bootcn-switch-height: 1.25rem;
  --bootcn-switch-gap: 0.75rem;

  display: grid;
  grid-template-columns: var(--bootcn-switch-width) 1fr;
  column-gap: var(--bootcn-switch-gap);
  align-items: start;
  padding-inline-start: 0;
}

.bootcn-switch--lg {
  --bootcn-switch-width: 3rem;
  --bootcn-switch-height: 1.625rem;
}

.bootcn-switch .bootcn-switch__input {
  width: var(--bootcn-switch-width);
  height: var(--bootcn-switch-height);
  margin: 0;
  margin-inline-start: 0;
  /* Off: a muted track with a visible border (3:1). */
  border-color: var(--bootcn-ring);
  background-color: var(--bootcn-input);
  cursor: pointer;
}

.bootcn-switch .bootcn-switch__input:checked {
  border-color: var(--bootcn-primary);
  background-color: var(--bootcn-primary);
}

/*
 * Thumb color. Bootstrap draws the thumb from --bs-form-switch-bg and sets it
 * in several state rules (checked, focus, dark + unchecked), so these
 * selectors repeat the classes to win in every state: light thumb, except
 * when on in dark mode, where the track is light and the thumb dark.
 */
.form-switch.bootcn-switch .form-check-input.bootcn-switch__input,
.form-switch.bootcn-switch .form-check-input.bootcn-switch__input:focus,
.form-switch.bootcn-switch .form-check-input.bootcn-switch__input:checked {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

[data-bs-theme='dark']
  .form-switch.bootcn-switch
  .form-check-input.bootcn-switch__input:not(:checked),
[data-bs-theme='dark']
  .form-switch.bootcn-switch
  .form-check-input.bootcn-switch__input:not(:checked):focus {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fafafa'/%3e%3c/svg%3e");
}

[data-bs-theme='dark'] .form-switch.bootcn-switch .form-check-input.bootcn-switch__input:checked {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%2318181b'/%3e%3c/svg%3e");
}

.bootcn-switch .bootcn-switch__input:focus-visible {
  border-color: var(--bootcn-primary);
  outline: 0;
  box-shadow: var(--bootcn-focus-ring);
}

.bootcn-switch .bootcn-switch__input:focus:not(:focus-visible) {
  box-shadow: none;
}

.bootcn-switch .bootcn-switch__input:disabled {
  cursor: not-allowed;
}

.bootcn-switch__label {
  grid-column: 2;
  align-self: center;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.bootcn-switch__description {
  grid-column: 2;
  margin: 0.125rem 0 0;
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
}

@media (prefers-reduced-motion: reduce) {
  .bootcn-switch .bootcn-switch__input {
    transition: none;
  }
}
