/* ---- Layout preservation for imported .docx ------------------------ */
/* These rules ensure that content loaded from .docx files retains its
   layout: table widths, font sizes, text alignment, spacing, etc.
   Inline styles from mammoth take precedence over these defaults. */

/* Tables: respect inline width styles, preserve cell widths */
.docx-editor-content table[style*="width"],
.docx-editor-content .ProseMirror table[style*="width"] {
  width: auto; /* let inline style control */
}
.docx-editor-content td[style*="width"],
.docx-editor-content .ProseMirror td[style*="width"],
.docx-editor-content th[style*="width"],
.docx-editor-content .ProseMirror th[style*="width"] {
  width: auto; /* let inline style control */
}

/* Font sizes from imported docs (mammoth wraps in <span style="font-size:...">) */
.docx-editor-content span[style*="font-size"],
.docx-editor-content .ProseMirror span[style*="font-size"] {
  font-size: inherit; /* respect the inline style */
}

/* Text alignment from imported docs */
.docx-editor-content p[style*="text-align"],
.docx-editor-content .ProseMirror p[style*="text-align"],
.docx-editor-content h1[style*="text-align"],
.docx-editor-content h2[style*="text-align"],
.docx-editor-content h3[style*="text-align"],
.docx-editor-content .ProseMirror h1[style*="text-align"],
.docx-editor-content .ProseMirror h2[style*="text-align"],
.docx-editor-content .ProseMirror h3[style*="text-align"] {
  text-align: inherit; /* respect the inline style */
}

/* Imported lists: preserve indentation */
.docx-editor-content ul[style*="margin-left"],
.docx-editor-content ol[style*="margin-left"],
.docx-editor-content .ProseMirror ul[style*="margin-left"],
.docx-editor-content .ProseMirror ol[style*="margin-left"] {
  margin-left: inherit;
}

/* Imported images: preserve dimensions */
.docx-editor-content img[width],
.docx-editor-content .ProseMirror img[width] {
  width: auto; /* let the width attribute or inline style control */
  max-width: 100%;
}

/* Spacing: preserve paragraph margins from imported docs */
.docx-editor-content p[style*="margin"],
.docx-editor-content .ProseMirror p[style*="margin"] {
  margin: inherit;
}

.docx-editor-content hr, .docx-editor-content .ProseMirror hr {
  border: none;
  border-top: 1px solid #d0d7de;
  margin: 1em 0;
  page-break-after: avoid;
}

.docx-editor-content p.docx-caption, .docx-editor-content .ProseMirror p.docx-caption {
  font-size: 9pt;
  color: #57606a;
  font-style: italic;
  text-align: center;
}

.docx-editor-content sub, .docx-editor-content sup,
.docx-editor-content .ProseMirror sub, .docx-editor-content .ProseMirror sup {
  font-size: 0.75em;
  line-height: 0;
}

/* Selected table cell highlight (TipTap) */
.docx-editor-content .selectedCell:after,
.docx-editor-content .ProseMirror .selectedCell:after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--de-selection);
  pointer-events: none;
  z-index: 2;
}
