// ============================================================================
// Chatbot Main - Message - Content - Text
// ============================================================================

.pf-chatbot__message-and-actions {
  width: 100%;

  blockquote {
    .pf-chatbot__message-text {
      display: inline-block;
    }
  }
}

// Need to inline shorter text
.pf-chatbot__message-text {
  width: fit-content;
  padding: var(--pf-t--global--spacer--sm) 0 var(--pf-t--global--spacer--sm) 0;
  border-radius: var(--pf-t--global--border--radius--small);
  --pf-chatbot-message-text-font-size: var(--pf-t--global--font--size--md);

  .pf-v6-c-button.pf-m-link {
    font-size: var(--pf-chatbot-message-text-font-size);
  }

  .pf-v6-c-content,
  .pf-v6-c-content--small,
  .pf-v6-c-content--blockquote,
  p,
  a {
    --pf-v6-c-content--FontSize: var(--pf-chatbot-message-text-font-size);
  }

  code {
    background-color: var(--pf-t--global--background--color--tertiary--default);
    font-size: var(--pf-chatbot-message-text-inline-code-font-size);
  }

  // Hide message text that contains sr-only content
  // https://css-tricks.com/inclusively-hidden/
  &:has(.sr-only) {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }

  &.pf-m-primary {
    code {
      background-color: var(--pf-t--global--background--color--secondary--default);
    }
  }

  &.pf-m-markdown {
    display: block;
  }
  &.pf-m-markdown > [class^='pf-v6-c-content'] {
    font-size: inherit;
    color: inherit;
  }
}

// ============================================================================
// Footnote spacing styles
// ============================================================================

// Add spacing to paragraphs in multi-paragraph footnotes
// Only target p tags that are direct children of message-text spans (not inside blockquotes, etc.)
li[id*='user-content-fn-']:has(> span > .pf-chatbot__message-text + .pf-chatbot__message-text)
  > span
  > .pf-chatbot__message-text
  > p {
  margin-block-end: var(--pf-t--global--spacer--md);
}

// Handle user message footnotes which may have extra span wrappers
li[id*='user-content-fn-']:has(> span > span > .pf-chatbot__message-text + .pf-chatbot__message-text)
  > span
  > span
  > .pf-chatbot__message-text
  > p {
  margin-block-end: var(--pf-t--global--spacer--md);
}

.pf-chatbot__message-text.footnotes {
  .data-footnote-backref {
    width: fit-content;
  }
}

.pf-chatbot__message--user {
  .pf-chatbot__message-text {
    background-color: var(--pf-t--global--color--brand--default);
    color: var(--pf-t--global--text--color--on-brand--default);
    --pf-v6-c-content--Color: var(--pf-t--global--text--color--on-brand--default);
    padding: var(--pf-t--global--spacer--sm);
    .pf-v6-c-button__icon {
      --pf-v6-c-button__icon--Color: var(--pf-t--global--text--color--on-brand--default);
    }

    .pf-v6-c-content,
    .pf-v6-c-content--small,
    .pf-v6-c-content--blockquote,
    p,
    a {
      color: var(--pf-t--global--text--color--on-brand--default);
    }
  }

  blockquote {
    border-inline-start-color: var(--pf-t--global--border--color--alt);
  }

  .pf-chatbot__message-text > .pf-chatbot__message-text {
    background-color: initial;
    padding: initial;
  }
}

// ============================================================================
// Information density styles
// ============================================================================
.pf-chatbot.pf-m-compact {
  // Need to inline shorter text
  .pf-chatbot__message-text {
    --pf-chatbot-message-text-font-size: var(--pf-t--global--font--size--sm);
    .pf-v6-c-button.pf-m-link {
      font-size: var(--pf-chatbot-message-text-font-size);
    }

    .pf-v6-c-content,
    .pf-v6-c-content--small,
    .pf-v6-c-content--blockquote,
    p,
    a {
      --pf-v6-c-content--FontSize: var(--pf-chatbot-message-text-font-size);
    }

    .pf-v6-c-content--blockquote {
      --pf-v6-c-content--blockquote--PaddingBlockStart: 0;
      --pf-v6-c-content--blockquote--PaddingBlockEnd: 0;
    }
  }
}
