/*
 * Shared chat bubble styles — used by quiz, join, onboarding, and any
 * other page that has a conversational AI chat.
 *
 * All classes prefixed with cr- (chat-renderer) to avoid collisions.
 *
 * Theme: set .cr-theme-dark on an ancestor to switch to dark mode.
 */

/* ── Messages ────────────────────────────────────────────── */
.cr-message {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    animation: crFadeIn 0.25s ease;
}
.cr-message.cr-assistant { justify-content: flex-start; }
.cr-message.cr-user      { justify-content: flex-end; }

@keyframes crFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Bubbles ─────────────────────────────────────────────── */
.cr-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.6;
    word-break: break-word;
}

/* Light theme (default) */
.cr-assistant .cr-bubble {
    background: #f1f5f9;
    color: #1a1a1a;
    padding: 12px 16px;
    max-width: 85%;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.cr-user .cr-bubble {
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}

/* Dark theme */
.cr-theme-dark .cr-assistant .cr-bubble {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    color: #e0e0e0;
    padding: 12px 16px;
    max-width: 85%;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.cr-theme-dark .cr-user .cr-bubble {
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Structured content (headings, paragraphs, lists) ──── */
.cr-section {
    margin-top: 12px;
    margin-bottom: 2px;
}
.cr-subtitle {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.5;
}
.cr-body {
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0 0 10px 0;
}
.cr-body strong, .cr-subtitle strong { font-weight: 600; }
.cr-body em { font-style: italic; }
.cr-body a, .cr-subtitle a {
    color: #6366f1;
    text-decoration: none;
}
.cr-body a:hover, .cr-subtitle a:hover {
    text-decoration: underline;
}

/* Dark theme text colors */
.cr-theme-dark .cr-subtitle { color: #f1f5f9; }
.cr-theme-dark .cr-body { color: #cbd5e1; }
.cr-theme-dark .cr-body strong { color: #f1f5f9; }
.cr-theme-dark .cr-body em { color: #94a3b8; }
.cr-theme-dark .cr-body a { color: #818cf8; }
.cr-theme-dark .cr-bullets li { color: #cbd5e1; }
.cr-theme-dark .cr-bullets li strong { color: #f1f5f9; }
.cr-theme-dark .cr-bullets li::before { background: #64748b; }

/* ── Bullet lists ────────────────────────────────────────── */
.cr-bullets {
    margin: 4px 0 10px 0;
    padding-left: 6px;
    list-style: none;
}
.cr-bullets li {
    font-size: 0.9rem;
    line-height: 1.7;
    color: #374151;
    padding: 2px 0 2px 16px;
    position: relative;
}
.cr-bullets li::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 11px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #9ca3af;
}
ol.cr-bullets {
    list-style: decimal;
    padding-left: 22px;
}
ol.cr-bullets li::before { display: none; }
ol.cr-bullets li { padding-left: 4px; }
.cr-bullets li strong { font-weight: 600; color: #1a1a1a; }

/* ── Typing indicator ────────────────────────────────────── */
.cr-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 4px 0;
}
.cr-theme-dark .cr-typing {
    padding: 0;
}
.cr-typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: crBlink 1.2s infinite;
}
.cr-typing span:nth-child(2) { animation-delay: 0.2s; }
.cr-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes crBlink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.9); }
    40%           { opacity: 1;   transform: scale(1);   }
}
