/* Replace with model (replaceModelUI.js): the Properties button and its
   dialog — a catalog search, then a preview of what changes. Colours are
   the app's tokens (styles.css), so both themes follow. */

.replace-model-row .replace-model-btn { width: 100%; }
.replace-model-row .hint { margin: 2px 0 0; font-size: 11.5px; }

.replace-model-dialog .unit-picker-box { width: min(640px, calc(100vw - 32px)); }

/* --- Search --- */
.replace-model-dialog input.replace-search { width: 100%; box-sizing: border-box; margin: 0; }
.replace-model-dialog .hint.replace-search-note { margin: 6px 0 6px; min-height: 16px; }
.replace-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(46vh, 360px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.replace-results:empty { display: none; }
.replace-result {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.replace-result:last-child { border-bottom: none; }
.replace-result.active { background: var(--button-hover); box-shadow: inset 3px 0 0 var(--accent); }
.replace-result-name { display: flex; flex-wrap: wrap; gap: 0 8px; align-items: baseline; }
.replace-result-maker { color: var(--text-dim); }
.replace-result-model { font-weight: 600; }
.replace-result-desc {
  color: var(--text-dim);
  font-size: 11.5px;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.replace-result-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.replace-tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.replace-tag.has-symbol { color: var(--ok-fg); border-color: var(--ok-border); background: var(--ok-bg); }
.replace-tag.discontinued { color: var(--disc-fg); border-color: var(--disc-border); background: var(--disc-bg); }
.replace-tag.same-kind { color: var(--accent); border-color: var(--accent-dim); }
.replace-tag.ai-draft { color: var(--ai-fg); border-color: var(--ai-border); background: var(--ai-bg); font-weight: 700; cursor: help; }

/* --- Preview --- */
.replace-preview[hidden], .replace-search-view[hidden] { display: none; }
.replace-back {
  background: none;
  border: none;
  padding: 2px 0;
  color: var(--accent);
  font-size: 12.5px;
  margin-bottom: 8px;
}
.replace-back:hover { background: none; color: var(--accent-hover); text-decoration: underline; }
.replace-model-head { margin-bottom: 8px; }
.replace-model-name { font-weight: 600; }
.replace-model-desc {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.replace-facts { margin: 0 0 10px; padding-left: 18px; font-size: 12.5px; }
.replace-facts li { margin: 2px 0; }
.replace-blocked {
  margin: 0 0 10px;
  padding: 7px 10px;
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-fg-soft);
  border-radius: var(--radius);
  font-size: 12.5px;
}
.replace-wires-sum { font-size: 12.5px; margin: 0 0 6px; }
.replace-wires-sum.has-lost { color: var(--warn-fg); }
.replace-wires-wrap { max-height: min(36vh, 300px); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.replace-wires { width: 100%; border-collapse: collapse; font-size: 12px; }
.replace-wires th, .replace-wires td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.replace-wires th { position: sticky; top: 0; background: var(--panel-alt); color: var(--text-dim); font-weight: 600; }
.replace-wires tr:last-child td { border-bottom: none; }
.replace-wires tr.lost td:last-child { color: var(--warn-fg); font-weight: 600; }
.replace-unit { margin: 0 0 6px; font-size: 12.5px; }
.replace-unit summary { cursor: pointer; padding: 3px 0; }
.replace-unit .replace-wires-wrap { margin: 4px 0 2px; }
/* Several units: their wire lists scroll in a box of their own, so the
   model and the facts above stay in view however many units there are. */
.replace-units {
  max-height: min(32vh, 260px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
}
.replace-units .replace-wires-wrap { max-height: none; }
.replace-units > .replace-unit:last-child { margin-bottom: 0; }
.replace-unit-rest > .replace-unit { margin-left: 14px; }

.unit-picker-actions .replace-model-go:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.unit-picker-actions .replace-model-go:not(:disabled):hover { background: var(--accent-hover); }
