/* cygenix-history.css
 * --------------------
 * Styles for the shared History modal. All selectors are scoped under
 * .cygenix-history-modal so they don't collide with the host page's CSS.
 */

.cygenix-history-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--serif, system-ui, sans-serif);
}
.cygenix-history-modal.open { display: flex; }

.cygenix-history-modal .ch-card {
  background: var(--bg2, #1a1d24);
  color: var(--text1, #e8e8e8);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 8px;
  /* Wider than the previous 900px to fit the side-by-side compare view.
     Falls back gracefully on narrower viewports. */
  width: min(1300px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.cygenix-history-modal .ch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}
.cygenix-history-modal .ch-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.cygenix-history-modal .ch-sub {
  font-size: 11px;
  color: var(--text3, #8a8a8a);
  margin-top: 2px;
  font-family: var(--mono, monospace);
}
.cygenix-history-modal .ch-close {
  background: transparent;
  color: var(--text2, #c0c0c0);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.cygenix-history-modal .ch-close:hover { color: var(--text1, #fff); }

.cygenix-history-modal .ch-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  min-height: 0;
}

.cygenix-history-modal .ch-list {
  border-right: 1px solid var(--border, rgba(255,255,255,0.08));
  overflow-y: auto;
  padding: 6px 0;
}
.cygenix-history-modal .ch-row {
  padding: 10px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cygenix-history-modal .ch-row:hover {
  background: var(--bg3, rgba(255,255,255,0.04));
}
.cygenix-history-modal .ch-row.active {
  background: var(--bg3, rgba(255,255,255,0.06));
  border-left-color: var(--accent, #6da9ff);
}
.cygenix-history-modal .ch-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono, monospace);
}
.cygenix-history-modal .ch-ver { font-weight: 600; color: var(--text1, #fff); }
.cygenix-history-modal .ch-label {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cygenix-history-modal .ch-label.auto       { background: var(--accent-glow, rgba(109,169,255,0.15)); color: var(--accent, #6da9ff); }
.cygenix-history-modal .ch-label.manual     { background: var(--teal-bg, rgba(45,212,191,0.15)); color: var(--teal, #2dd4bf); }
.cygenix-history-modal .ch-label.pre-revert { background: var(--purple-bg, rgba(167,139,250,0.15)); color: var(--purple, #a78bfa); }

.cygenix-history-modal .ch-meta {
  color: var(--text3, #8a8a8a);
  font-family: var(--mono, monospace);
  font-size: 10px;
}
.cygenix-history-modal .ch-note {
  color: var(--text2, #c0c0c0);
  font-size: 11px;
  font-style: italic;
}

.cygenix-history-modal .ch-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.cygenix-history-modal .ch-detail-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cygenix-history-modal .ch-detail-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}
/* Side-by-side compare layout. The detail area below the header becomes
   a 2-column grid with sticky column headers above each pane. Each pane
   scrolls independently, but the JS in selectVersion() syncs their scroll
   positions so paired lines stay aligned. */
.cygenix-history-modal .ch-compare {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.cygenix-history-modal .ch-pane-header {
  padding: 8px 14px;
  font-family: var(--mono, monospace);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3, #8a8a8a);
  background: var(--bg3, rgba(255,255,255,0.03));
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}
.cygenix-history-modal .ch-pane-header-left  { border-right: 1px solid var(--border, rgba(255,255,255,0.08)); }
.cygenix-history-modal .ch-pane {
  overflow: auto;
  padding: 4px 0;
  font-family: var(--mono, monospace);
  font-size: 11px;
  line-height: 1.6;
}
.cygenix-history-modal .ch-pane-left  { border-right: 1px solid var(--border, rgba(255,255,255,0.08)); }
.cygenix-history-modal .ch-pane-empty {
  padding: 24px;
  text-align: center;
  color: var(--text3, #8a8a8a);
  font-size: 12px;
  font-family: var(--serif, system-ui, sans-serif);
}

/* Diff line styles. Each row in either pane is one of these. The colours
   are tuned so a glance tells you which side has the change without
   reading the text. */
.cygenix-history-modal .ch-line {
  padding: 0 14px;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  min-height: 1.6em;
}
.cygenix-history-modal .ch-line-same     { color: var(--text2, #c0c0c0); }
.cygenix-history-modal .ch-line-changed  {
  background: rgba(234, 179, 8, 0.12);   /* amber */
  color: var(--text1, #e8e8e8);
  border-left: 2px solid rgba(234, 179, 8, 0.6);
  padding-left: 12px;
}
.cygenix-history-modal .ch-line-added    {
  background: rgba(34, 197, 94, 0.13);   /* green */
  color: var(--text1, #e8e8e8);
  border-left: 2px solid rgba(34, 197, 94, 0.7);
  padding-left: 12px;
}
.cygenix-history-modal .ch-line-removed  {
  background: rgba(239, 68, 68, 0.13);   /* red */
  color: var(--text1, #e8e8e8);
  border-left: 2px solid rgba(239, 68, 68, 0.7);
  padding-left: 12px;
}
.cygenix-history-modal .ch-line-blank    {
  background: var(--bg3, rgba(255,255,255,0.02));
}

/* Stats badges in the detail header — small counts that summarise the
   diff so the user gets a feel for scale before scrolling. */
.cygenix-history-modal .ch-stats { font-family: var(--mono, monospace); }
.cygenix-history-modal .ch-stat {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  font-weight: 600;
}
.cygenix-history-modal .ch-stat-changed { background: rgba(234,179,8,0.18); color: rgb(234,179,8); }
.cygenix-history-modal .ch-stat-added   { background: rgba(34,197,94,0.18); color: rgb(34,197,94); }
.cygenix-history-modal .ch-stat-removed { background: rgba(239,68,68,0.18); color: rgb(239,68,68); }

/* Smaller comparison-sub text inside the title line, so "Comparing v3
   vs v2 (previous)" reads as one phrase rather than fighting for emphasis. */
.cygenix-history-modal .ch-detail-sub {
  font-weight: 400;
  color: var(--text3, #8a8a8a);
  font-size: 12px;
  margin-left: 4px;
}

.cygenix-history-modal .ch-empty {
  padding: 24px;
  text-align: center;
  color: var(--text3, #8a8a8a);
  font-size: 12px;
}

.cygenix-history-modal .ch-btn {
  font-family: var(--serif, system-ui, sans-serif);
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  background: transparent;
  color: var(--text2, #c0c0c0);
}
.cygenix-history-modal .ch-btn:hover { color: var(--text1, #fff); }
.cygenix-history-modal .ch-btn.primary {
  background: var(--accent, #6da9ff);
  color: #000;
  border-color: transparent;
  font-weight: 600;
}
.cygenix-history-modal .ch-btn.danger {
  background: var(--red-bg, rgba(240,70,70,0.15));
  color: var(--red, #f04646);
  border-color: rgba(240,70,70,0.3);
}
.cygenix-history-modal .ch-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
