/* chatbot.css — 3I free-form AI tutor-advisory chatbot panel
   Uses design token variables from variables.css */

.chatbot-panel {
    padding: var(--space-4) 0;
    border-top: 1px solid var(--border-default);
    margin-top: var(--space-4);
}

/* Contained shell (same treatment as .lp-plan-card) so the assistant reads
   as its own surface rather than loose text on the page background. */
.chatbot-card {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
}

.chatbot-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.chatbot-badge {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--color-primary-light);
    color: var(--color-primary-700);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-badge svg {
    width: 16px;
    height: 16px;
}

.chatbot-header-text {
    flex: 1;
    min-width: 0;
}

.chatbot-heading {
    font-size: var(--text-md);
    font-weight: var(--weight-bold);
    color: var(--fg-primary);
    margin: 0;
}

.chatbot-subtitle {
    font-size: var(--text-sm);
    color: var(--fg-muted);
    line-height: 1.5;
    margin: var(--space-1) 0 0;
}

/* ── Stale-context banner (tutor-triggered refresh only, never automatic) ── */
.chatbot-stale-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    background: var(--color-warning-light);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-3);
}
/* This class's own display:flex has equal specificity to the browser's
   [hidden] { display: none } rule and loads after it, so it wins --
   without this override, staleBanner.hidden = true silently fails to hide
   the element (same gotcha documented for .lp-history-list). */
.chatbot-stale-banner[hidden] {
    display: none;
}

.chatbot-stale-text {
    font-size: var(--text-sm);
    color: var(--fg-primary);
}

.chatbot-refresh-btn {
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-3);
    white-space: nowrap;
}

/* ── Message log ─────────────────────────────────────────────────────────── */
/* Recessed relative to the card (bg-surface-alt + shadow-inner, same combo
   .input uses) so the conversation tray reads as distinct from the controls
   below it, rather than bubbles floating directly on the card background. */
.chatbot-log {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-height: 420px;
    min-height: 120px;
    overflow-y: auto;
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    background: var(--bg-surface-alt);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-inner);
}

.chatbot-empty {
    margin: auto;
    max-width: 32ch;
    font-size: var(--text-sm);
    color: var(--fg-muted);
    line-height: 1.6;
    text-align: center;
}

.chatbot-bubble {
    max-width: 80%;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.chatbot-bubble-text {
    margin: 0;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    white-space: pre-wrap;
}

.chatbot-bubble--user {
    align-self: flex-end;
    background: var(--color-primary-700);
    border-bottom-right-radius: var(--radius-sm);
}
.chatbot-bubble--user .chatbot-bubble-text {
    color: #fff;
}

.chatbot-bubble--assistant {
    align-self: flex-start;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-bottom-left-radius: var(--radius-sm);
}
.chatbot-bubble--assistant .chatbot-bubble-text {
    color: var(--fg-primary);
}

/* ── "Thinking…" indicator — animated dots instead of static italic text ── */
.chatbot-bubble--thinking .chatbot-bubble-text {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.chatbot-thinking-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--fg-muted);
    animation: chatbot-thinking-bounce 1.2s infinite ease-in-out both;
}
.chatbot-thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.chatbot-thinking-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-thinking-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .chatbot-thinking-dot {
        animation: none;
        opacity: 0.7;
    }
}

/* ── Privacy hint — persistent, never dismissible, sits right above the
   input where the tutor is about to type ─────────────────────────────── */
.chatbot-privacy-hint {
    font-size: var(--text-xs);
    font-style: italic;
    color: var(--fg-muted);
    line-height: 1.4;
    margin: 0 0 var(--space-2);
}

/* ── Input row ───────────────────────────────────────────────────────────── */
.chatbot-input-row {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
}

.chatbot-input {
    flex: 1;
    resize: vertical;
    min-height: 44px;
}

.chatbot-send-btn {
    white-space: nowrap;
}

.chatbot-error {
    font-size: var(--text-sm);
    color: var(--color-danger);
    margin: 0 0 var(--space-2);
}
