/* Theme-aware liquid toggle for .bz-switch (user + admin).
   Visuals enhanced by assets/js/bz-liquid-toggle.js — checkbox stays for forms. */

.bz-liquid-filters {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.bz-switch {
  --bz-switch-on: var(--brand, var(--green, #810100));
  --bz-switch-off: #c9ced3;
  --bz-switch-off-track: color-mix(in srgb, var(--bz-switch-on) 12%, #e8e8e8);
  --bz-switch-off-ring: color-mix(in srgb, var(--bz-switch-on) 28%, #c4c4c4);
  --border: 3px;
  --width: 52;
  --height: 30;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bz-switch__text {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  line-height: 1.35;
  min-width: 0;
  flex: 1 1 auto;
}

.bz-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}

/* Fallback (pre-JS / reduced motion) */
.bz-switch__track {
  --complete: 0;
  --delta: 0;
  --unchecked: color-mix(in srgb, var(--bz-switch-on) 14%, #d4d4d4);
  --checked: var(--bz-switch-on);
  --control: #fff;
  --transition: 0.22s;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  background-color: var(--bz-switch-off-track);
  border-radius: 100px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  transition: box-shadow 0.2s ease, background-color 0.2s ease, outline 0.2s ease;
  align-items: center;
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: calc(var(--width) * 1px);
  height: calc(var(--height) * 1px);
  box-shadow:
    rgba(0, 0, 0, 0.14) 0 0 3px inset,
    var(--bz-switch-off-ring) 0 0 0 1.5px inset;
  overflow: visible;
  container-type: inline-size;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.bz-switch:not(.bz-switch--liquid) .bz-switch__track::after {
  content: "";
  display: block;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  background-color: #fff;
  border-radius: 200px;
  position: absolute;
  box-shadow:
    color-mix(in srgb, var(--bz-switch-on) 22%, transparent) 0 0 0 1px,
    rgba(0, 0, 0, 0.22) 0 4px 8px;
  transition: left 280ms var(--ease);
}

.bz-switch:not(.bz-switch--liquid) input[type="checkbox"]:checked + .bz-switch__track {
  background-color: var(--bz-switch-on);
  box-shadow:
    rgba(0, 0, 0, 0.22) 0 0 4px inset,
    var(--bz-switch-on) 0 0 0 2px inset;
}

.bz-switch:not(.bz-switch--liquid) input[type="checkbox"]:checked + .bz-switch__track::after {
  left: 24px;
}

.bz-switch input[type="checkbox"]:focus-visible + .bz-switch__track,
.bz-switch__track:focus-visible {
  outline: 2px solid var(--bz-switch-on);
  outline-offset: 3px;
}

.bz-switch input[type="checkbox"]:disabled + .bz-switch__track {
  opacity: 0.45;
  cursor: not-allowed;
}

.bz-switch:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.85;
}

.bz-switch--block {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 14px;
}

.bz-switch--sm {
  --width: 46;
  --height: 28;
  --border: 2.5px;
}
.bz-switch--sm:not(.bz-switch--liquid) .bz-switch__track::after {
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
}
.bz-switch--sm:not(.bz-switch--liquid) input[type="checkbox"]:checked + .bz-switch__track::after {
  left: 20px;
}

/* ── Liquid layer ─────────────────────────────────────────────────── */
/* Solid track always visible; SVG filters are optional polish (often broken in WebViews). */

.bz-switch--liquid .bz-switch__track {
  background: #d1d5db;
  background: color-mix(in srgb, var(--checked) calc(var(--complete) * 1%), #d1d5db);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.14),
    inset 0 0 0 1.5px rgba(0, 0, 0, 0.06);
  overflow: visible;
  transition:
    background-color var(--transition) var(--ease),
    box-shadow var(--transition) var(--ease);
}

.bz-switch--liquid .bz-switch__track.is-on {
  background: var(--checked);
  box-shadow:
    inset 0 1px 4px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1.5px color-mix(in srgb, var(--checked) 70%, #000);
}

.bz-switch--liquid .bz-switch__track::after {
  display: none !important;
}

.liquid-toggle {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  background: transparent;
  overflow: visible;
  pointer-events: none;
  display: block;
}

.liquid-toggle * {
  pointer-events: none;
  box-sizing: border-box;
  display: block;
}

/* Knockout + goo are demo extras; hide / no-filter so the control never blanks out */
.bz-switch--liquid .knockout {
  display: none !important;
}

.bz-switch--liquid .indicator,
.bz-switch--liquid .indicator--masked {
  display: none !important;
}

.bz-switch--liquid .indicator__liquid {
  position: absolute;
  top: 50%;
  left: var(--border);
  height: calc(100% - (2 * var(--border)));
  width: calc(58% - (2 * var(--border)));
  border-radius: 100px;
  background: #fff;
  container-type: inline-size;
  translate: calc((var(--complete) / 100) * (100cqi - 100% - (2 * var(--border)))) -50%;
  transition:
    scale var(--transition) var(--ease),
    translate var(--transition) var(--ease),
    background var(--transition) var(--ease);
  z-index: 3;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(0, 0, 0, 0.04);
}

.bz-switch--liquid .wrapper {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  clip-path: inset(0 0 0 0 round 100px);
  filter: none;
  overflow: hidden;
}

.bz-switch--liquid .liquids {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  overflow: hidden;
  filter: none;
  transform: translateZ(0);
}

.bz-switch--liquid .liquid__shadow {
  display: none;
}

.bz-switch--liquid .liquid__track {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  background: #fff;
  translate: none;
  left: auto;
  top: auto;
  height: auto;
  width: auto;
}

.bz-switch--liquid .indicator__liquid .cover {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  background: #fff;
  opacity: 1;
}

.bz-switch--liquid .indicator__liquid .shadow {
  position: absolute;
  inset: 0;
  border-radius: 100px;
  opacity: 0;
  z-index: 4;
  box-shadow:
    1px -1px 2px hsl(0 0% 100% / 0.45) inset,
    -1px 1px 4px hsl(0 0% 20% / 0.18) inset,
    0 3px 8px hsl(0 0% 20% / 0.18);
  transition: opacity var(--transition) var(--ease);
}

/* Press / drag: soft squash (knob stays white & visible) */
.bz-switch--liquid .bz-switch__track[data-active="true"] .indicator__liquid,
.bz-switch--liquid .bz-switch__track:active .indicator__liquid {
  scale: calc(1.28 + (var(--delta, 0) * 0.01)) calc(1.12 - (var(--delta, 0) * 0.008));
}

.bz-switch--liquid .bz-switch__track[data-active="true"] .indicator__liquid .shadow,
.bz-switch--liquid .bz-switch__track:active .indicator__liquid .shadow {
  opacity: 1;
}

.bz-switch--liquid .bz-switch__track[data-active="true"] .indicator__liquid .cover,
.bz-switch--liquid .bz-switch__track:active .indicator__liquid .cover {
  opacity: 1;
}

/* Auth / profile rows: keep text readable beside the control */
.bz-auth__pass-toggle {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  background: #fff;
  gap: 14px;
}
.bz-auth__pass-toggle .bz-switch__text {
  font-size: 14px;
  font-weight: 650;
  color: #111827;
}
.bz-auth__pass-toggle .bz-switch__track {
  order: 2;
  flex-shrink: 0;
}

@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .bz-switch {
    --bz-switch-off-track: #e5e7eb;
    --bz-switch-off-ring: #c4c4c4;
  }
  .bz-switch--liquid .bz-switch__track {
    background: #d1d5db;
  }
  .bz-switch--liquid .bz-switch__track.is-on {
    background: var(--checked, #810100);
  }
}

@media (max-width: 380px) {
  .bz-switch {
    --width: 48;
    --height: 28;
    --border: 2.5px;
    gap: 10px;
  }
  .bz-auth__pass-toggle {
    padding: 11px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bz-switch__track,
  .bz-switch--liquid .indicator--masked .mask,
  .bz-switch--liquid .indicator__liquid,
  .bz-switch--liquid .wrapper,
  .bz-switch--liquid .liquid__track,
  .bz-switch--liquid .cover,
  .bz-switch--liquid .shadow {
    transition: none !important;
  }
  .bz-switch--liquid .knockout,
  .bz-switch--liquid .liquids {
    filter: none !important;
  }
  .bz-switch--liquid .wrapper {
    filter: none !important;
  }
}
