/* Aniyab UI — Radio / Checkbox / Switch
 * From Figma: Components / switch-check-radio
 *
 * Markup:
 *   <label class="ay-radio">
 *     <input class="ay-radio__input" type="radio" name="x" />
 *     <span class="ay-radio__control" aria-hidden="true"></span>
 *     <span class="ay-radio__label">متن</span>
 *   </label>
 *
 *   <label class="ay-check">
 *     <input class="ay-check__input" type="checkbox" />
 *     <span class="ay-check__control" aria-hidden="true"></span>
 *     <span class="ay-check__label">متن</span>
 *   </label>
 *
 *   <label class="ay-switch">
 *     <input class="ay-switch__input" type="checkbox" role="switch" />
 *     <span class="ay-switch__control" aria-hidden="true">
 *       <span class="ay-switch__track"></span>
 *       <span class="ay-switch__thumb"></span>
 *     </span>
 *     <span class="ay-switch__label">لیبل</span>
 *   </label>
 */

/* Shared field reset */
.ay-radio,
.ay-check,
.ay-switch {
  box-sizing: border-box;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0;
  font-family: var(--ay-font-family, dana, IRANSansfanum, Tahoma, sans-serif);
  font-weight: 500;
  color: var(--ay-text-main);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ay-radio__input,
.ay-check__input,
.ay-switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===================== Radio ===================== */

.ay-radio {
  min-height: 32px;
  font-size: 12px;
  line-height: 24px;
}

.ay-radio__control {
  box-sizing: border-box;
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 8px;
}

.ay-radio__control::before {
  content: "";
  box-sizing: border-box;
  display: block;
  width: 16px;
  height: 16px;
  background: var(--ay-surface-white);
  border: 1px solid var(--ay-border-dark);
  border-radius: 16px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ay-radio__control::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--ay-surface-white);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.ay-radio__label {
  padding: 0;
  color: inherit;
}

.ay-radio__input:checked + .ay-radio__control::before {
  background: var(--ay-brand-primary-light);
  border-color: var(--ay-brand-primary-light);
}

.ay-radio__input:checked + .ay-radio__control::after {
  opacity: 1;
  transform: scale(1);
}

.ay-radio__input:focus-visible + .ay-radio__control::before {
  outline: 2px solid var(--ay-brand-primary-light);
  outline-offset: 2px;
}

.ay-radio__input:disabled + .ay-radio__control::before {
  background: var(--ay-bg-darker);
  border-color: var(--ay-border-dark);
}

.ay-radio__input:disabled + .ay-radio__control::after {
  background: var(--ay-surface-white);
}

.ay-radio:has(.ay-radio__input:disabled) {
  color: var(--ay-border-dark);
  cursor: not-allowed;
}

/* ===================== Checkbox ===================== */

.ay-check {
  min-height: 32px;
  font-size: 12px;
  line-height: 24px;
}

.ay-check__control {
  box-sizing: border-box;
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 8px;
}

.ay-check__control::before {
  content: "";
  box-sizing: border-box;
  display: block;
  width: 16px;
  height: 16px;
  background: var(--ay-surface-white);
  border: 1px solid var(--ay-border-dark);
  border-radius: var(--ay-radius-check, 4px);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ay-check__control::after {
  content: "";
  box-sizing: border-box;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 9px;
  margin-top: -6px;
  margin-left: -2px;
  border: 2px solid var(--ay-surface-white);
  border-top: 0;
  border-left: 0;
  opacity: 0;
  transform: rotate(45deg) scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.ay-check__label {
  padding: 0;
  color: inherit;
}

.ay-check__input:checked + .ay-check__control::before {
  background: var(--ay-brand-primary-light);
  border-color: var(--ay-brand-primary-light);
}

.ay-check__input:checked + .ay-check__control::after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

.ay-check__input:focus-visible + .ay-check__control::before {
  outline: 2px solid var(--ay-brand-primary-light);
  outline-offset: 2px;
}

.ay-check__input:disabled + .ay-check__control::before {
  background: var(--ay-bg-darker);
  border-color: var(--ay-border-dark);
}

.ay-check__input:disabled + .ay-check__control::after {
  border-color: var(--ay-surface-white);
}

.ay-check:has(.ay-check__input:disabled) {
  color: var(--ay-border-dark);
  cursor: not-allowed;
}

/* ===================== Switch ===================== */

.ay-switch {
  min-height: 38px;
  gap: 0;
  font-size: 14px;
  line-height: 28px;
}

.ay-switch__control {
  box-sizing: border-box;
  position: relative;
  flex: none;
  width: 58px;
  height: 38px;
}

.ay-switch__track {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 14px;
  margin: -7px 0 0 -17px;
  border-radius: 10px;
  background: var(--ay-bg-darker);
  transition: background-color 0.2s ease;
}

.ay-switch__thumb {
  box-sizing: border-box;
  position: absolute;
  top: 5px;
  left: 24px; /* OFF — toward end in LTR; mirrors Figma ON at left when checked */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 4px;
  border-radius: 100px;
  background: transparent;
  transition: left 0.2s ease, background-color 0.2s ease;
}

.ay-switch__thumb::before {
  content: "";
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ay-surface-white);
  box-shadow: var(--ay-elevation-1);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.ay-switch__label {
  color: inherit;
}

/* ON */
.ay-switch__input:checked + .ay-switch__control .ay-switch__track {
  background: rgba(5, 69, 166, 0.5); /* Brand/Primary/Light @ 50% */
}

.ay-switch__input:checked + .ay-switch__control .ay-switch__thumb {
  left: 6px;
}

.ay-switch__input:checked + .ay-switch__control .ay-switch__thumb::before {
  background: var(--ay-brand-primary-light);
}

/* Hover halo (ON) */
.ay-switch:hover:not(:has(.ay-switch__input:disabled)) .ay-switch__input:checked + .ay-switch__control .ay-switch__thumb {
  background: var(--ay-switch-halo-hover);
}

/* Focus / select halo */
.ay-switch__input:focus-visible + .ay-switch__control .ay-switch__thumb {
  background: var(--ay-switch-halo-focus);
}

.ay-switch__input:focus-visible + .ay-switch__control .ay-switch__track {
  outline: none;
}

/* Disabled */
.ay-switch__input:disabled + .ay-switch__control .ay-switch__track {
  background: var(--ay-bg-darker);
}

.ay-switch__input:disabled + .ay-switch__control .ay-switch__thumb {
  background: transparent;
}

.ay-switch__input:disabled + .ay-switch__control .ay-switch__thumb::before {
  background: var(--ay-bg-darker);
  box-shadow: var(--ay-elevation-1);
}

.ay-switch:has(.ay-switch__input:disabled) {
  color: var(--ay-text-disable);
  cursor: not-allowed;
}
