/*
 * Shared Route choice-control surface.
 *
 * Existing consumers retain their local geometry. Opt-in route-checkbox
 * consumers share the approved compact square and dark selected state.
 */
:root {
  --route-choice-surface: var(--panel, #ffffff);
  --route-choice-border: var(--line-strong, #aeb9c7);
  --route-choice-border-hover: var(--accent, #147a6f);
  --route-choice-accent: var(--accent, #147a6f);
  --route-choice-accent-rgb: var(--accent-rgb, 20, 122, 111);
  --route-choice-focus-ring: rgba(var(--route-choice-accent-rgb), .22);
  --route-choice-error: #cf625a;
  --route-choice-error-surface: #fffafa;
  --route-choice-disabled-surface: #f1f3f6;
  --route-choice-disabled-mark: #aeb7c2;
}

:where(input[type="checkbox"], input[type="radio"]) {
  width: 13px;
  height: 13px;
  min-width: 13px;
  min-height: 13px;
}

input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  padding: 0 !important;
  border: 1px solid var(--route-choice-border);
  background-color: var(--route-choice-surface);
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: none !important;
  color: #fff;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    outline-color 140ms ease;
}

input[type="checkbox"] {
  border-radius: var(--radius);
}

input[type="radio"] {
  border-radius: var(--radius-circle);
}

input[type="checkbox"]:hover:not(:disabled),
input[type="radio"]:hover:not(:disabled) {
  border-color: var(--route-choice-border-hover);
}

input[type="checkbox"]:checked {
  border-color: var(--route-choice-accent);
  background-color: var(--route-choice-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.25 8.15 6.4 11.3 12.8 4.9' fill='none' stroke='%23fff' stroke-width='2.1' stroke-linecap='square' stroke-linejoin='miter'/%3E%3C/svg%3E");
  background-size: 78% 78%;
}

input[type="radio"]:checked {
  border-color: var(--route-choice-accent);
  background-color: var(--route-choice-accent);
  background-image: radial-gradient(circle at center, #fff 0 28%, transparent 34%);
}

input[type="checkbox"]:focus,
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus,
input[type="radio"]:focus-visible {
  border-color: var(--route-choice-accent);
  outline: 2px solid var(--route-choice-focus-ring) !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
}

input[type="checkbox"][aria-invalid="true"],
input[type="checkbox"].is-invalid,
input[type="radio"][aria-invalid="true"],
input[type="radio"].is-invalid,
.has-error > input[type="checkbox"],
.has-error > input[type="radio"] {
  border-color: var(--route-choice-error) !important;
  background-color: var(--route-choice-error-surface);
  box-shadow: none !important;
}

input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
  border-color: var(--route-field-border, var(--line, #d8dee7));
  background-color: var(--route-choice-disabled-surface);
  box-shadow: none !important;
  cursor: not-allowed;
  opacity: 1;
}

input[type="checkbox"]:disabled:checked,
input[type="radio"]:disabled:checked {
  border-color: var(--route-choice-disabled-mark);
  background-color: var(--route-choice-disabled-mark);
}

/* Custom switch tracks retain local dimensions and movement distances. */
.accrual-option-track {
  border: 1px solid var(--route-choice-border);
  border-radius: var(--radius);
  background: var(--route-choice-surface);
  box-shadow: none !important;
}

.accrual-option-track::after {
  border-radius: var(--radius);
  background: #8d99a8;
  box-shadow: none !important;
}

.accrual-option-toggle input:checked ~ .accrual-option-track {
  border-color: var(--route-choice-accent);
  background: var(--route-choice-accent);
}

.accrual-option-toggle input:checked ~ .accrual-option-track::after {
  background: #fff;
}

.accrual-option-toggle input:focus-visible ~ .accrual-option-track {
  border-color: var(--route-choice-accent);
  outline: 2px solid var(--route-choice-focus-ring);
  outline-offset: 2px;
  box-shadow: none !important;
}

.accrual-option-toggle input:disabled ~ .accrual-option-track {
  border-color: var(--route-field-border, var(--line, #d8dee7));
  background: var(--route-choice-disabled-surface);
  opacity: 1;
}

.accrual-option-toggle input:disabled ~ .accrual-option-track::after {
  background: var(--route-choice-disabled-mark);
}

@media (forced-colors: active) {
  input[type="checkbox"],
  input[type="radio"],
  .accrual-option-track {
    forced-color-adjust: auto;
  }
}

/* D067: shared dark checkbox; preserve the native input and existing checkmark. */
input.route-checkbox[type="checkbox"] {
  --route-checkbox-size: 18px;
  --route-checkbox-selected: #064a43;
  flex: 0 0 var(--route-checkbox-size);
  width: var(--route-checkbox-size);
  min-width: var(--route-checkbox-size);
  max-width: var(--route-checkbox-size);
  height: var(--route-checkbox-size);
  min-height: var(--route-checkbox-size);
  max-height: var(--route-checkbox-size);
  margin: 0;
  vertical-align: middle;
  border: 1px solid #8d96a6;
  border-radius: var(--radius);
  background-color: var(--route-choice-surface);
}

/* A standalone row selector follows the whole cell, including multiline rows. */
td:has(> input.route-checkbox:only-child) {
  vertical-align: middle;
}

td > input.route-checkbox:only-child {
  display: block;
  margin-inline: auto;
}

/* Preserve the Team selector column width with equal existing end padding. */
td.team-select-column:has(> input.route-checkbox:only-child) {
  padding-inline: 4px !important;
}

input.route-checkbox[type="checkbox"]:is(:checked, :indeterminate) {
  border-color: var(--route-brand-green);
  background-color: var(--route-checkbox-selected);
}

input.route-checkbox[type="checkbox"]:indeterminate {
  background-image: linear-gradient(#fff, #fff);
  background-size: 10px 2px;
}

input.route-checkbox[type="checkbox"]:hover:not(:disabled) {
  border-color: var(--route-brand-green);
}

input.route-checkbox[type="checkbox"]:focus-visible {
  outline: 2px solid var(--route-brand-green) !important;
  outline-offset: 2px !important;
}

input.route-checkbox[type="checkbox"]:focus:not(:focus-visible) {
  outline: none !important;
}

input.route-checkbox[type="checkbox"]:disabled {
  border-color: var(--route-field-disabled-border);
  background-color: var(--route-choice-disabled-surface);
}

input.route-checkbox[type="checkbox"]:disabled:is(:checked, :indeterminate) {
  border-color: var(--route-choice-disabled-mark);
  background-color: var(--route-choice-disabled-mark);
}

@media (forced-colors: active) {
  input.route-checkbox[type="checkbox"] {
    appearance: auto;
    background-image: none;
  }
}

/* D080: opt-in radio and choice row shared by Restore and TU confirmation. */
input.route-radio[type="radio"] {
  --route-radio-size: 18px;
  --route-radio-selected: #064a43;
  flex: 0 0 var(--route-radio-size);
  width: var(--route-radio-size);
  min-width: var(--route-radio-size);
  max-width: var(--route-radio-size);
  height: var(--route-radio-size);
  min-height: var(--route-radio-size);
  max-height: var(--route-radio-size);
  margin: 0;
  align-self: center;
  vertical-align: middle;
  border: 1px solid #8d96a6;
  border-radius: var(--radius-circle);
  background-color: #fff;
}

input.route-radio[type="radio"]:checked {
  border-color: var(--route-radio-selected);
  background-color: var(--route-radio-selected);
  background-image: radial-gradient(circle at center, #fff 0 3px, transparent 3.5px);
}

input.route-radio[type="radio"]:hover:not(:disabled) {
  border-color: var(--route-radio-selected);
}

input.route-radio[type="radio"]:focus-visible {
  outline: 2px solid var(--route-brand-green) !important;
  outline-offset: 2px !important;
}

input.route-radio[type="radio"]:focus:not(:focus-visible) {
  outline: none !important;
}

input.route-radio[type="radio"]:disabled {
  border-color: var(--route-field-disabled-border);
  background-color: var(--route-choice-disabled-surface);
}

input.route-radio[type="radio"]:disabled:checked {
  border-color: var(--route-choice-disabled-mark);
  background-color: var(--route-choice-disabled-mark);
}

label.route-radio-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  box-shadow: none;
  cursor: pointer;
}

label.route-radio-option:has(> input:checked) {
  border-color: #064a43;
  background: #f3f4f5;
}

label.route-radio-option:has(> input:disabled) {
  color: var(--muted);
  cursor: not-allowed;
}

@media (forced-colors: active) {
  input.route-radio[type="radio"] {
    appearance: auto;
    background-image: none;
  }
  label.route-radio-option:has(> input:checked) {
    border-color: Highlight;
  }
}
