/* === Preview card ============================================================ */
.preview-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.preview-card:empty { display: none; }
.lform-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  transition: background .12s;
}
.lform-item:last-child { border-bottom: none; }
.lform-item:hover { background: #f5f8fc; }
.lform-item.success {
  background: var(--c-ok-bg);
  border-left: 3px solid var(--c-ok-border);
}
.lform-item.error {
  background: var(--c-err-bg);
  border-left: 3px solid var(--c-err-border);
}

/* === Nested group children =================================================== */
.preview-nested {
  border-left: 3px solid var(--c-primary-lt);
  margin-left: 45px;
  background: #f7f9fc;
}
.preview-nested .lform-item {
  padding-left: 14px;
  font-size: 13px;
}
.preview-nested .preview-nested {
  margin-left: 35px;
  border-left-color: var(--c-border);
}
.group-label       { font-weight: 600; color: var(--c-primary); font-size: 13px; }
.display-info-label { font-style: italic; color: var(--c-text-2); font-size: 12px; }

/* === Group itemControl: header / footer ===================================== */
.lform-group-header { border-bottom: 2px solid var(--c-primary, #2563eb); padding-bottom: 6px; }
.lform-group-header .group-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
  text-transform: uppercase;
}
.lform-group-footer { border-top: 1px solid var(--c-border, #e0e0e0); padding-top: 6px; }
.lform-group-footer .group-label {
  font-size: 11px;
  font-weight: 400;
  font-style: italic;
  color: var(--c-text-2, #6b7280);
  text-transform: none;
}
.preview-group-ctrl-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 1px 7px;
  border-radius: 8px;
  flex-shrink: 0;
  margin-top: 3px;
  background: transparent;
  color: var(--c-primary, #2563eb);
  border: 1px solid currentColor;
  cursor: help;
}

/* === Collapse toggle in preview ============================================== */
.preview-collapse-toggle {
  font-size: 10px;
  color: #999;
  width: 16px;
  flex-shrink: 0;
  display: inline-block;
  text-align: center;
  cursor: pointer;
  user-select: none;
  margin-right: 2px;
}
.preview-collapse-toggle:hover { color: #444; }

/* === AND/OR badge ============================================================ */
.preview-logic-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 10px;
  flex-shrink: 0;
  margin-top: 3px;
  cursor: help;
}
.preview-logic-and { background: #ecf0f1; color: #5d6d7e; }
.preview-logic-or  { background: #fff3e0; color: #e65100; }

/* === Required star / optional badge ========================================= */
.preview-required-star {
  color: var(--c-err);
  font-size: 13px;
  line-height: 1;
  margin-left: 2px;
  font-weight: 700;
}
.preview-optional-badge {
  font-size: 10px;
  color: #999;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 1px 7px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 3px;
  font-style: italic;
}

/* === enableWhen condition hint =============================================== */
.preview-condition-hint {
  font-size: 11px;
  color: var(--c-text-2);
  background: #f5f5f5;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 1px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  flex-shrink: 1;
  margin-top: 3px;
}
.preview-condition-hint.preview-condition-waiting {
  background: #fff8e1;
  border-color: #ffe082;
  color: #795548;
}

/* === questionnaire-constraint badge ========================================= */
.preview-constraint-badge {
  font-size: 11px;
  color: #795548;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 10px;
  padding: 1px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 3px;
  cursor: default;
}
.preview-constraint-badge--fail {
  color: #b71c1c;
  background: #ffebee;
  border-color: #ef9a9a;
}

/* === read-only / initial value meta badges ================================== */
.preview-meta-badge {
  font-size: 11px;
  color: #546e7a;
  background: #eceff1;
  border: 1px solid #b0bec5;
  border-radius: 10px;
  padding: 1px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 3px;
  cursor: default;
}
.preview-meta-badge--init {
  color: #4527a0;
  background: #ede7f6;
  border-color: #b39ddb;
}
.preview-meta-badge--repeats {
  color: #1565c0;
  background: #e3f2fd;
  border-color: #90caf9;
}
.preview-meta-badge--sig {
  color: #6a1b9a;
  background: #f3e5f5;
  border-color: #ce93d8;
}
.preview-meta-badge--subject {
  color: #00695c;
  background: #e0f2f1;
  border-color: #80cbc4;
}

/* Reference info hints (profile / filter) */
.ctrl-ref-info {
  display: block;
  font-size: 11px;
  color: #78909c;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
  cursor: default;
}

/* Repeatable item UI */
.repeat-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.repeat-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.repeat-remove-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #999;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.repeat-remove-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}
.repeat-add-btn {
  align-self: flex-start;
  padding: 3px 10px;
  border: 1px dashed #90caf9;
  border-radius: 4px;
  background: #f0f7ff;
  color: #1565c0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.repeat-add-btn:hover {
  background: #e3f2fd;
  border-color: #42a5f5;
}

/* === Repeating group instances ============================================== */
.rg-instances {
  padding: 6px 2px 2px;
  background: transparent;  /* do not inherit preview-nested's opaque bg — tint must accumulate */
  border-left: none;
  margin-left: 0;
}
.rg-inst {
  position: relative;
  border: 1.5px dashed #b9c6d6;
  border-radius: 8px;
  padding: 10px;
  margin: 5px;
  background: rgba(15, 40, 80, 0.04);
}
.rg-inst .repeat-remove-btn.rg-del {
  position: absolute;
  top: -11px;
  left: 10px;
  z-index: 1;
}
.preview-readonly-value {
  display: inline-block;
  font-size: 13px;
  color: var(--c-text-2, #546e7a);
  background: #f5f7fa;
  border: 1px solid var(--c-border, #dde3ec);
  border-radius: var(--r-sm, 4px);
  padding: 2px 8px;
  min-width: 40px;
  cursor: not-allowed;
}
.preview-calc-value {
  display: inline-block;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 4px;
  margin-left: 6px;
  background: #f0f4ff;
  color: #3b4db8;
  border: 1px solid #c7d2fe;
  font-variant-numeric: tabular-nums;
}

/* === AND/OR separator between sibling items ================================== */
.logic-separator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #aaa;
  margin: 2px 14px;
}
.logic-separator::before,
.logic-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}
.logic-separator-and { color: var(--c-primary); }
.logic-separator-and::before,
.logic-separator-and::after { background: #c5d8f6; }
.logic-separator-or  { color: #e65100; }
.logic-separator-or::before,
.logic-separator-or::after { background: #ffe0b2; }

/* === Group table layout (questionnaire-itemControl: gtable) ================ */
.gtable {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 14px 8px;
  font-size: 0.87rem;
  width: calc(100% - 28px);
}
.gtable th.gtable-th {
  text-align: left;
  padding: 5px 10px;
  border-bottom: 2px solid var(--c-border, #dde);
  color: var(--c-label, #555);
  font-weight: 600;
  white-space: nowrap;
  background: var(--c-surface-alt, #f7f9fc);
}
.gtable th.gtable-th-action {
  width: 2.2rem;
}
.gtable td.gtable-td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--c-border-light, #edf0f5);
  vertical-align: middle;
}
.gtable td.gtable-td-action {
  width: 2.2rem;
  text-align: center;
  vertical-align: middle;
}
.gtable td.gtable-tfoot-td {
  padding: 4px 8px;
}
/* Cell-mode item: strip the row wrapper visually — let the control fill the cell */
.gtable .gtable-cell-item {
  display: contents;
}
/* Remove hover/padding from lform-item inside a gtable cell */
.gtable td .lform-item {
  padding: 0;
  gap: 4px;
}
.gtable td .lform-item:hover { background: transparent; }
/* Remove button */
.gtable-rm-btn {
  border: none;
  background: transparent;
  color: var(--c-danger, #e74c3c);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 3px;
  cursor: pointer;
}
.gtable-rm-btn:hover { background: rgba(231, 76, 60, 0.1); }
/* Add row button */
.gtable-add-btn {
  font-size: 0.82rem;
  padding: 3px 10px;
  margin: 2px 0;
}
/* Required star inside column header */
.gtable-required-star {
  color: var(--c-danger, #e74c3c);
  font-weight: 700;
}
/* Builder badge for gtable */
.preview-group-ctrl-badge--gtable {
  background: transparent;
  border: 1px solid var(--c-primary, #3498db);
  color: var(--c-primary, #3498db);
}
/* Column header indicators: separate sub-row below the title */
.gtable-th-title {
  display: block;
}
.gtable-th-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
  opacity: 0.75;
}
.gtable-col-ind {
  display: inline-block;
  font-size: 0.75em;
  line-height: 1;
  vertical-align: middle;
  cursor: default;
  text-decoration: none;
}
.gtable-col-ind--optional {
  font-size: 0.68em;
  font-weight: 500;
  color: #888;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 0 3px;
  line-height: 1.4;
}

