/* GitHub-style text diff (app/views/shared/_text_diff.html.erb).
   Plain CSS rather than Tailwind utilities: the same partial renders inside
   Administrate (its own stylesheet, linked from admin/application/_stylesheet)
   and inside the app, where Propshaft's :app bundle picks this file up.
   Colours are GitHub's light diff palette, so the view reads as the diff
   compliance teams already know. */

.text-diff {
  --diff-fg: #1f2328;
  --diff-muted: #59636e;
  --diff-border: #d1d9e0;
  --diff-canvas: #ffffff;
  --diff-subtle: #f6f8fa;
  --diff-added: #e6ffec;
  --diff-added-num: #d1f8d9;
  --diff-added-word: #abf2bc;
  --diff-added-fg: #1a7f37;
  --diff-removed: #ffebe9;
  --diff-removed-num: #ffcecb;
  --diff-removed-word: rgba(255, 129, 130, 0.4);
  --diff-removed-fg: #d1242f;
  --diff-hunk: #ddf4ff;
  --diff-focus: #0969da;

  position: relative;
  overflow: hidden;
  border: 1px solid var(--diff-border);
  border-radius: 6px;
  background: var(--diff-canvas);
  color: var(--diff-fg);
  font-family: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 20px;
  text-align: left;
}

.text-diff-empty {
  color: #59636e;
  font-size: 14px;
}

/* Layout switch: two visually hidden radios drive the tabs and the views. */
.text-diff__mode {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.text-diff__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--diff-border);
  background: var(--diff-subtle);
  font-family: -apple-system, BlinkMacSystemFont, "Geist", "Segoe UI", Helvetica, Arial, sans-serif;
}

.text-diff__stats {
  display: inline-flex;
  gap: 6px;
  color: var(--diff-muted);
  font-variant-numeric: tabular-nums;
}

.text-diff__count { font-weight: 600; }
.text-diff__count.is-added { color: var(--diff-added-fg); }
.text-diff__count.is-removed { color: var(--diff-removed-fg); }

.text-diff__tabs {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--diff-border);
  border-radius: 6px;
  background: var(--diff-subtle);
}

.text-diff__tab {
  padding: 1px 10px;
  border-radius: 4px;
  color: var(--diff-muted);
  cursor: pointer;
  user-select: none;
}

.text-diff__mode--unified:checked ~ .text-diff__bar .text-diff__tab--unified,
.text-diff__mode--split:checked ~ .text-diff__bar .text-diff__tab--split {
  background: var(--diff-canvas);
  box-shadow: 0 0 0 1px var(--diff-border);
  color: var(--diff-fg);
  font-weight: 600;
}

.text-diff__mode--unified:focus-visible ~ .text-diff__bar .text-diff__tab--unified,
.text-diff__mode--split:focus-visible ~ .text-diff__bar .text-diff__tab--split {
  outline: 2px solid var(--diff-focus);
  outline-offset: 1px;
}

.text-diff__view--split { display: none; }
.text-diff__mode--split:checked ~ .text-diff__view--unified { display: none; }
.text-diff__mode--split:checked ~ .text-diff__view--split { display: block; }

/* Every table of one diff shares these widths (table-layout: fixed), so
   the hunks and the expanded gaps read as one listing. */
.text-diff__table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border-spacing: 0;
}

.text-diff__col-num { width: 52px; }
.text-diff__col-sign { width: 20px; }
.text-diff__table--split .text-diff__col-code { width: calc(50% - 72px); }

.text-diff__table td {
  padding: 0;
  border: 0;
  vertical-align: top;
}

.text-diff__num {
  padding: 0 10px 0 6px !important;
  color: var(--diff-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.text-diff__sign {
  color: var(--diff-muted);
  text-align: center;
  user-select: none;
}

.text-diff__code {
  padding: 0 12px 0 2px !important;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.text-diff__table--split .text-diff__code + .text-diff__num { border-left: 1px solid var(--diff-border); }

.text-diff td.is-added { background: var(--diff-added); }
.text-diff td.text-diff__num.is-added { background: var(--diff-added-num); }
.text-diff td.text-diff__sign.is-added { color: var(--diff-added-fg); }
.text-diff td.is-removed { background: var(--diff-removed); }
.text-diff td.text-diff__num.is-removed { background: var(--diff-removed-num); }
.text-diff td.text-diff__sign.is-removed { color: var(--diff-removed-fg); }
.text-diff td.is-empty { background: var(--diff-subtle); }

.text-diff__word {
  border-radius: 2px;
  color: inherit;
  text-decoration: none;
}
ins.text-diff__word { background: var(--diff-added-word); }
del.text-diff__word { background: var(--diff-removed-word); }

.text-diff__hunk td {
  padding: 4px 10px;
  background: var(--diff-hunk);
  color: var(--diff-muted);
}

.text-diff__gap {
  border-top: 1px solid var(--diff-border);
  border-bottom: 1px solid var(--diff-border);
}
.text-diff__gap + .text-diff__table,
.text-diff__table + .text-diff__gap { border-top: 0; }

.text-diff__gap > summary,
.text-diff__gap--static {
  display: block;
  padding: 4px 12px;
  background: var(--diff-hunk);
  color: var(--diff-muted);
  font-family: -apple-system, BlinkMacSystemFont, "Geist", "Segoe UI", Helvetica, Arial, sans-serif;
  list-style: none;
}
.text-diff__gap > summary { cursor: pointer; }
.text-diff__gap > summary::-webkit-details-marker { display: none; }
.text-diff__gap > summary:hover { color: var(--diff-focus); }
.text-diff__gap > summary:focus-visible { outline: 2px solid var(--diff-focus); outline-offset: -2px; }
.text-diff__gap-open { display: none; }
.text-diff__gap[open] .text-diff__gap-open { display: inline; }
.text-diff__gap[open] .text-diff__gap-closed { display: none; }
