/* Unified switches. The app has native checkbox switches and label-based
   switches; scoping by element prevents both implementations from stacking. */
input.mv7-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  min-width: 44px;
  flex: 0 0 44px;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  outline: 0;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  vertical-align: middle;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

input.mv7-switch::after {
  position: absolute;
  top: 2px;
  left: 2px;
  display: block;
  width: 20px;
  height: 20px;
  margin: 0;
  border-radius: 50%;
  background: #e7ebe8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.72);
  content: '';
  transform: translateX(0);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), background 180ms ease;
}

input.mv7-switch:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.14);
}

input.mv7-switch:checked {
  border-color: rgba(45, 222, 152, 0.72);
  background: linear-gradient(135deg, #32e6a2, #169c6b);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.22), 0 0 0 1px rgba(45, 222, 152, 0.08);
}

input.mv7-switch:checked::after {
  background: #fff;
  transform: translateX(18px);
}

input.mv7-switch:focus-visible {
  outline: 2px solid var(--v2-green-bright);
  outline-offset: 3px;
}

input.mv7-switch:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  filter: saturate(0.45);
}

/* Label-based variant used by the home widget configurator. */
label.mv7-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  min-width: 44px;
  flex: 0 0 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

label.mv7-switch::after {
  display: none;
  content: none;
}

label.mv7-switch > input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

label.mv7-switch > .mv7-switch-slider {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

label.mv7-switch > .mv7-switch-slider::before {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e7ebe8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.72);
  content: '';
  transform: translateX(0);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), background 180ms ease;
}

label.mv7-switch:hover > input:not(:disabled) + .mv7-switch-slider {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.14);
}

label.mv7-switch > input:checked + .mv7-switch-slider {
  border-color: rgba(45, 222, 152, 0.72);
  background: linear-gradient(135deg, #32e6a2, #169c6b);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.22), 0 0 0 1px rgba(45, 222, 152, 0.08);
}

label.mv7-switch > input:checked + .mv7-switch-slider::before {
  background: #fff;
  transform: translateX(18px);
}

label.mv7-switch > input:focus-visible + .mv7-switch-slider {
  outline: 2px solid var(--v2-green-bright);
  outline-offset: 3px;
}

label.mv7-switch:has(> input:disabled) {
  opacity: 0.46;
  cursor: not-allowed;
  filter: saturate(0.45);
}

:root[data-resolved-theme='light'] input.mv7-switch,
:root[data-resolved-theme='light'] label.mv7-switch > .mv7-switch-slider {
  border-color: rgba(15, 23, 42, 0.12);
  background: #d9dee5;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.1);
}

:root[data-resolved-theme='light'] input.mv7-switch::after,
:root[data-resolved-theme='light'] label.mv7-switch > .mv7-switch-slider::before {
  background: #fff;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.24), inset 0 1px rgba(255, 255, 255, 0.95);
}

:root[data-resolved-theme='light'] input.mv7-switch:checked,
:root[data-resolved-theme='light'] label.mv7-switch > input:checked + .mv7-switch-slider {
  border-color: rgba(10, 150, 102, 0.55);
  background: linear-gradient(135deg, #35dda0, #109868);
}

@media (prefers-reduced-motion: reduce) {
  input.mv7-switch,
  input.mv7-switch::after,
  label.mv7-switch > .mv7-switch-slider,
  label.mv7-switch > .mv7-switch-slider::before {
    transition: none;
  }
}
