.erp-switch {
  --erp-switch-width: 48px;
  --erp-switch-height: 28px;
  --erp-switch-padding: 2px;
  --erp-switch-thumb: 22px;
  --erp-switch-travel: 20px;
  box-sizing: border-box;
  display: inline-grid;
  flex: 0 0 auto;
  width: var(--erp-switch-width);
  min-width: var(--erp-switch-width);
  height: var(--erp-switch-height);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.erp-switch-track {
  position: relative;
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: inherit;
  background: #e2e8f0;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    transform 140ms ease;
}

.erp-switch-thumb {
  position: absolute;
  top: 50%;
  left: var(--erp-switch-padding);
  box-sizing: border-box;
  width: var(--erp-switch-thumb);
  height: var(--erp-switch-thumb);
  border-radius: 999px;
  background: #ffffff;
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.24),
    0 1px 2px rgba(15, 23, 42, 0.12);
  transform: translate3d(0, -50%, 0) scaleX(1);
  transform-origin: right center;
  transition: transform 360ms cubic-bezier(0.22, 1.45, 0.36, 1);
}

.erp-switch.is-checked .erp-switch-track {
  border-color: #2563eb;
  background: linear-gradient(135deg, #06b6d4, #2563eb);
}

.erp-switch.is-checked .erp-switch-thumb {
  transform: translate3d(var(--erp-switch-travel), -50%, 0) scaleX(1);
  transform-origin: left center;
}

.erp-switch.is-moving-on .erp-switch-thumb {
  animation: erp-switch-move-on 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.erp-switch.is-moving-off .erp-switch-thumb {
  animation: erp-switch-move-off 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes erp-switch-move-on {
  0% { transform: translate3d(0, -50%, 0) scaleX(1); }
  48% { transform: translate3d(calc(var(--erp-switch-travel) * 0.6), -50%, 0) scaleX(1.28); }
  78% { transform: translate3d(calc(var(--erp-switch-travel) * 1.05), -50%, 0) scaleX(0.94); }
  100% { transform: translate3d(var(--erp-switch-travel), -50%, 0) scaleX(1); }
}

@keyframes erp-switch-move-off {
  0% { transform: translate3d(var(--erp-switch-travel), -50%, 0) scaleX(1); }
  48% { transform: translate3d(calc(var(--erp-switch-travel) * 0.4), -50%, 0) scaleX(1.28); }
  78% { transform: translate3d(calc(var(--erp-switch-travel) * -0.05), -50%, 0) scaleX(0.94); }
  100% { transform: translate3d(0, -50%, 0) scaleX(1); }
}

.erp-switch:not(:disabled):active .erp-switch-track {
  transform: scale(0.96);
}

.erp-switch:not(:disabled):active .erp-switch-thumb {
  transform: translate3d(0, -50%, 0) scaleX(1.18);
}

.erp-switch.is-checked:not(:disabled):active .erp-switch-thumb {
  transform: translate3d(var(--erp-switch-travel), -50%, 0) scaleX(1.18);
}

.erp-switch:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 3px;
}

.erp-switch:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

@media (prefers-reduced-motion: reduce) {
  .erp-switch-track,
  .erp-switch-thumb {
    animation: none !important;
    transition: none;
  }
}
