/* ai-chat.css — styles for the shared "Ask Claude" widget (ai-chat.js).
   Loaded by every page that mounts the chat: transactions.html (after
   styles.css, which keeps its page-level card groupings) and net-worth.html
   (after app-shell.css, which owns every --app-* token used here, including
   the dark and wealth overrides). Tokens only — no raw color literals. */

.ai-section {
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--app-ai-tint);
    border-radius: 4px;
    border-left: 3px solid var(--app-ai);
}

/* With the shared card shell (both pages use class="ai-section app-card"),
   the accent rides on top of app-shell.css's card base. transactions.html's
   styles.css also groups this selector with its other page cards for
   padding — same specificity, this file loads later, accent wins. */
.ai-section.app-card {
    border-left: 3px solid var(--app-ai);
    background: var(--app-ai-tint);
}

.ai-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ai-section-title {
    color: var(--app-muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ai-new-chat-btn {
    background: none;
    border: 1px solid var(--app-ai-border);
    color: var(--app-ai-text);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    margin-top: 0;
    cursor: pointer;
}

.ai-new-chat-btn:hover {
    background-color: var(--app-ai-soft);
}

.ai-quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.ai-quick-prompts-secondary {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--app-ai-soft);
}

.ai-prompt-btn {
    background-color: var(--app-ai-soft);
    color: var(--app-ai-text);
    border: 1px solid var(--app-ai-border);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    margin-top: 0;
    border-radius: 20px;
    cursor: pointer;
}

.ai-prompt-btn:hover {
    background-color: var(--app-ai-soft-strong);
}

.ai-prompt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-conversation {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.ai-message {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    max-width: 90%;
    word-wrap: break-word;
}

.ai-message.user {
    background-color: var(--app-ai);
    color: var(--app-on-accent);
    align-self: flex-end;
}

.ai-message.assistant {
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    color: var(--app-text);
    align-self: flex-start;
}

.ai-message.assistant ul {
    padding-left: 18px;
    margin: 4px 0;
}

.ai-message.loading {
    background-color: var(--app-surface-raised);
    color: var(--app-dim);
    align-self: flex-start;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-message.assistant.ai-message--question {
    border-left: 3px solid var(--app-warning);
    background-color: var(--app-warning-soft);
}

/* Transparency line: what the next question will send to Claude. */
.ai-context-summary {
    font-size: 12px;
    color: var(--app-dim);
    margin-bottom: 6px;
}

/* Animated waiting indicator — three pulsing dots in currentColor. */
.ai-thinking {
    display: inline-flex;
    gap: 4px;
}

.ai-thinking-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    animation: ai-thinking-pulse 1.2s ease-in-out infinite;
}

.ai-thinking-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-thinking-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ai-thinking-pulse {
    0%, 80%, 100% {
        opacity: 0.25;
        transform: scale(0.85);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

.ai-input-row {
    display: flex;
    gap: 8px;
}

/* Explicit surface/text so the widget is self-sufficient on pages that
   don't load transactions.html's global form styles (net-worth.html). */
.ai-input-row textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--app-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    min-height: 40px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
    line-height: 1.4;
    background-color: var(--app-surface);
    color: var(--app-text);
}

.ai-input-row textarea:disabled {
    background-color: var(--app-surface-raised);
}

.ai-input-row button {
    margin-top: 0;
    padding: 8px 16px;
    background-color: var(--app-ai);
    color: var(--app-on-accent);
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
}

.ai-input-row button:hover {
    background-color: var(--app-ai-strong);
}

.ai-input-row button:disabled {
    background-color: var(--app-dim);
    cursor: not-allowed;
}

.ai-context-details {
    margin-bottom: 12px;
}

.ai-context-details summary {
    font-size: 12px;
    color: var(--app-ai-text);
    cursor: pointer;
    user-select: none;
    margin-bottom: 6px;
}

.ai-context-details textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--app-ai-border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--app-text);
    background-color: var(--app-ai-tint);
    resize: vertical;
    min-height: 56px;
    line-height: 1.4;
}

.ai-error {
    margin-top: 8px;
    font-size: 13px;
    color: var(--app-negative);
}

@media (max-width: 640px) {
    .ai-section.app-card {
        padding: 18px 16px;
        border-radius: 15px;
    }
}
