/**
 * INFOBMS global ON/OFF toggle switch
 * Matches design: light-green ON / light-red OFF pill with white knob + ON/OFF labels.
 */
.infobms-toggle,
.hc-on-off-switch {
  --toggle-on-bg: #86efac;
  --toggle-off-bg: #fca5a5;
  --toggle-knob-bg: #ffffff;
  --toggle-on-label: #14532d;
  --toggle-off-label: #7f1d1d;
  margin-bottom: 0.75rem;
}

.infobms-toggle__row,
.hc-on-off-switch__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.infobms-toggle--inline .infobms-toggle__row,
.infobms-toggle--inline .hc-on-off-switch__row {
  justify-content: flex-start;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.infobms-toggle--inline .infobms-toggle__text,
.infobms-toggle--inline .hc-on-off-switch__text {
  flex: 0 1 auto;
  min-width: 0;
}

.user-access-locations {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-start;
}

.user-access-locations .infobms-toggle {
  margin-bottom: 0.25rem;
  max-width: 100%;
}

.user-access-locations-heading {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
}

.user-access-locations-all {
  margin-bottom: 0.75rem;
}

.infobms-toggle__text,
.hc-on-off-switch__text {
  flex: 1 1 12rem;
  min-width: 0;
}

.infobms-toggle__label,
.hc-on-off-switch__label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--pos-text-primary, var(--text-primary, #111827));
  cursor: pointer;
}

.infobms-toggle__help,
.hc-on-off-switch__help {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.35;
}

/* Compact control used by the enhancer (checkbox sits over the track) */
.infobms-toggle__control,
.hc-on-off-switch__control,
.infobms-toggle-enhance__control {
  position: relative !important;
  display: inline-block;
  flex-shrink: 0;
  width: 4.35rem !important;
  min-width: 4.35rem;
  height: 1.9rem !important;
  min-height: 1.9rem;
  vertical-align: middle;
}

.infobms-toggle__input,
.hc-on-off-switch__input,
.infobms-toggle-enhance__input {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  border: 0 !important;
  background: transparent !important;
  cursor: pointer;
  z-index: 2;
}

.infobms-toggle__track,
.hc-on-off-switch__track,
.infobms-toggle-enhance__track {
  position: absolute !important;
  inset: 0;
  display: block !important;
  margin: 0 !important;
  border-radius: 9999px;
  background: var(--toggle-off-bg, #fca5a5) !important;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: background-color 0.25s ease;
  overflow: hidden;
  user-select: none;
}

.infobms-toggle__state,
.hc-on-off-switch__state,
.infobms-toggle-enhance__state {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
  pointer-events: none;
  transition: opacity 0.15s ease;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.infobms-toggle__state--on,
.hc-on-off-switch__state--on,
.infobms-toggle-enhance__state--on {
  left: 0.5rem;
  color: var(--toggle-on-label, #14532d);
  opacity: 0;
}

.infobms-toggle__state--off,
.hc-on-off-switch__state--off,
.infobms-toggle-enhance__state--off {
  right: 0.42rem;
  color: var(--toggle-off-label, #7f1d1d);
  opacity: 1;
}

.infobms-toggle__knob,
.hc-on-off-switch__knob,
.infobms-toggle-enhance__knob {
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: var(--toggle-knob-bg, #ffffff);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
  transform: translateY(-50%);
  transition: left 0.25s ease;
  pointer-events: none;
}

.infobms-toggle__input:checked + .infobms-toggle__track,
.hc-on-off-switch__input:checked + .hc-on-off-switch__track,
.infobms-toggle-enhance__input:checked + .infobms-toggle-enhance__track,
.infobms-toggle__input:checked + .hc-on-off-switch__track,
.hc-on-off-switch__input:checked + .infobms-toggle__track {
  background: var(--toggle-on-bg, #86efac) !important;
}

.infobms-toggle__input:checked + .infobms-toggle__track .infobms-toggle__state--on,
.hc-on-off-switch__input:checked + .hc-on-off-switch__track .hc-on-off-switch__state--on,
.infobms-toggle-enhance__input:checked + .infobms-toggle-enhance__track .infobms-toggle-enhance__state--on,
.infobms-toggle__input:checked + .infobms-toggle__track .hc-on-off-switch__state--on,
.hc-on-off-switch__input:checked + .hc-on-off-switch__track .infobms-toggle__state--on {
  opacity: 1;
}

.infobms-toggle__input:checked + .infobms-toggle__track .infobms-toggle__state--off,
.hc-on-off-switch__input:checked + .hc-on-off-switch__track .hc-on-off-switch__state--off,
.infobms-toggle-enhance__input:checked + .infobms-toggle-enhance__track .infobms-toggle-enhance__state--off,
.infobms-toggle__input:checked + .infobms-toggle__track .hc-on-off-switch__state--off,
.hc-on-off-switch__input:checked + .hc-on-off-switch__track .infobms-toggle__state--off {
  opacity: 0;
}

.infobms-toggle__input:checked + .infobms-toggle__track .infobms-toggle__knob,
.hc-on-off-switch__input:checked + .hc-on-off-switch__track .hc-on-off-switch__knob,
.infobms-toggle-enhance__input:checked + .infobms-toggle-enhance__track .infobms-toggle-enhance__knob,
.infobms-toggle__input:checked + .infobms-toggle__track .hc-on-off-switch__knob,
.hc-on-off-switch__input:checked + .hc-on-off-switch__track .infobms-toggle__knob {
  left: calc(100% - 1.7rem);
}

.infobms-toggle__input:focus-visible + .infobms-toggle__track,
.hc-on-off-switch__input:focus-visible + .hc-on-off-switch__track,
.infobms-toggle-enhance__input:focus-visible + .infobms-toggle-enhance__track {
  outline: 2px solid var(--btn-primary-bg, var(--accent-primary, #3b82f6));
  outline-offset: 2px;
}

.infobms-toggle.is-disabled,
.hc-on-off-switch.is-disabled,
.infobms-toggle-enhance.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* Hide iCheck chrome if anything leaks through on enhanced inputs */
.infobms-toggle-enhance .icheckbox_square-blue,
.infobms-toggle-enhance .iradio_square-blue {
  display: none !important;
}

/* Inline / label-adjacent enhancer: keep label text, put switch after */
.infobms-toggle-enhance--inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
  vertical-align: middle;
}

body.dark-mode .infobms-toggle__label,
body.dark-mode .hc-on-off-switch__label {
  color: var(--text-primary, #e2e8f0);
}

body.dark-mode {
  --toggle-on-bg: #4ade80;
  --toggle-off-bg: #f87171;
  --toggle-on-label: #14532d;
  --toggle-off-label: #7f1d1d;
  --toggle-knob-bg: #f8fafc;
}
