Improve CSS namespacing and custom element display handling in ai_chatbot
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3576664. -->
Reported by: [cadence96](https://www.drupal.org/user/3520894)
Related to !1284
>>>
<p>[Tracker]<br>
<strong>Update Summary:</strong> Improve frontend robustness and prevent CSS conflicts in ai_chatbot<br><br>
<strong>Short Description:</strong> Generic CSS class and custom element display handling may cause theme conflicts<br><br>
<strong>Check-in Date:</strong> 03/02/2026<br><br>
<em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>The <code>ai_chatbot</code> module has two frontend robustness issues that may cause conflicts in real-world Drupal installations:</p>
<p><strong>1. Generic CSS class (<code>.rotate</code>)</strong><br><br>
The module uses a generic <code>.rotate</code> class for the chatbot toggle icon. This class name is very common in themes and CSS frameworks, increasing the risk of unintended overrides or animation conflicts.</p>
<p><strong>2. Custom element display behavior (<code><deep-chat></code>)</strong><br><br>
The chatbot renders a <code><deep-chat></code> custom element. Since this is not a native HTML element, it behaves as an inline element and does not occupy the full available width as expected.</p>
<p>Custom elements may behave as inline elements unless explicitly styled.</p>
<p>To ensure predictable behavior, layout intent should be explicitly defined.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>1. Rename the generic class:</p>
<p><code>.rotate</code> → <code>.chevron-icon--rotate</code></p>
<p>This avoids namespace collisions and follows component-scoped naming practices.</p>
<p>2. Explicitly define display behavior for the custom element:</p>
<pre><pre>.deepchat-element {<br> display: block;<br>}</pre></pre><p>This guarantees stable layout regardless of theme-level CSS.</p>
<p>No functional logic changes required.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<ul>
<li>Update CSS class naming</li>
<li>Update JS toggle logic if needed</li>
<li>Add explicit display rule for <code>deep-chat</code></li>
<li>Test with Olivero and custom themes</li>
</ul>
<h3>Optional: Other details</h3>
<p>A video is attached demonstrating the layout issue. It shows how the <code>&lt;deep-chat&gt;</code> element behaves as an inline element and does not occupy the full available width, resulting in incorrect layout rendering.</p>
<p>No API changes.<br><br>
No data model changes.<br><br>
This is a frontend hardening improvement.</p>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<ul>
<li>[x] AI Assisted Issue — This issue was generated with AI assistance and reviewed/refined by the creator.</li>
<li>[ ] AI Assisted Code</li>
<li>[ ] AI Generated Code</li>
<li>[ ] Vibe Coded</li>
</ul>
issue