/* Admin form-builder field preview cards.
   Each card renders the BA-side form field exactly as a BA would see it,
   wrapped in admin chrome (type label, edit/delete actions).
   Inputs are visually disabled via pointer-events on the body. */

.fields-preview {
  display: grid;
  gap: 1.5rem;
}

.field-preview-card {
  border: 1px solid var(--light-border-color, #e0e0e0);
  border-radius: 8px;
  background: white;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.field-preview-card:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  border-color: #c5c9d1;
}

.field-preview-card__chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #f8f9fa;
  border-bottom: 1px solid var(--light-border-color, #e0e0e0);
}

.field-preview-card__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.field-preview-card__name {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1f2933;
  margin-right: 0.25rem;
}

.field-preview-card__type {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  font-weight: 600;
}

.field-preview-card__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.field-preview-card__badge--required {
  background: #fff3cd;
  color: #856404;
}

.field-preview-card__badge--conditional {
  background: #fef3e7;
  color: #c66100;
}

.field-preview-card__badge--repeatable {
  background: #e3f2fd;
  color: #0d47a1;
}

.field-preview-card__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.field-preview-card__body {
  padding: 1.5rem 1.5rem 1rem;
  pointer-events: none;
  user-select: none;
}

.field-preview-card__body input,
.field-preview-card__body select,
.field-preview-card__body textarea,
.field-preview-card__body button {
  pointer-events: none;
  background-color: #fafbfc;
}

.field-preview-card__body .repeatable-fields > .dynamic-field {
  margin-bottom: 0;
}

.field-preview-card__children {
  margin-top: 1rem;
  padding-left: 2rem;
  border-left: 3px solid #e9ecef;
  pointer-events: auto; /* re-enable for the chrome */
}

.field-preview-card__child {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed #e9ecef;
}

.field-preview-card__child:last-child {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}

.field-preview-card__child-chrome {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.field-preview-card__child-name {
  font-size: 1.4rem;
  font-weight: 600;
  color: #1f2933;
  margin-right: 0.25rem;
}

/* Pushes the Edit/Delete buttons to the right edge while leaving the type
   label and conditional summary tight to the field name. */
.field-preview-card__child-spacer {
  flex: 1 1 auto;
}

.field-preview-card__child .dynamic-field {
  pointer-events: none;
}

/* The BA-side conditional-fields Stimulus controller hides any field with
   show_conditions when its parent has no matching value. In the admin
   preview every field should always be visible, so override here. The
   form_field partial puts a `hidden` utility class on the wrapper at
   render time when the field is conditional, and the controller sets
   `style.display = none` at runtime — both need to lose to the preview. */
.field-preview-card .dynamic-field,
.field-preview-card .dynamic-field.conditional-field-hidden,
.field-preview-card [data-conditional-fields-target="conditionalField"],
.field-preview-card [data-show-conditions] {
  display: block !important;
  opacity: 1 !important;
}

.field-preview-card .hidden[data-show-conditions] {
  display: block !important;
}

/* The BA-side _form_field partial repeats the field name as an <h3><label>
   above the input. With the chrome already showing the name we'd render it
   twice, so hide the body's heading. */
.field-preview-card__body h3 {
  display: none;
}
