/* templates.css - the Templates panel and the template insight section
 * (p20e). Variables first, one dark block (A12 rule for every module
 * stylesheet). */

:root {
  --tpl-bg: #f2f4f8;
  --tpl-border: #c8cfdc;
  --tpl-text: #232733;
  --tpl-muted: #626b7d;
  --tpl-field-bg: #fbfcfe;
  --tpl-pass: #2f6b3e;
  --tpl-fail: #a03232;
  --tpl-pin: #8a6d1f;
}

body.dark {
  --tpl-bg: #1f2229;
  --tpl-border: #363c49;
  --tpl-text: #dde1e9;
  --tpl-muted: #8f97a8;
  --tpl-field-bg: #262a33;
  --tpl-pass: #7fc08f;
  --tpl-fail: #e08484;
  --tpl-pin: #d3b35a;
}

#templates-panel {
  border: 1px solid var(--tpl-border);
  background: var(--tpl-bg);
  color: var(--tpl-text);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 6px 8px;
  font-size: 12.5px;
  max-height: 55%;
  overflow-y: auto;
}
#templates-panel[hidden] { display: none !important; }

.tpl-panel-head, .tpl-sync-head { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.tpl-panel-title { font-weight: 600; }
.tpl-panel-note { color: var(--tpl-muted); line-height: 1.45; margin: 4px 0 6px; }

.tpl-editor {
  width: 100%;
  box-sizing: border-box;
  background: var(--tpl-field-bg);
  color: var(--tpl-text);
  border: 1px solid var(--tpl-border);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  resize: vertical;
}

.tpl-btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tpl-btn {
  background: var(--tpl-field-bg);
  color: var(--tpl-text);
  border: 1px solid var(--tpl-border);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
}
.tpl-btn:hover { border-color: var(--tpl-muted); }

.tpl-status-line { margin: 4px 0; line-height: 1.4; }
.tpl-ok { color: var(--tpl-pass); }
.tpl-error { color: var(--tpl-fail); }

.tpl-sync-config { display: flex; flex-direction: column; gap: 4px; margin: 4px 0; }
.tpl-sync-input {
  background: var(--tpl-field-bg);
  color: var(--tpl-text);
  border: 1px solid var(--tpl-border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
}
.tpl-ent-line { color: var(--tpl-muted); margin: 2px 0 4px; }

.tpl-sync-row { display: flex; align-items: baseline; gap: 8px; padding: 2px 0; }
.tpl-sync-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tpl-sync-meta { color: var(--tpl-muted); }

.tpl-conflict {
  border: 1px solid var(--tpl-fail);
  border-radius: 4px;
  padding: 6px 8px;
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-conflict[hidden] { display: none !important; }

/* ---- the template insight section (rendered into the insights panel and
 * the dashboard by the shared section renderer) ---- */

.insight-template .tpl-rule { display: flex; flex-direction: column; gap: 2px; padding: 3px 0; }
.tpl-rule-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tpl-status { font-weight: 600; }
.tpl-pass { color: var(--tpl-pass); }
.tpl-fail { color: var(--tpl-fail); }
.tpl-onfail { color: var(--tpl-pin); font-size: 11px; }
.tpl-rule-id { font-weight: 600; }
.tpl-selector { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.tpl-match-count { color: var(--tpl-muted); font-size: 11.5px; }
.tpl-pinned .tpl-rule-id::after { content: " (pinned)"; color: var(--tpl-pin); font-weight: 400; font-size: 11px; }
.tpl-failure { display: flex; align-items: baseline; gap: 8px; padding-left: 14px; }
.tpl-reason { font-size: 12px; }
.tpl-summary { font-weight: 600; }
.tpl-note { font-size: 11.5px; }
