chrysopedia/frontend/src/components/ChatWidget.module.css
jlightner 3bb0266a19 feat: Added personality weight slider (0.0–1.0) to ChatWidget header an…
- "frontend/src/api/chat.ts"
- "frontend/src/components/ChatWidget.tsx"
- "frontend/src/components/ChatWidget.module.css"

GSD-Task: S02/T02
2026-04-04 09:30:56 +00:00

450 lines
9.7 KiB
CSS

/* ChatWidget — floating chat bubble + expandable panel */
/* ── Bubble ───────────────────────────────────────────────── */
.bubble {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
width: 56px;
height: 56px;
border-radius: 50%;
background: var(--color-accent);
color: #0f0f14;
border: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
box-shadow: 0 4px 16px var(--color-shadow-heavy);
transition: transform 0.15s, background 0.15s;
z-index: 1000;
}
.bubble:hover {
background: var(--color-accent-hover);
transform: scale(1.08);
}
/* ── Panel ────────────────────────────────────────────────── */
.panel {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
width: 400px;
max-height: 60vh;
background: var(--color-bg-surface);
border: 1px solid var(--color-border);
border-radius: 16px;
display: flex;
flex-direction: column;
box-shadow: 0 8px 32px var(--color-shadow-heavy);
z-index: 1001;
animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(16px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* ── Header ───────────────────────────────────────────────── */
.header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.75rem 1rem;
border-bottom: 1px solid var(--color-border);
flex-shrink: 0;
}
/* ── Personality slider ───────────────────────────────────── */
.sliderRow {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
border-bottom: 1px solid var(--color-border);
flex-shrink: 0;
}
.sliderLabel {
font-size: 0.6875rem;
color: var(--color-text-secondary);
white-space: nowrap;
user-select: none;
}
.slider {
flex: 1;
-webkit-appearance: none;
appearance: none;
height: 4px;
border-radius: 2px;
background: var(--color-border);
outline: none;
cursor: pointer;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 14px;
height: 14px;
border-radius: 50%;
background: var(--color-accent);
border: 2px solid var(--color-bg-surface);
box-shadow: 0 1px 4px var(--color-shadow-heavy);
cursor: pointer;
transition: transform 0.1s;
}
.slider::-webkit-slider-thumb:hover {
transform: scale(1.15);
}
.slider::-moz-range-thumb {
width: 14px;
height: 14px;
border-radius: 50%;
background: var(--color-accent);
border: 2px solid var(--color-bg-surface);
box-shadow: 0 1px 4px var(--color-shadow-heavy);
cursor: pointer;
}
.slider::-moz-range-track {
height: 4px;
border-radius: 2px;
background: var(--color-border);
}
.headerTitle {
font-size: 0.875rem;
font-weight: 600;
color: var(--color-text-primary);
margin: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.headerLabel {
font-size: 0.6875rem;
color: var(--color-text-secondary);
text-transform: uppercase;
letter-spacing: 0.04em;
font-weight: 500;
}
.closeBtn {
background: none;
border: none;
color: var(--color-text-secondary);
font-size: 1.25rem;
cursor: pointer;
padding: 0.25rem;
line-height: 1;
border-radius: 4px;
transition: color 0.15s, background 0.15s;
flex-shrink: 0;
}
.closeBtn:hover {
color: var(--color-text-primary);
background: var(--color-bg-surface-hover);
}
/* ── Messages area ────────────────────────────────────────── */
.messages {
flex: 1;
overflow-y: auto;
padding: 0.75rem 1rem;
display: flex;
flex-direction: column;
gap: 0.75rem;
min-height: 0;
}
.userMsg {
align-self: flex-end;
background: var(--color-accent);
color: #0f0f14;
padding: 0.5rem 0.75rem;
border-radius: 12px 12px 4px 12px;
font-size: 0.875rem;
max-width: 85%;
word-break: break-word;
font-weight: 500;
}
.assistantMsg {
align-self: flex-start;
background: var(--color-bg-page);
border: 1px solid var(--color-border);
padding: 0.625rem 0.75rem;
border-radius: 12px 12px 12px 4px;
font-size: 0.875rem;
color: var(--color-text-primary);
max-width: 90%;
line-height: 1.6;
white-space: pre-wrap;
word-break: break-word;
}
/* ── Cursor ───────────────────────────────────────────────── */
.cursor {
display: inline-block;
width: 2px;
height: 1em;
background: var(--color-accent);
margin-left: 2px;
vertical-align: text-bottom;
animation: blink 0.8s step-end infinite;
}
@keyframes blink {
50% { opacity: 0; }
}
/* ── Typing indicator ─────────────────────────────────────── */
.typing {
display: flex;
gap: 4px;
align-items: center;
padding: 0.5rem 0.75rem;
align-self: flex-start;
}
.typingDot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--color-text-secondary);
animation: bounce 1.2s infinite;
}
.typingDot:nth-child(2) {
animation-delay: 0.15s;
}
.typingDot:nth-child(3) {
animation-delay: 0.3s;
}
@keyframes bounce {
0%, 60%, 100% { transform: translateY(0); }
30% { transform: translateY(-4px); }
}
/* ── Sources ──────────────────────────────────────────────── */
.sources {
margin-top: 0.5rem;
padding-top: 0.5rem;
border-top: 1px solid var(--color-border);
}
.sourcesLabel {
font-size: 0.6875rem;
font-weight: 600;
color: var(--color-text-secondary);
text-transform: uppercase;
letter-spacing: 0.04em;
margin: 0 0 0.375rem;
}
.sourceList {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.sourceItem {
display: flex;
gap: 0.375rem;
align-items: baseline;
font-size: 0.75rem;
}
.sourceNum {
flex-shrink: 0;
width: 1.125rem;
height: 1.125rem;
display: flex;
align-items: center;
justify-content: center;
background: var(--color-accent);
color: #0f0f14;
border-radius: 3px;
font-size: 0.625rem;
font-weight: 700;
}
.sourceLink {
color: var(--color-accent);
text-decoration: none;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.sourceLink:hover {
text-decoration: underline;
}
/* ── Citation superscripts ────────────────────────────────── */
.citationGroup {
font-size: 0.7em;
vertical-align: super;
line-height: 0;
}
.citationLink {
color: var(--color-accent);
text-decoration: none;
font-weight: 600;
cursor: pointer;
}
.citationLink:hover {
text-decoration: underline;
}
/* ── Error ────────────────────────────────────────────────── */
.errorMsg {
background: rgba(239, 68, 68, 0.1);
color: #f87171;
border: 1px solid rgba(239, 68, 68, 0.2);
border-radius: 8px;
padding: 0.5rem 0.625rem;
font-size: 0.8125rem;
align-self: flex-start;
}
/* ── Suggestions ──────────────────────────────────────────── */
.suggestions {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 0.5rem 0;
}
.suggestionsLabel {
font-size: 0.75rem;
color: var(--color-text-secondary);
margin: 0;
}
.suggestionBtn {
background: var(--color-bg-page);
border: 1px solid var(--color-border);
border-radius: 8px;
padding: 0.5rem 0.625rem;
color: var(--color-text-primary);
font-size: 0.8125rem;
cursor: pointer;
text-align: left;
transition: border-color 0.15s, background 0.15s;
}
.suggestionBtn:hover {
border-color: var(--color-accent);
background: var(--color-bg-surface-hover);
}
/* ── Input row ────────────────────────────────────────────── */
.inputRow {
display: flex;
gap: 0.375rem;
padding: 0.625rem 0.75rem;
border-top: 1px solid var(--color-border);
flex-shrink: 0;
}
.input {
flex: 1;
padding: 0.5rem 0.625rem;
background: var(--color-bg-input);
border: 1px solid var(--color-border);
border-radius: 8px;
color: var(--color-text-primary);
font-size: 0.8125rem;
transition: border-color 0.15s;
}
.input:focus {
outline: none;
border-color: var(--color-accent);
box-shadow: 0 0 0 2px var(--color-accent-focus);
}
.input::placeholder {
color: var(--color-text-secondary);
opacity: 0.7;
}
.sendBtn {
padding: 0.5rem 0.75rem;
background: var(--color-accent);
color: #0f0f14;
border: none;
border-radius: 8px;
font-size: 0.8125rem;
font-weight: 600;
cursor: pointer;
transition: background 0.15s;
white-space: nowrap;
}
.sendBtn:hover:not(:disabled) {
background: var(--color-accent-hover);
}
.sendBtn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* ── Responsive (mobile) ──────────────────────────────────── */
@media (max-width: 640px) {
.bubble {
bottom: 1rem;
right: 1rem;
width: 48px;
height: 48px;
font-size: 1.25rem;
}
.panel {
bottom: 0;
right: 0;
left: 0;
width: 100%;
max-height: 75vh;
border-radius: 16px 16px 0 0;
border-bottom: none;
}
}