/*
 * Over — form controls that extend the system with two patterns adopted from the
 * reference product (Apple/Revolut-style), built entirely from our tokens:
 *   .switch    — iOS-style on/off toggle (replaces a checkbox for settings)
 *   .segmented — a track + pill segmented control (view / option switcher)
 * See docs/architecture/ui.md.
 */

/* ── Toggle switch ── */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  width: calc(var(--badge-h) + var(--sp-4));
  height: var(--badge-h);
  border-radius: var(--r-lg);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  transition: background 0.14s, border-color 0.14s;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  width: calc(var(--badge-h) - var(--sp-2));
  height: calc(var(--badge-h) - var(--sp-2));
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.14s, background 0.14s;
}

.switch input:checked + .switch__track {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch__track::after {
  transform: translateY(-50%) translateX(var(--badge-h));
  background: var(--white);
}

.switch input:disabled + .switch__track {
  opacity: 0.5;
}

.switch input:focus-visible + .switch__track {
  border-color: var(--accent);
}

/* Label + switch on one row (label left, switch right). */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.switch-row__label {
  font-size: var(--fs-sm);
  color: var(--text);
}

/* Stacked switch rows (e.g. a settings card) keep the standard field gap. */
.switch-row + .switch-row {
  margin-top: var(--sp-3);
}

/* ── Segmented control ── */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.segmented__item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: var(--control-h-sm);
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--text-dim);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.segmented__item:hover {
  color: var(--text);
}

.segmented__item.is-active {
  background: var(--surface);
  color: var(--text);
}
