/* Form display: a record pager over a vertical editable form. Colours, borders,
   radius and spacing come from the active CiviCRM theme (RiverLea --crm-*
   variables) with fallbacks, so it follows the current stream and dark mode. */

.crm-search-form-pager {
  display: flex;
  align-items: center;
  gap: var(--crm-flex-gap, 8px);
  margin-bottom: var(--crm-padding-medium, 12px);
}

.crm-search-form-pager-count {
  font-weight: bold;
  min-width: 4em;
  text-align: center;
  color: var(--crm-text-color, inherit);
}

.crm-search-form-record {
  background: var(--crm-container-bg-color, #fff);
  border: var(--crm-border, 1px solid #dfe3e8);
  border-radius: var(--crm-l-radius, 6px);
  box-shadow: var(--crm-shadow-block, 0 1px 2px rgba(0, 0, 0, 0.08));
  padding: var(--crm-padding-medium, 14px) var(--crm-padding-reg, 16px);
  max-width: 640px;
}

/* Grid of record-forms. One column at 1x1 (keeps the single-form look); a
   CSS-var column count otherwise, mirroring the searchkit_box boxes-per-row
   grid, with a responsive fallback to a single column on narrow screens. */
.crm-search-form-grid {
  display: grid;
  grid-template-columns: repeat(var(--form-cols, 1), minmax(0, 1fr));
  gap: var(--crm-padding-medium, 14px);
  align-items: start;
}
.crm-search-form-grid.is-grid .crm-search-form-record {
  max-width: none;
  height: 100%;
}
@media (max-width: 720px) {
  .crm-search-form-grid { grid-template-columns: 1fr; }
}

.crm-search-form-field {
  margin-bottom: var(--crm-padding-medium, 12px);
}

.crm-search-form-label {
  display: block;
  font-weight: bold;
  margin-bottom: 4px;
  color: var(--crm-text-color, inherit);
}

.crm-search-form-value input,
.crm-search-form-value select,
.crm-search-form-value textarea,
.crm-search-form-value .crm-form-contact,
.crm-search-form-value .select2-container {
  width: 100%;
  max-width: 100%;
}

.crm-search-form-actions {
  margin-top: var(--crm-padding-medium, 14px);
  padding-top: var(--crm-padding-small, 10px);
  border-top: 1px solid var(--crm-border-color, #e0e4e8);
}

/* Inline notices (record dropped from search, browse-set capped). */
.crm-search-form-notice {
  margin-bottom: var(--crm-padding-medium, 12px);
  max-width: 640px;
}

/* Section heading grouping fields within the record. */
.crm-search-form-section {
  margin: var(--crm-padding-medium, 16px) 0 var(--crm-padding-small, 8px);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--crm-border-color, #e0e4e8);
  font-size: 1.05em;
  font-weight: bold;
  color: var(--crm-text-color, inherit);
}
.crm-search-form-item:first-child .crm-search-form-section {
  margin-top: 0;
}

/* Unsaved-changes hint next to the pager. */
.crm-search-form-dirty {
  margin-left: var(--crm-flex-gap, 8px);
  font-size: 0.9em;
  color: var(--crm-warning, #b8860b);
}

.crm-search-form-error {
  margin-top: var(--crm-padding-medium, 12px);
}

/* Save / Discard / Cancel guard, centred over the display. */
.crm-search-form-guard-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

.crm-search-form-guard {
  max-width: 460px;
  width: 90%;
  margin: 0;
  box-shadow: var(--crm-shadow-popup, 0 4px 16px rgba(0, 0, 0, 0.25));
}

.crm-search-form-guard-actions {
  display: flex;
  gap: var(--crm-flex-gap, 8px);
  justify-content: flex-end;
}

.crm-search-form-guard-error {
  margin-bottom: 0;
}
