/*
 * Response typography and tables. Web Chat 4.19 uses class names such as
 * wOVnR0W_text-content__markdown, not the old .webchat__text-content.
 * Match the semantic suffix, never its generated hash. Keep this scoped to
 * the Benefits transcript: citation dialogs, cards and the send box are
 * excluded. Keep body text styling and the approved section spacing intact.
 */
/* Both streaming and fallback renderers insert an inner render-markdown div.
 * Blocks are descendants, not direct children of text-content__markdown. */
.benefits-webchat [class*="text-content__markdown"] :is(p, ul, ol, blockquote) {
  margin-block: 0.75rem;
}

.benefits-webchat [class*="text-content__markdown"] li + li {
  margin-block-start: 0.5rem;
}

.benefits-webchat [class*="text-content__markdown"] li > p + p {
  margin-block-start: 0.5rem;
}

/* Tailwind's reset removes native list markers. Restore semantic Markdown
 * lists, including the numbered SendActivity intake menu. */
.benefits-webchat [class*="text-content__markdown"] :is(ol, ul) {
  padding-inline-start: 1.65em;
  list-style-position: outside;
}

.benefits-webchat [class*="text-content__markdown"] ol {
  list-style-type: decimal;
}

.benefits-webchat [class*="text-content__markdown"] ul {
  list-style-type: disc;
}

.benefits-webchat [class*="text-content__markdown"] ol > li::marker {
  color: hsl(var(--primary));
  font-weight: 700;
}

.benefits-webchat [class*="text-content__markdown"] :is(h1, h2, h3, h4, h5, h6) {
  margin-block: 1.25rem 0.5rem;
  font-weight: 700;
  line-height: 1.35;
  color: hsl(var(--primary));
}

/* Restore Markdown heading hierarchy removed by the global CSS reset. */
.benefits-webchat [class*="text-content__markdown"] h1 {
  font-size: 1.35em;
}

.benefits-webchat [class*="text-content__markdown"] h2 {
  font-size: 1.2em;
}

.benefits-webchat [class*="text-content__markdown"] h3 {
  font-size: 1.1em;
}

/* Keep the existing faint rule; add the missing room on either side. */
.benefits-webchat [class*="text-content__markdown"] hr {
  margin-block: 1.25rem;
}

/* Indent the complete table, not individual rows. Fixed layout and wrapping
 * keep long labels within the available bubble width, including on phones. */
.benefits-webchat [class*="text-content__markdown"] table {
  --response-table-indent: 24px;
  width: calc(100% - var(--response-table-indent));
  max-width: calc(100% - var(--response-table-indent));
  margin-block: 16px;
  margin-inline: var(--response-table-indent) 0;
  table-layout: fixed;
  border-collapse: collapse;
  border: 0;
}

.benefits-webchat [class*="text-content__markdown"] :is(th, td) {
  padding: 10px 12px;
  border: 0;
  border-block-end: 1px solid hsl(var(--primary) / 0.16);
  vertical-align: top;
  text-align: start;
  overflow-wrap: anywhere;
}

.benefits-webchat [class*="text-content__markdown"] th {
  color: hsl(var(--primary));
  background-color: hsl(var(--primary) / 0.08);
  font-weight: 700;
}

.benefits-webchat [class*="text-content__markdown"] tbody tr:last-child td {
  border-block-end: 0;
}

@media (max-width: 600px) {
  .benefits-webchat [class*="text-content__markdown"] table {
    --response-table-indent: 12px;
  }

  .benefits-webchat [class*="text-content__markdown"] :is(th, td) {
    padding: 8px 10px;
  }
}

/* No extra empty space at the top/bottom of a one-paragraph message. */
.benefits-webchat [class*="text-content__markdown"] > :first-child,
.benefits-webchat [class*="text-content__markdown"] > div[class*="render-markdown"] > :first-child {
  margin-block-start: 0;
}

.benefits-webchat [class*="text-content__markdown"] > :last-child,
.benefits-webchat [class*="text-content__markdown"] > div[class*="render-markdown"] > :last-child {
  margin-block-end: 0;
}

/* Space the latest non-user activity outside its bubble/card, not inside it.
 * Match SDK semantic class suffixes (StackedLayout is CSS-moduled in 4.19).
 * Earlier bot activities and all user activities keep their existing layout. */
.benefits-webchat article.webchat__basic-transcript__activity:has([class*="stacked-layout--activity"]:not([class*="stacked-layout--from-user"])):not(:has(~ article.webchat__basic-transcript__activity [class*="stacked-layout--activity"]:not([class*="stacked-layout--from-user"]))) {
  padding-block: 12px;
}

.benefits-webchat article.webchat__basic-transcript__activity:has([class*="stacked-layout--activity"]:not([class*="stacked-layout--from-user"])):not(:has(~ article.webchat__basic-transcript__activity [class*="stacked-layout--activity"]:not([class*="stacked-layout--from-user"]))) .webchat__basic-transcript__activity-body:not(:empty) {
  padding-block-end: 0;
}
