Repository navigation
Expand file tree
/
Copy pathchatai.css
More file actions
465 lines (397 loc) · 11.1 KB
/
Copy pathchatai.css
File metadata and controls
465 lines (397 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
/* Styles for the ChatAI widget */
:root {
--chat-bg: #fafafa;
--chat-pale: #fafafa;
--chat-fg: #333;
--chat-accent: rgba(8, 91, 236, 0.1);
--chat-user: rgba(8, 91, 236, 1);
--chat-accent-contrast: #ffffff;
--chat-warning-bg: #dd1515;
--chat-warning-fg: #fafafa;
--chat-cutoff-bg: #f5f0d8;
--chat-cutoff-fg: #4a3b1a;
--chat-cutoff-border: #d1b55c;
--chat-border: #ccc;
--chat-radius: 8px;
--chat-message-padding: 1rem;
--chat-font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--chat-margin-x: 1.5rem;
}
/* Remove all animations and transitions for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
#chatbot-dialog {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
.chatbot-status-visible {
animation: none !important;
}
}
@media (prefers-color-scheme: dark) {
:root {
--chat-bg: #1e1e1e;
--chat-fg: #f5f5f5;
--chat-accent: rgba(8, 91, 236, 0.1);
--chat-border: #444;
/* Dark variants */
--chat-warning-bg: #b91c1c;
--chat-warning-fg: #fef2f2;
}
}
.chatbot-toggle {
display: block;
position: fixed;
inset: auto 1.5rem 1.5rem auto;
background: var(--chat-accent);
backdrop-filter: blur(3px);
color: white;
border: none;
border-radius: 50%;
padding: 0.75rem;
cursor: pointer;
z-index: 1000;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
& svg {
width: 2rem;
aspect-ratio: 1;
}
}
/* Before-open state */
.chatbot-dialog {
width: min(80%, 50ch);
border: none;
border-radius: var(--chat-radius);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
/*
position: fixed;
*/
inset: auto var(--chat-margin-x) 5rem auto;
font-family: var(--chat-font);
background: var(--chat-bg);
color: var(--chat-fg);
z-index: 1001;
transform-origin: bottom right;
transform: translateX(calc(100% + var(--chat-margin-x)));
transition: opacity 0.5s ease-out,
transform 0.5s ease-out,
overlay 0.5s ease-out allow-discrete,
display 0.5s ease-out allow-discrete;
}
#chatbot-dialog[open] {
display: grid;
grid-template-rows: max-content 1fr max-content max-content;
opacity: 1;
height: auto;
min-height: 0;
max-height: 80vh;
width: min(70%, 50ch);
border: none;
border-radius: var(--chat-radius);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
inset: auto 1.5rem 5rem auto;
padding: var(--chat-message-padding);
font-family: var(--chat-font);
background: var(--chat-bg);
color: var(--chat-fg);
z-index: 1001;
transform-origin: bottom right;
transform: translateX(calc(var(--chat-margin-x)*-1));
transition: opacity 0.5s ease-out,
transform 0.5s ease-out,
overlay 0.5s ease-out allow-discrete,
display 0.5s ease-out allow-discrete;
}
/* Needs to be after the previous dialog[open] rule to take effect,
as the specificity is the same */
@starting-style {
#chatbot-dialog[open] {
opacity: 0;
transform: translateX(100%);
}
}
.chatbot-header {
display: flex;
justify-content: space-between;
align-items: center;
background: var(--chat-bg);
border-bottom: 1px solid var(--chat-border);
}
.chatbot-header-icon {
& svg {
fill: var(--chat-fg);
display: block;
width: 2rem;
aspect-ratio: 1;
}
}
.chatbot-close {
background: none;
border: none;
font-size: 1.25rem;
cursor: pointer;
color: var(--chat-fg);
& svg {
display: block;
width: 2rem;
aspect-ratio: 1;
fill: currentColor;
}
}
.chatbot-msg-wrapper {
overflow-y: scroll;
overscroll-behavior: contain;
min-height: 0;
font-size: clamp(0.9rem, 0.9rem + 0.1vw, 1rem);
}
.chatbot-messages {
background: var(--chat-bg);
display: flex;
flex-direction: column;
gap: 0.5rem;
text-wrap: pretty;
}
.chatbot-welcome {
margin: var(--chat-message-padding);
}
.chatbot-name {
font-size: 0.8rem;
}
.chatbot-msg {
max-width: 80%;
padding: 0.6rem 0.9rem;
border-radius: var(--chat-radius);
line-height: 1.4;
}
.chatbot-msg.user {
align-self: flex-end;
background: var(--chat-user);
color: var(--chat-accent-contrast);
}
.chatbot-msg.bot {
align-self: flex-start;
background: #e9e9e9;
color: #111;
&.chatbot-warning {
background: var(--chat-warning-bg);
font-weight: bold;
color: var(--chat-warning-fg);
}
&.chatbot-cutoff {
background-color: var(--chat-cutoff-bg, #f5f0d8);
color: var(--chat-cutoff-fg, #4a3b1a);
border-left: 3px solid var(--chat-cutoff-border, #d1b55c);
font-size: 0.9rem;
}
}
.chatbot-form {
display: grid;
grid-template-columns: 1fr auto;
column-gap: var(--chat-message-padding);
margin-block: var(--chat-message-padding);
align-items: end;
}
#chatbot-dialog input.chatbot-input,
.chatbot-submit {
font: inherit;
color: inherit;
}
/* overrides PW default theme input[type="text"] styles */
#chatbot-input.chatbot-input {
appearance: none;
-webkit-appearance: none;
box-sizing: border-box;
display: block;
width: 100%;
max-width: none;
height: auto;
margin: 0;
border: 0;
border-bottom: 1px solid var(--chat-border);
border-radius: 0;
background: transparent;
padding: 0.55rem 0.2rem;
line-height: 1.2;
font-family: var(--chat-font);
box-shadow: none;
}
/* overrides PW default theme input[type="text"] styles */
#chatbot-dialog input.chatbot-input::placeholder {
color: color-mix(in srgb, var(--chat-fg) 55%, transparent);
opacity: 1; /* FF placeholder opacity quirk */
}
.chatbot-submit {
appearance: none;
-webkit-appearance: none;
border: 1px solid transparent;
background: var(--chat-user);
color: var(--chat-accent-contrast);
padding: 0.55rem 0.9rem;
border-radius: calc(var(--chat-radius) - 2px);
cursor: pointer;
line-height: 1.2;
}
.chatbot-submit:hover {
filter: brightness(0.8);
}
.chatbot-submit:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.chatbot-meta-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 0.25rem;
font-size: 0.85rem;
}
.chatbot-clear .chatai-reset {
padding: 0;
border: none;
background: none;
color: var(--chat-fg);
text-decoration: underline;
text-underline-offset: 0.12em;
cursor: pointer;
font: inherit;
}
/* Reuse your existing focus style */
.chatbot-clear .chatai-reset:focus-visible {
outline: 2px solid var(--chat-user);
outline-offset: 2px;
}
.chatbot-status {
font-size: 0.85rem;
margin-top: 0.5rem;
opacity: 0;
transition: opacity 0.15s ease;
}
.chatbot-status[aria-busy="true"] {
opacity: 1;
}
/* honor [hidden] if you ever toggle it directly */
.chatbot-status[hidden] {
display: none;
}
.chatbot-status-visible {
display: inline-block;
animation: chatbotThinkingPulse 1.3s ease-in-out infinite;
}
@keyframes chatbotThinkingPulse {
0% {
opacity: 0.3;
transform: translateX(0);
}
50% {
opacity: 1;
transform: translateX(2px);
}
100% {
opacity: 0.3;
transform: translateX(0);
}
}
/* visually hidden for screen readers */
.chatbot-status-sr {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
position: absolute;
}
.chatbot-footer {
font-size: 0.8rem;
}
/* Focus rings for keyboard users */
.chatbot-toggle:focus-visible,
.chatbot-close:focus-visible,
.chatbot-form button:focus-visible,
.chatbot-input:focus-visible {
outline: 2px solid var(--chat-user);
outline-offset: 3px;
}
/* Link styling inside messages */
.chatbot-msg a {
color: inherit;
text-decoration: underline;
text-underline-offset: 0.12em;
}
.chatbot-msg a:hover {
text-decoration-thickness: 0.11em;
}
.chatbot-msg a:focus-visible {
outline: 2px solid var(--chat-user);
outline-offset: 2px;
}
/* RTL support for message alignment */
[dir="rtl"] .chatbot-msg.user {
align-self: flex-start;
}
[dir="rtl"] .chatbot-msg.bot {
align-self: flex-end;
}
/* Inline code styling */
.chatbot-msg code {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 0.9em;
padding: 0.1em 0.3em;
border-radius: 4px;
background: rgba(0, 0, 0, 0.05);
}
@media (prefers-color-scheme: dark) {
.chatbot-msg code {
background: rgba(255, 255, 255, 0.1);
}
}
/* Mobile tuning */
@media (max-width: 480px) {
.chatbot-toggle {
inset: auto 1rem 1rem auto;
padding: 0.9rem;
}
#chatbot-dialog,
.chatbot-dialog {
width: 95vw;
inset: auto 0.75rem 4.5rem auto;
}
}
/* Hide widget in print views */
@media print {
.chatbot-toggle,
#chatbot-dialog,
.chatbot-dialog {
display: none !important;
}
}
/* TinyMCE and CKEditor classes */
.align_left {text-align: left}
.align_center {text-align: center}
.align_right {text-align: right}
/*
* TODO ChatAI widget CSS
*
* Implemented (leave here as reference):
* - Focus states: visible :focus-visible rings for toggle, inputs, buttons, and links.
* - Reduced motion: dialog transitions shortened and typing animation disabled on prefers-reduced-motion.
* - High-contrast tokens: added --chat-accent-contrast, --chat-warning-bg, --chat-warning-fg.
* - RTL support: basic alignment flip for .chatbot-msg.user/.bot under [dir="rtl"].
* - Typography scale: clamp() font size on .chatbot-messages and text-wrap: pretty.
* - Link styling: explicit :hover and :focus-visible states for links inside messages.
* - Code styling: inline <code> inside messages.
* - Scroll behavior: overscroll-behavior: contain and a single scrollable wrapper for messages.
* - Warning colour: warning bubble now uses dedicated bg/fg tokens.
* - Mobile spacing: minor inset/padding tweaks at <= 480px; tap targets kept comfortable.
* - Print styles: hide toggle and dialog in print views.
*
* Backlog / nice-to-haves:
* 1) Container queries: size dialog via @container where supported instead of viewport width only.
* 2) Remaining-messages badge: small unobtrusive counter in header; aria-live="polite"; only visible when close to the limit.
* 3) Reply colour tokens: separate message bubble colours from button colours; introduce --chat-reply-bg/fg or similar.
* 4) Close button placement: final decision and tests for sticky top-right behaviour, hit area >= 44px, and interaction with launcher.
* 5) Footer styling: refine layout and spacing for disclaimer + “talk to a human” / “book” links; consider mobile-specific tweaks and per-site variants.
* 6) File upload affordance (future feature): visual design and focus/hover states for an attach button once backend support is in place.
*/