/*
 * Editorial Structured Content companion — Official Form Body Rhythm
 *
 * Final presentation sublayer for official-form body tables.
 * Bản Tin loads it after article composition CSS; Thư Viện and TinyMCE load it
 * after editorial-structured-content.css.
 *
 * Purpose:
 * - preserve compact fit-only typography for wide official matrices;
 * - restore visible writing height for meaningful all-blank input rows;
 * - give full-width section/description rows enough vertical breathing room;
 * - suppress editorial zebra/hover treatment inside formal document bodies;
 * - change presentation only; canonical HTML/table semantics remain unchanged.
 */

/*
 * Formal-document body rows stay paper-white.
 *
 * Keep this explicit in the final companion layer so generic zebra/hover rules
 * from any earlier table/article stylesheet cannot leak back into the form.
 */
:where(.ct-prose, body.mce-content-body)
  .ct-official-document
  table.ct-data-table.is-complex
  > tbody
  > tr
  > td {
  background: #fff;
}

@media (hover: hover) {
  :where(.ct-prose, body.mce-content-body)
    .ct-official-document
    table.ct-data-table.is-complex
    > tbody
    > tr:hover
    > td {
    background: #fff;
  }
}

/*
 * Meaningful blank input row.
 *
 * Require at least two direct TDs and no non-empty direct TD. This avoids
 * touching totals, section labels, colspan notes and ordinary populated rows.
 */
:where(.ct-prose, body.mce-content-body)
  .ct-official-document
  table.ct-data-table.is-complex
  > tbody
  > tr:has(> td:nth-child(2)):not(:has(> td:not(:empty)))
  > td {
  height: 24px;
  padding-top: 0;
  padding-bottom: 0;
  vertical-align: middle;
}

/*
 * Full-width form section/description band such as:
 * “1. Hàng hóa, dịch vụ ...”. Keep source typography/italics intact and only
 * restore vertical rhythm that generic 8+/11+ column density would compress.
 */
:where(.ct-prose, body.mce-content-body)
  .ct-official-document
  table.ct-data-table.is-complex
  > tbody
  > tr
  > td:only-child[colspan] {
  padding-top: 7px;
  padding-bottom: 7px;
  line-height: 1.4;
}

@media (max-width: 640px) {
  :where(.ct-prose, body.mce-content-body)
    .ct-official-document
    table.ct-data-table.is-complex
    > tbody
    > tr:has(> td:nth-child(2)):not(:has(> td:not(:empty)))
    > td {
    height: 20px;
  }

  :where(.ct-prose, body.mce-content-body)
    .ct-official-document
    table.ct-data-table.is-complex
    > tbody
    > tr
    > td:only-child[colspan] {
    padding-top: 6px;
    padding-bottom: 6px;
    line-height: 1.35;
  }
}
