/*
 * Structural styles for ui-toggle, ui-checkbox, and ui-radio.
 *
 * The toggle/checkbox row aligns to the standard control height so it
 * lines up with sibling buttons and inputs in a formgroup.
 */

ui-toggle {
  display: flex;
  align-items: center;
  gap: var(--elation-space-2);
  min-height: var(--elation-control-h);
}
ui-toggle > div {
  display: inline-block;
  position: relative;
  width: 2em;
  height: 1.25em;
  flex: 0 0 auto;
  cursor: pointer;
  user-select: none;
  -ms-user-select: none;
  z-index: 2;
}
ui-toggle[align="left"] > div {
  order: -1;
}
ui-toggle input {
  display: none;
}
ui-toggle span {
  cursor: pointer;
}
ui-toggle > div::before {
  display: block;
  position: absolute;
  top: 2px;
  left: 2px;
  bottom: 2px;
  width: 40%;
  z-index: -1;
  content: '';
}
ui-toggle[checked] > div::before {
  right: 2px;
  left: auto;
  content: '';
}
ui-toggle[disabled] > div,
ui-toggle[disabled] span {
  cursor: not-allowed;
}

ui-checkbox {
  display: flex;
  align-items: center;
  gap: var(--elation-space-2);
  min-height: var(--elation-control-h);
  min-width: 6em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -ms-user-select: none;
  -moz-user-select: none;
}
ui-checkbox > input {
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  cursor: pointer;
  -webkit-appearance: none;
  box-sizing: border-box;
}
ui-checkbox[align="left"] > input {
  order: -1;
}
ui-checkbox > input:checked::after {
  content: '\2714';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  line-height: 1;
}
ui-checkbox[disabled] {
  cursor: not-allowed;
}
ui-checkbox[disabled] > input {
  pointer-events: none;
}
