/* MCP Chat Demo — shared component used on index.html and mcp-servers.html.
   Relies on the host page's CSS variables: --bg, --surface, --line, --line-strong,
   --text, --muted, --faint, --accent, --accent-2, --accent-3, --mono, --sans. */

.chat-shell { margin-top: 56px; border: 1px solid var(--line-strong); border-radius: 24px; background: oklch(from var(--bg) calc(l - 0.02) c h / 0.85); backdrop-filter: blur(12px); overflow: hidden; display: grid; grid-template-columns: 1fr; }
.chat-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; color: var(--faint); }
.chat-top .lhs { display: flex; flex-direction: column; gap: 4px; }
.chat-top .lhs > div:first-child { display: flex; align-items: center; gap: 10px; }
.chat-top .av { width: 22px; height: 22px; border-radius: 6px; overflow: hidden; }
.chat-top .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-scope { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; }
.chat-scope .scope-id, .chat-scope .scope-tags { color: var(--accent); }
.chat-scope .scope-dot { color: var(--faint); }
.chat-body { padding: 24px 22px; min-height: 320px; display: flex; flex-direction: column; gap: 16px; }
@keyframes mcp-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-body .mcp-in { animation: mcp-enter 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.msg { max-width: 80%; }
.msg.user { align-self: flex-end; background: oklch(from var(--accent) l c h / 0.12); border: 1px solid oklch(from var(--accent) l c h / 0.25); color: var(--text); padding: 12px 16px; border-radius: 16px 16px 4px 16px; font-size: 14.5px; }
.msg.bot { align-self: flex-start; width: 100%; max-width: 100%; }
.tool-call { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.tool-call .tc-head { padding: 10px 14px; background: oklch(from var(--bg) calc(l + 0.04) c h); color: var(--accent-2); display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); transition: border-bottom-color 0.3s ease; }
.tool-call.collapsed .tc-head { border-bottom-color: transparent; }
.tool-call .tc-head .spin { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: mcp-spin 0.7s linear infinite; }
@keyframes mcp-spin { to { transform: rotate(360deg); } }
.tool-call .tc-head.ok .spin { border: none; background: var(--accent-2); color: var(--bg); display: flex; align-items: center; justify-content: center; animation: none; font-size: 9px; font-weight: 700; }
.tool-call .tc-body { padding: 12px 14px; color: var(--muted); white-space: pre-wrap; line-height: 1.6; overflow: hidden; max-height: 120px; transition: max-height 0.45s ease, opacity 0.3s ease, padding 0.45s ease; }
.tool-call.collapsed .tc-body { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; }
.tool-call .tc-body .key { color: var(--faint); }
.tool-call .tc-body .val { color: var(--accent); }
.bot-answer { background: var(--surface); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 16px 18px; font-size: 14.5px; line-height: 1.6; }
.bot-answer b { color: var(--accent); font-weight: 600; }
.bot-answer .row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.bot-answer .row:last-child { border-bottom: none; }
.bot-answer .row span:last-child { font-family: var(--mono); color: var(--text); }
.cursor { display: inline-block; width: 8px; height: 15px; background: var(--accent); vertical-align: -2px; animation: cursor-blink 0.8s infinite; }
@keyframes cursor-blink { 50% { opacity: 0; } }
.chat-foot { border-top: 1px solid var(--line); padding: 16px 22px; }
.chat-foot .lbl { font-family: var(--mono); font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; }
.suggest { display: flex; flex-wrap: wrap; gap: 10px; }
.suggest button { font-family: var(--sans); font-size: 13.5px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 9px 16px; cursor: pointer; transition: all 0.2s; }
.suggest button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.suggest button:disabled { opacity: 0.4; cursor: default; }
.chat-foot .composer { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; padding: 7px 7px 7px 16px; }
.chat-foot .composer-input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; color: var(--text); font-family: var(--sans); font-size: 14.5px; cursor: default; }
.chat-foot .composer-input::placeholder { color: var(--faint); }
.chat-foot .composer-send { flex: none; width: 36px; height: 36px; border-radius: 10px; border: none; background: oklch(from var(--accent) l c h / 0.16); color: var(--accent); display: flex; align-items: center; justify-content: center; cursor: default; transition: background 0.15s, color 0.15s, transform 0.1s; }
.chat-foot .composer-send.active { background: var(--accent); color: var(--bg); transform: scale(0.92); }
.chat-foot .composer-send:disabled { opacity: 0.5; }
.thinking { font-family: var(--mono); font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.thinking .think-dots { display: inline-flex; gap: 5px; }
.thinking .think-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: think-bounce 1.2s infinite ease-in-out; }
.thinking .think-dots i:nth-child(2) { animation-delay: 0.18s; }
.thinking .think-dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes think-bounce { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.tool-call .tc-head .tc-meta { color: var(--faint); }
@media (prefers-reduced-motion: reduce) {
  .chat-body .mcp-in { animation: none; }
  .tool-call .tc-body { transition: none; }
  .tool-call .tc-head { transition: none; }
}

/* --- Suggestion groups (Markets / Ask Daniel) shown together, separated --- */
.suggest-group + .suggest-group { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.suggest-label { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 9px; }

/* --- Loading row (during fetch) --- */
.bot-loading { font-family: var(--mono); font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.bot-loading .ld-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: mcp-spin 0.7s linear infinite; }

/* --- Error / fallback bubble --- */
.bot-answer.is-error { border-color: oklch(from var(--accent) l c h / 0.4); color: var(--muted); }
.bot-answer.is-error .err-title { color: var(--accent); font-weight: 600; display: block; margin-bottom: 4px; }

/* --- Inline SVG line chart --- */
.mcp-chart { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 14px 12px 10px; background: oklch(from var(--bg) calc(l + 0.02) c h); }
.mcp-chart .chart-head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-bottom: 8px; }
.mcp-chart .chart-head .chart-now { color: var(--text); font-size: 13px; }
.mcp-chart svg { display: block; width: 100%; height: auto; }
.mcp-chart .ch-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mcp-chart .ch-area { fill: oklch(from var(--accent) l c h / 0.10); stroke: none; }
.mcp-chart .ch-dot { fill: var(--accent); }
.mcp-chart .chart-foot { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 6px; }

/* --- Top-crypto / data table --- */
.mcp-table { margin-top: 12px; width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mcp-table th { text-align: left; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); padding: 0 8px 7px 0; font-weight: 500; }
.mcp-table td { padding: 7px 8px 7px 0; border-top: 1px dashed var(--line); }
.mcp-table td:last-child, .mcp-table th:last-child { text-align: right; padding-right: 0; font-family: var(--mono); }
.mcp-table .t-rank { color: var(--faint); width: 1.4em; }
.mcp-table .t-sym { color: var(--muted); font-family: var(--mono); font-size: 11.5px; margin-left: 6px; }
.mcp-table .up { color: var(--accent-2); }
.mcp-table .down { color: oklch(from var(--accent) calc(l + 0.05) calc(c + 0.05) calc(h + 25)); }

/* --- Big single value (FX) --- */
.mcp-value { margin-top: 14px; display: flex; align-items: baseline; gap: 10px; }
.mcp-value .v-num { font-family: var(--mono); font-size: 26px; color: var(--accent); font-weight: 600; }
.mcp-value .v-sub { font-family: var(--mono); font-size: 12px; color: var(--faint); }

/* --- Ask-Daniel project list --- */
.mcp-projects { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.mcp-projects .pj { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.mcp-projects .pj-name { color: var(--accent); font-weight: 600; font-size: 14px; }
.mcp-projects .pj-tech { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 4px; }
.mcp-projects .pj-sum { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  .bot-loading .ld-spin { animation: none; }
}
