/* Shared control states for the installed service and the design prototype. */
:root {
  --control-border: #c8d7d0;
  --control-hover: #f3f8f5;
  --control-selected: var(--accent-soft, #e8f3ef);
  --control-selected-text: #155442;
  --control-focus: var(--accent, #19705c);
  --control-danger: #b33131;
  --control-danger-hover: #982828;
  --control-radius: 10px;
}

.btn, .live-picks button, .live-call-tabs button, .choice-option {
  border-radius: var(--control-radius);
  min-height: 44px;
  line-height: 1.45;
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:where(:not(.primary):not(.danger):not(.ghost)) { border-color: var(--control-border); }
.btn:hover:not(:disabled) { filter: none; }
.btn:where(:not(.primary):not(.danger)):hover:not(:disabled),
.live-picks button:hover:not(:disabled), .quick-option:hover:not(:disabled) {
  background: var(--control-hover);
  border-color: var(--accent);
}
.btn.primary:hover:not(:disabled) { background: #155e4d; border-color: #155e4d; }
.btn.danger {
  color: #fff;
  background: var(--control-danger);
  border-color: var(--control-danger);
}
.btn.danger:focus-visible { outline-color: var(--control-danger); }
.btn.danger:hover:not(:disabled) { background: var(--control-danger-hover); border-color: var(--control-danger-hover); }
.btn:disabled, .live-picks button:disabled, .choice-option:disabled { cursor: not-allowed; }

/* Native inputs retain keyboard handling, labels and required validation. */
input:is([type="checkbox"], [type="radio"]) {
  appearance: none;
  -webkit-appearance: none;
  display: inline-block;
  vertical-align: middle;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  margin: 0;
  flex: 0 0 22px;
  border: 1.5px solid #789087;
  border-radius: 6px;
  background: #fff center / 15px 15px no-repeat;
  cursor: pointer;
  accent-color: var(--accent);
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked {
  border-color: var(--accent);
  background-color: var(--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 8 3.2 3.2L13 4.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
input[type="checkbox"]:indeterminate { background-color: var(--accent); border-color: var(--accent); background-image: linear-gradient(#fff, #fff); background-size: 11px 2px; }
input[type="radio"]:checked { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px #fff; }
input:is([type="checkbox"], [type="radio"]):disabled { opacity: .55; cursor: not-allowed; }

.checks, .checks.vertical { gap: 10px; align-items: stretch; }
.checks label:has(> input:is([type="checkbox"], [type="radio"])),
.order-grants label:has(> input:is([type="checkbox"], [type="radio"])),
label.answer {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 13px 15px;
  margin: 0;
  border: 1px solid var(--control-border);
  border-radius: var(--control-radius);
  background: var(--paper, #fff);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.55;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.checks:not(.vertical) label:has(> input) { flex: 1 1 240px; }
.checks label:has(> input:not(:disabled)):hover,
.order-grants label:has(> input:not(:disabled)):hover, label.answer:has(> input:not(:disabled)):hover {
  border-color: var(--accent);
  background: var(--control-hover);
}
.checks label:has(> input:checked), .order-grants label:has(> input:checked), label.answer:has(> input:checked),
.checks label:has(> input:checked):hover, .order-grants label:has(> input:checked):hover, label.answer:has(> input:checked):hover {
  color: var(--control-selected-text);
  background: var(--control-selected);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 .5px var(--accent);
}
.checks label:has(> input:disabled), .order-grants label:has(> input:disabled), label.answer:has(> input:disabled) { cursor: not-allowed; }
.order-grants label:has(> input) + label { margin-top: 10px; }
.order-grants .live-note { margin: 12px 0 0; }
#live-modal .checks label, #modal .checks label { margin-top: 0; }

/* A single visual language for persistent choices, separate from action buttons. */
.choice-group, .live-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-option, .live-picks button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--control-border);
  background: var(--paper, #fff);
  color: var(--text);
}
.choice-option::before, .live-picks button::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 1.5px solid #789087;
  border-radius: 50%;
  background: #fff center / 12px 12px no-repeat;
}
.live-picks[data-multiple="true"] button::before { border-radius: 4px; }
.btn.choice-option[aria-pressed="true"], .live-picks button[aria-pressed="true"],
.live-picks button.active, .quick-option.selected, .priority-option.selected, .colleague.selected,
.patient-pill.active, .observation-tab.active, .choice-tab[aria-pressed="true"] {
  color: var(--control-selected-text);
  background: var(--control-selected);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 .5px var(--accent);
  font-weight: 600;
}
.choice-option[aria-pressed="true"]::before, .live-picks button[aria-pressed="true"]::before {
  border-color: var(--accent);
  background-color: var(--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 8 3.2 3.2L13 4.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.btn.choice-option[aria-pressed="true"]:hover:not(:disabled), .btn.choice-tab[aria-pressed="true"]:hover:not(:disabled), .live-picks button[aria-pressed="true"]:hover:not(:disabled) { background: #dceee4; }
.choice-option[aria-pressed="true"]:disabled, .live-picks button[aria-pressed="true"]:disabled,
.quick-option.selected:disabled, .priority-option.selected:disabled { opacity: 1; }
.live-call-tabs button.active, .tablet-tab.active, .patient-pane-tabs button.active {
  color: var(--control-selected-text);
  background: var(--control-selected);
  border-color: var(--accent);
  font-weight: 600;
}
.staff-band-grid button[aria-pressed="true"] { background: var(--control-selected); color: var(--control-selected-text); box-shadow: inset 0 0 0 2px var(--accent); border-radius: 6px; }
.location-options button[aria-selected="true"] { background: var(--control-selected); color: var(--control-selected-text); box-shadow: inset 3px 0 var(--accent); }

:is(button, a, input, select, textarea, summary):focus-visible,
.btn:focus-visible, .quick-option:focus-visible, .tablet-tab:focus-visible,
.priority-option:focus-visible, .patient-pill:focus-visible, .colleague:focus-visible,
.location-input input:focus-visible {
  outline: 3px solid var(--control-focus);
  outline-offset: 3px;
}
.checks label:has(> input:focus-visible), .order-grants label:has(> input:focus-visible), label.answer:has(> input:focus-visible) { border-color: var(--control-focus); }

/* Put the destructive alternative at the far right, including wrapped mobile headers. */
.incident-head .incident-actions { margin-left: auto; justify-content: flex-end; }
.incident-actions .cancel-creation { margin-left: auto; }
.refinement-call-actions { justify-content: flex-end; }
@media(max-width:640px) {
  .checks label:has(> input), .order-grants label:has(> input), label.answer { padding: 12px; min-height: 56px; font-size: 14px; }
  .choice-option, .live-picks button { min-height: 44px; font-size: 13px; padding: 9px 11px; }
  .incident-head .incident-actions { width: 100%; }
  .incident-head .incident-actions .btn { flex: 0 1 auto; }
  .incident-actions .cancel-creation { margin-left: auto; }
  .modal-footer { flex-wrap: wrap; }
}
@media(prefers-reduced-motion:reduce) {
  .btn, .live-picks button, .live-call-tabs button, .checks label, .order-grants label, label.answer { transition: none; }
}
@media(forced-colors:active) {
  input:is([type="checkbox"], [type="radio"]) { appearance: auto; -webkit-appearance: auto; }
  .choice-option[aria-pressed="true"], .live-picks button[aria-pressed="true"],
  .checks label:has(> input:checked), .order-grants label:has(> input:checked) { outline: 2px solid Highlight; }
  .choice-option::before, .live-picks button::before { display: none; }
}
