/**
 * Word preview (docx-preview) only. Downloaded .docx and PDF are unchanged.
 * docx-preview wraps content in `.docx-wrapper` when inWrapper is true (default className "docx").
 * Word often emits inline `color: rgb(0,0,0)`; we override so merged field text reads as "filled" in the UI.
 * Font / spacing CSS vars are set from the preview toolbar (on-screen tuning only).
 */
[data-app-form-docx-preview] .docx-wrapper,
[data-app-form-docx-preview] .docx-wrapper * {
  font-family: var(
    --app-docx-preview-font-family,
    'Times New Roman',
    Times,
    serif
  ) !important;
  font-size: var(--app-docx-preview-font-size, 13pt) !important;
  line-height: var(--app-docx-preview-line-height, 1.25) !important;
  color: hsl(var(--app-form-docx-preview-fill, 225 60% 38%)) !important;
}

[data-app-form-docx-preview][data-preview-bold='true'] .docx-wrapper,
[data-app-form-docx-preview][data-preview-bold='true'] .docx-wrapper * {
  font-weight: 700 !important;
}

[data-app-form-docx-preview][data-preview-italic='true'] .docx-wrapper,
[data-app-form-docx-preview][data-preview-italic='true'] .docx-wrapper * {
  font-style: italic !important;
}

.dark [data-app-form-docx-preview] .docx-wrapper,
.dark [data-app-form-docx-preview] .docx-wrapper * {
  color: hsl(var(--app-form-docx-preview-fill-dark, 213 80% 72%)) !important;
}

/* Section layout filter (see bieuMauPreviewSections.ts) */
[data-app-form-docx-preview][data-bieu-layout-filter-active='true']
  .docx-wrapper
  [data-bieu-section]:not(.bieu-section-visible) {
  opacity: 0.14;
  filter: grayscale(0.35);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

[data-app-form-docx-preview][data-bieu-layout-filter-active='true']
  .docx-wrapper
  [data-bieu-section].bieu-section-visible {
  opacity: 1;
  filter: none;
}

/* Justified body text: avoid huge rivers between words (matches injectDocxJustifyMitigationStyles). */
[data-app-form-docx-preview] .docx-wrapper p[style*='text-align: justify'],
[data-app-form-docx-preview] .docx-wrapper p[style*='text-align:justify'],
[data-app-form-docx-preview] .docx-wrapper p[style*='text-align: distribute'],
[data-app-form-docx-preview] .docx-wrapper p[style*='text-align:distribute'],
[data-app-form-docx-preview] .docx-wrapper li[style*='text-align: justify'],
[data-app-form-docx-preview] .docx-wrapper li[style*='text-align:justify'],
[data-app-form-docx-preview] .docx-wrapper td[style*='text-align: justify'],
[data-app-form-docx-preview] .docx-wrapper td[style*='text-align:justify'] {
  text-align: justify !important;
  text-align-last: start !important;
  text-justify: inter-word !important;
  text-wrap: pretty !important;
  hyphens: auto !important;
  -webkit-hyphens: auto !important;
  overflow-wrap: break-word !important;
  word-break: normal !important;
}
