/* Diff viewer (#406, js/diff_view.js): one file's changes, unified or side by side. Reusable - the Git
   view's detail pane hosts it; colours come from the theme variables (--ok / --danger / --panel ...)
   mixed into transparent, so both themes work. One table in one scroll box: long lines scroll sideways
   and, side by side, both halves move together. */
.diff-view { display: flex; flex-direction: column; min-height: 0; min-width: 0; flex: 1; font-size: 12px; }

.diff-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 0; color: var(--muted); }
.diff-toolbar-gap { flex: 1; }
.diff-modes { display: inline-flex; }
.diff-modes .diff-mode-btn { border-radius: 0; }
.diff-modes .diff-mode-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.diff-modes .diff-mode-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; }
.diff-mode-btn.active { background: color-mix(in srgb, var(--accent) 22%, var(--panel)); border-color: var(--accent); color: var(--text); position: relative; }
.diff-context-label { display: inline-flex; align-items: center; gap: 6px; }
.diff-context {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 6px;
  font-size: 12px;
}

.diff-body { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.diff-content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.diff-file { display: flex; align-items: center; gap: 8px; padding: 4px 0 6px; min-width: 0; }
.diff-path { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.diff-status {
  flex: none;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
  text-transform: capitalize;
}
.diff-status-added { color: var(--ok); }
.diff-status-deleted { color: var(--danger); }
.diff-file-stat { flex: none; display: flex; gap: 6px; font-family: ui-monospace, monospace; }
.diff-file-bin { flex: none; color: var(--muted); }
.diff-add-count { color: var(--ok); }
.diff-del-count { color: var(--danger); }
/* links into the file (#817, js/diff_view.js onOpenFile): the head's path and the line numbers as buttons that read as text */
.diff-open-file { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.diff-num-btn { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.diff-open-file:hover, .diff-num-btn:hover { color: var(--accent); text-decoration: underline; }
.diff-open-file:focus-visible, .diff-num-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.diff-state { padding: 18px 8px; color: var(--muted); text-align: center; }
.diff-error { color: var(--danger); }

.diff-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.diff-scroll:focus { outline: none; }
.diff-table {
  border-collapse: collapse;
  min-width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 18px;
  tab-size: 4;
}
.diff-table td { padding: 0 8px; vertical-align: top; }
.diff-text { white-space: pre; }
.diff-num {
  min-width: 3.5ch;
  padding: 0 6px;
  text-align: right;
  color: var(--muted-2);
  user-select: none;
  white-space: nowrap;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}
.diff-sign { width: 1ch; padding: 0 2px 0 6px; color: var(--muted); user-select: none; }
.diff-hunk td {
  padding: 2px 8px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--muted);
  white-space: pre;
}
.diff-unified .diff-add td:not(.diff-num), .diff-split .diff-text.diff-add { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.diff-unified .diff-del td:not(.diff-num), .diff-split .diff-text.diff-del { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.diff-unified .diff-add .diff-num { background: color-mix(in srgb, var(--ok) 28%, transparent); }
.diff-unified .diff-del .diff-num { background: color-mix(in srgb, var(--danger) 28%, transparent); }
.diff-split .diff-num.diff-add { background: color-mix(in srgb, var(--ok) 28%, transparent); }
.diff-split .diff-num.diff-del { background: color-mix(in srgb, var(--danger) 28%, transparent); }
/* the filler facing a one-sided change */
.diff-split .diff-empty { background: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--muted) 10%, transparent) 4px 8px); }
.diff-split .diff-new-num { border-left: 1px solid var(--border); }
.diff-split .diff-text { min-width: 24ch; width: 50%; }
