
.container {
  display: inline-flex;
  align-items: center;
  gap: var(--brutal-space-3);
  position: relative;
  user-select: none;
}

.container.labelLeft {
  flex-direction: row-reverse;
}

.switchWrapper {
  position: relative;
  display: inline-block;
}

/* Hide native checkbox */
.input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  z-index: 1;
  cursor: pointer;
}

/* Switch track */
.switch {
  display: flex;
  align-items: center;
  background-color: var(--brutal-white);
  border: var(--brutal-border-width) var(--brutal-border-style) var(--brutal-black);
  cursor: pointer;
  transition: all var(--brutal-transition-base);
  position: relative;
  overflow: hidden;
}

.switch.withShadow {
  box-shadow: var(--brutal-shadow-sm);
}

/* Size variants */
.sm .switch {
  width: 36px;
  height: 20px;
}

.md .switch {
  width: 48px;
  height: 28px;
}

.lg .switch {
  width: 60px;
  height: 36px;
}

/* Thumb (square slider) */
.thumb {
  position: absolute;
  background-color: var(--brutal-black);
  border: none;
  transition: transform var(--brutal-transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Thumb sizes */
.sm .thumb {
  width: 12px;
  height: 12px;
  left: 3px;
}

.md .thumb {
  width: 18px;
  height: 18px;
  left: 4px;
}

.lg .thumb {
  width: 24px;
  height: 24px;
  left: 5px;
}

/* Checked state - move thumb to right */
.sm .switch.checked .thumb {
  transform: translateX(16px);
}

.md .switch.checked .thumb {
  transform: translateX(20px);
}

.lg .switch.checked .thumb {
  transform: translateX(24px);
}

/* Checked state - change background */
.switch.checked {
  background-color: var(--brutal-accent);
}

/* Label */
.label {
  font-family: var(--brutal-font-sans);
  font-weight: var(--brutal-font-medium);
  color: var(--brutal-black);
  cursor: pointer;
  transition: color var(--brutal-transition-base);
}

.sm .label {
  font-size: var(--brutal-text-sm);
}

.md .label {
  font-size: var(--brutal-text-base);
}

.lg .label {
  font-size: var(--brutal-text-lg);
}

/* States */
/* Hover state */
.container:not(.disabled):hover .switch {
  background-color: var(--brutal-gray-100);
  transform: translate(-1px, -1px);
}

.container:not(.disabled):hover .switch.checked {
  background-color: var(--brutal-accent-dark);
}

.container:not(.disabled):hover .switch.withShadow {
  box-shadow: 5px 5px 0px var(--brutal-black);
}

.container:not(.disabled):hover .label {
  color: var(--brutal-gray-700);
}

/* Focus state */
.input:focus-visible + .switch {
  outline: var(--brutal-border-width) var(--brutal-border-style) var(--brutal-accent);
  outline-offset: 2px;
}

/* Active state */
.container:not(.disabled):active .switch {
  transform: translate(2px, 2px);
}

.container:not(.disabled):active .switch.withShadow {
  box-shadow: 2px 2px 0px var(--brutal-black);
}

/* Disabled state */
.disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.disabled .switch {
  cursor: not-allowed;
  background-color: var(--brutal-gray-300);
}

.disabled .switch.checked {
  background-color: var(--brutal-gray-400);
}

.disabled .label {
  cursor: not-allowed;
  color: var(--brutal-gray-500);
}

.disabled .thumb {
  background-color: var(--brutal-gray-600);
}

/* Loading state */
.switch.loading {
  cursor: wait;
}

.loadingIndicator {
  width: 100%;
  height: 100%;
  background-color: var(--brutal-white);
  animation: loadingPulse 1s ease-in-out infinite;
}

@keyframes loadingPulse {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
  }
}

/* Angular movement animation */
@keyframes slideIn {
  0% {
    transform: translateX(0) rotate(-5deg);
  }
  50% {
    transform: translateX(50%) rotate(5deg);
  }
  100% {
    transform: translateX(100%) rotate(0deg);
  }
}

/* Keyboard navigation enhancement */
.input:focus-visible + .switch {
  transform: translate(-1px, -1px);
}

.input:focus-visible + .switch.withShadow {
  box-shadow: 5px 5px 0px var(--brutal-black);
}

/* High contrast off state */
.switch:not(.checked) {
  background-color: var(--brutal-gray-200);
}

/* Ensure square corners everywhere */
.switch,
.thumb {
  border-radius: 0 !important;
}