/* Add any CSS rules for Angular module "crmRevisionist" */

/*
 * The history dialog is opened either via crm-dialog-popup (SearchKit admin
 * listing) or a SearchKit "task" uiDialog (FormBuilder admin table) - neither
 * call site lets us pass custom jQuery-UI-dialog width/height options, so the
 * default (a fixed 40%-of-window height) applies. Overriding it here with
 * :has() scopes the override to *this* dialog's content only, leaving every
 * other search-task/popup dialog in CiviCRM untouched. vw/vh units make it
 * naturally responsive to window resizing without any JS.
 */
.ui-dialog:has(.revisionist-history-panel) {
  width: 92vw !important;
  max-width: 1200px !important;
  height: 85vh !important;
}

.ui-dialog:has(.revisionist-history-panel) .ui-dialog-content {
  height: calc(100% - 3em) !important;
  max-height: none !important;
}

.revisionist-history-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.revisionist-body {
  display: flex;
  flex: 1 1 auto;
  gap: 16px;
  /* Lets the flex children scroll internally instead of growing past the
     dialog and pushing the Close button off-screen. */
  min-height: 0;
}

.revisionist-sidebar {
  flex: 0 0 260px;
  overflow-y: auto;
}

.revisionist-current-marker {
  padding: 6px 10px;
  margin-bottom: 8px;
  border-left: 3px solid #5bc0de;
  background-color: rgba(91, 192, 222, 0.12);
  cursor: pointer;
}

.revisionist-current-marker.active {
  border-left-color: #2777a4;
  background-color: rgba(91, 192, 222, 0.28);
}

.revisionist-pinned-filter {
  /* Scaled down like .revisionist-pin-toggle below - the default
     crm-form-toggle is sized for a standalone form row. */
  transform: scale(0.85);
  transform-origin: left center;
  color: #767676;
  font-size: 0.9em;
  margin-bottom: 8px;
  cursor: pointer;
}

.revisionist-history-list > li {
  cursor: pointer;
  position: relative;
}

.revisionist-pin-toggle {
  float: right;
  padding: 1px 6px;
}

.revisionist-description {
  margin: 4px 0 8px 0;
}

/* Click-to-edit affordance matching SearchKit's own inline-edit convention
   (see #bootstrap-theme.crm-search .crm-editable-enabled in search_kit's
   crmSearchAdmin.css) - invisible border normally, dashed on hover, so it
   doesn't look like a permanent input box until the user actually wants to
   edit it. display:block (not inline-block) so a short/empty description
   doesn't leave room on the same line for whatever follows (e.g. the
   Restore button) to render alongside it instead of on its own line.
   width:fit-content keeps the hover border snug around the text rather
   than stretching the full row width. */
.revisionist-description-display {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 4px 0 8px 0;
  padding: 1px 4px;
  border: 1px dashed transparent;
  border-radius: 2px;
  cursor: text;
  min-width: 40px;
}

.revisionist-description-display:hover {
  border-color: #999;
}

.revisionist-description-edit {
  position: relative;
  margin: 4px 0 8px 0;
}

.revisionist-description-edit .revisionist-description {
  margin: 0;
  padding-right: 22px;
}

.revisionist-description-clear {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  border: 0;
  background: none;
  padding: 2px 4px;
  color: #999;
  cursor: pointer;
}

.revisionist-description-clear:hover {
  color: #333;
}

.revisionist-detail {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.revisionist-display-restore {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(128, 128, 128, 0.2);
}

.revisionist-detail-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.revisionist-compare-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

/*
 * flex:1 1 auto here is only meant to apply inside .revisionist-compare-row's
 * horizontal layout, so this note takes the remaining width next to the
 * compare-toggle buttons. But the same element/class is also used standalone
 * (not inside .revisionist-compare-row) for the "Current version" note,
 * where it's a direct child of .revisionist-detail-inner's *column* flex
 * layout instead - there flex:1 1 auto grows it vertically to fill leftover
 * space, pushing the tab bar down. Scope the growth to the row context only;
 * the standalone case gets a plain, non-growing block below.
 */
.revisionist-compare-row .revisionist-compare-note {
  flex: 1 1 auto;
}

.revisionist-compare-note {
  flex: 0 0 auto;
  margin-bottom: 6px;
}

.revisionist-compare-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.revisionist-tabs {
  flex: 0 0 auto;
  margin-bottom: 0;
}

.revisionist-tab-content {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  border: 1px solid #ddd;
  border-top: 0;
  padding: 8px;
}

/*
 * Angular ng-if adds/removes this element from the DOM entirely rather than
 * toggling Bootstrap's .open class, so it needs its own display rule instead
 * of relying on ".open > .dropdown-menu". Scoped to this list only.
 */
.revisionist-history-list .dropdown-menu {
  display: block;
}

.revisionist-field-row {
  padding: 6px 8px;
  margin-bottom: 4px;
}

/* An inline row (key: value on one line) needs much less padding than a
   multi-line JSON/text block - :has() scopes the tighter padding to just
   those rows without a separate modifier class on the parent. */
.revisionist-field-row:has(.revisionist-field-inline) {
  padding: 3px 8px;
}

.revisionist-field-inline .revisionist-diff-marker {
  width: auto;
  margin-right: 0.2em;
}

.revisionist-field-name {
  font-weight: bold;
  margin-bottom: 2px;
}

/* Plain (non-diff) field=>value listing used for "Current version" - no
   status coloring, just a light separator between rows. */
.revisionist-field-row-plain {
  padding: 3px 8px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.revisionist-field-row-plain:last-child {
  border-bottom: 0;
}

/*
 * Applied to a whole field-row, which can contain a mix of removed (red) and
 * added (green) lines for a "changed" field - so only a border-left accent
 * here, not a background, to avoid layering a third color behind the
 * per-line backgrounds below.
 */
.revisionist-diff-added,
.revisionist-diff-removed,
.revisionist-diff-changed {
  border-left: 3px solid transparent;
}

.revisionist-diff-added {
  border-left-color: #2ea043;
}

.revisionist-diff-removed {
  border-left-color: #d9534f;
}

.revisionist-diff-changed {
  border-left-color: #f0ad4e;
}

/*
 * Semi-transparent rgba() overlays rather than solid pastel hex backgrounds,
 * so these blend correctly with whatever the surrounding theme's background
 * is - light or dark - instead of punching a bright light-mode-only patch
 * into a dark dialog.
 */

.revisionist-diff-lines {
  font-family: monospace;
  white-space: pre-wrap;
}

.revisionist-diff-line-added {
  background-color: rgba(46, 160, 67, 0.18);
}

.revisionist-diff-line-removed {
  background-color: rgba(217, 83, 79, 0.18);
}

.revisionist-diff-marker {
  display: inline-block;
  width: 1.2em;
  font-weight: bold;
}

/* Marks where a run of unchanged lines was collapsed - see collapseContext()
   in crmRevisionDiff.component.js. Kept visually quiet since it's a gap
   marker, not content. */
.revisionist-diff-context {
  color: #767676;
  font-style: italic;
  padding-left: 1.2em;
}
