/* Thành Phát EV v0.0.84 — audited editorial tables + image captions.
 * The v083 product selectors looked for ".woocommerce" INSIDE body even when that
 * class is on body itself, so they did not match real WooCommerce product tabs.
 * The new rules target Woo tab panels directly, and an additional class attached
 * to WordPress's the_content output, without touching cart/checkout/attribute data.
 */

/* Sources supported: post/page prose, Gutenberg, UX block content and product
   description. The PHP content filter also marks old imported HTML tables. */
body.tpa-site :is(
  .tpa-prose,
  .tpa-category-content-body,
  .entry-content,
  .wp-block-post-content,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel,
  .tpa-product-tabs-wrap .woocommerce-Tabs-panel--description
) :is(figure.wp-block-table, .wp-block-table),
body.tpa-site .tpa-article-panel .wp-block-table {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 18px 0 24px !important;
  overflow-x: auto;
  border: 1px solid #d7e7ef;
  border-radius: 12px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

body.tpa-site :is(
  table.tpev-editorial-table,
  .tpa-prose table,
  .tpa-category-content-body table,
  .entry-content table,
  .wp-block-post-content table,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
  .tpa-product-tabs-wrap .woocommerce-Tabs-panel--description table
):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes)) {
  box-sizing: border-box !important;
  display: table !important;
  float: none !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  table-layout: fixed !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  margin: 18px 0 24px !important;
  border: 1px solid #d7e7ef !important;
  border-radius: 12px !important;
  background: #fff !important;
  color: #173b56;
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
  box-shadow: 0 5px 18px rgba(8, 45, 75, .035);
}

/* Gutenberg uses <figure> as the table outline, not a second nested border. */
body.tpa-site .wp-block-table > table.tpev-editorial-table,
body.tpa-site .tpa-prose .wp-block-table > table,
body.tpa-site .tpa-product-tabs-wrap .wp-block-table > table {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
}

body.tpa-site :is(
  table.tpev-editorial-table,
  .tpa-prose table,
  .tpa-category-content-body table,
  .entry-content table,
  .wp-block-post-content table,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
  .woocommerce-Tabs-panel--description table
):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes)) :is(th,td) {
  box-sizing: border-box !important;
  padding: 12px 16px !important;
  border: 0 !important;
  border-bottom: 1px solid #e2edf3 !important;
  vertical-align: middle !important;
  text-align: left !important;
  font-size: inherit !important;
  font-weight: 400;
  line-height: 1.55 !important;
  overflow-wrap: anywhere;
  word-break: normal;
  background: transparent;
  color: inherit;
}

body.tpa-site :is(
  table.tpev-editorial-table,
  .tpa-prose table,
  .tpa-category-content-body table,
  .entry-content table,
  .wp-block-post-content table,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
  .woocommerce-Tabs-panel--description table
):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes)) tr:last-child > :is(th,td) {
  border-bottom: 0 !important;
}

/* Supports thead/th as well as legacy header rows in tbody. A tiny JS helper
   marks a two-cell row headed “Thông số / Chi tiết” even if old HTML used <td>. */
body.tpa-site :is(
  table.tpev-editorial-table,
  .tpa-prose table,
  .tpa-category-content-body table,
  .entry-content table,
  .wp-block-post-content table,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
  .woocommerce-Tabs-panel--description table
):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes))
:is(thead tr, tbody tr:first-child:has(> th), .tpev-table-header-row) > :is(th,td) {
  background: #e8f5fa !important;
  color: #0a4260 !important;
  font-weight: 700 !important;
  border-bottom: 1px solid #c9e3ed !important;
}

body.tpa-site :is(
  table.tpev-editorial-table,
  .tpa-prose table,
  .tpa-category-content-body table,
  .entry-content table,
  .wp-block-post-content table,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
  .woocommerce-Tabs-panel--description table
):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes)) tbody tr:nth-child(even):not(.tpev-table-header-row) > :is(th,td) {
  background: #f5fafc !important;
}

body.tpa-site :is(
  table.tpev-editorial-table,
  .tpa-prose table,
  .tpa-category-content-body table,
  .entry-content table,
  .wp-block-post-content table,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
  .woocommerce-Tabs-panel--description table
):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes)) tr:has(> :nth-child(2):last-child) > :first-child {
  width: 34% !important;
  color: #124a67;
  font-weight: 600;
}

body.tpa-site :is(
  table.tpev-editorial-table,
  .tpa-prose table,
  .tpa-category-content-body table,
  .entry-content table,
  .wp-block-post-content table,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
  .woocommerce-Tabs-panel--description table
) :is(th,td) p {
  margin: 0 !important;
}

@media (max-width: 767px) {
  body.tpa-site :is(
    table.tpev-editorial-table,
    .tpa-prose table,
    .tpa-category-content-body table,
    .entry-content table,
    .wp-block-post-content table,
    .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
    .woocommerce-Tabs-panel--description table
  ):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes)) {
    font-size: 14px !important;
    margin: 14px 0 20px !important;
  }
  body.tpa-site :is(
    table.tpev-editorial-table,
    .tpa-prose table,
    .tpa-category-content-body table,
    .entry-content table,
    .wp-block-post-content table,
    .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
    .woocommerce-Tabs-panel--description table
  ):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes)) :is(th,td) {
    padding: 10px 11px !important;
  }
  body.tpa-site :is(
    table.tpev-editorial-table,
    .tpa-prose table,
    .tpa-category-content-body table,
    .entry-content table,
    .wp-block-post-content table,
    .tpa-product-tabs-wrap .woocommerce-tabs .panel table,
    .woocommerce-Tabs-panel--description table
  ):not(:is(.shop_table,.shop_attributes,.variations,.woocommerce-product-attributes)) tr:has(> :nth-child(2):last-child) > :first-child {
    width: 39% !important;
  }
}

/* Photo captions only: native Gutenberg, Classic Editor, image gallery captions.
 * Don't italicise all <em> paragraphs or overlay badges owned by the theme. */
body.tpa-site :is(
  .tpa-prose,
  .tpa-category-content-body,
  .entry-content,
  .wp-block-post-content,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel,
  .tpa-product-tabs-wrap .woocommerce-Tabs-panel--description
) :is(
  figure.wp-block-image > figcaption,
  figure.wp-block-gallery figcaption,
  figure.wp-block-gallery .blocks-gallery-item__caption,
  .wp-caption > .wp-caption-text,
  .gallery-caption,
  figure:has(> img) > figcaption,
  figure:has(> a > img) > figcaption
) {
  box-sizing: border-box;
  display: block;
  max-width: 100%;
  width: 100%;
  margin: 8px auto 18px !important;
  padding: 0 8px;
  color: #667e90;
  font-family: inherit;
  font-style: italic !important;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;
  text-align: center !important;
}


/* Old WordPress [caption] shortcode wrappers may retain width="..." from the
 * classic editor. Keep the complete picture+caption inside a phone viewport. */
body.tpa-site :is(
  .tpa-prose,
  .tpa-category-content-body,
  .entry-content,
  .wp-block-post-content,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel,
  .tpa-product-tabs-wrap .woocommerce-Tabs-panel--description
) .wp-caption {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-inline: auto !important;
}
body.tpa-site :is(
  .tpa-prose,
  .tpa-category-content-body,
  .entry-content,
  .wp-block-post-content,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel,
  .tpa-product-tabs-wrap .woocommerce-Tabs-panel--description
) .wp-caption img {
  display: block;
  max-width: 100% !important;
  height: auto !important;
  margin-inline: auto;
}

/* Stronger rule for figure-wrapped Gutenberg tables. Editorial tables are
 * 100% wide, but only the outer figure gets the rounded border/shadow. */
body.tpa-site :is(
  .tpa-prose,
  .tpa-product-tabs-wrap .woocommerce-tabs .panel,
  .tpa-category-content-body,
  .entry-content,
  .wp-block-post-content
) .wp-block-table > table.tpev-editorial-table {
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
