/* AI chat, dashboard and inbox. Uses only the tokens from style.css. */

/* --- AI chat ----------------------------------------------------------------------- */
.ai-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 16px; min-height: min(66vh, 640px); }
.ai-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ai-chats { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; overflow-y: auto; overflow-x: hidden; max-height: min(58vh, 560px); }
.ai-chats li { display: flex; align-items: center; border-radius: 8px; }
.ai-chats li:hover { background: var(--surface-hover); }
.ai-chats li.active { background: var(--accent-soft); }
.chat-link { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: var(--text); font: 500 13.5px var(--font);
  padding: 8px 10px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-chats li.active .chat-link { color: var(--link); }
.chat-del { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 8px; opacity: 0; }
.ai-chats li:hover .chat-del, .chat-del:focus { opacity: 1; }

.ai-main { display: flex; flex-direction: column; min-width: 0; }
.ai-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ai-model { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-weight: 500; }
.ai-model select { width: auto; padding: 6px 10px; }
.ai-status { font-size: 13px; color: var(--muted); }
.ai-status.ok { color: var(--ok); }
.ai-status.bad { color: var(--danger-text); }
.ai-log { flex: 1; min-height: 300px; max-height: min(54vh, 560px); overflow-y: auto; padding: 16px; border-radius: var(--radius);
  background: var(--surface-sunk); border: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 14px; }
.ai-msg { max-width: 86%; }
.ai-msg.user { align-self: flex-end; }
.ai-msg .who { font-size: 12px; color: var(--muted); margin: 0 4px 4px; }
.ai-msg.user .who { text-align: right; }
.ai-body { padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-soft); line-height: 1.6; word-break: break-word; font-size: 14.5px; }
.ai-msg.user .ai-body { white-space: pre-wrap; background: var(--accent); color: var(--accent-text); border-color: transparent; }
.ai-body > :first-child { margin-top: 0; }
.ai-body > :last-child { margin-bottom: 0; }
.ai-body p { margin: 0 0 10px; }
.ai-body ul, .ai-body ol { margin: 0 0 10px; padding-left: 22px; }
.ai-body h3, .ai-body h4, .ai-body h5, .ai-body h6 { margin: 14px 0 6px; font-size: 15px; }
.ai-body code { font-family: var(--font-mono); font-size: 0.88em; padding: 1px 5px; border-radius: 5px; background: var(--surface-sunk); border: 1px solid var(--border-soft); }
.ai-body pre { position: relative; margin: 0 0 10px; padding: 30px 12px 12px; border-radius: var(--radius-sm); background: var(--surface-sunk); border: 1px solid var(--border-soft); overflow-x: auto; }
.ai-body pre code { padding: 0; background: none; border: 0; font-size: 13px; white-space: pre; }
.ai-body pre[data-lang]::before { content: attr(data-lang); position: absolute; top: 8px; left: 12px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.copy-code { position: absolute; top: 6px; right: 6px; font: 600 11px var(--font); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.copy-code:hover { color: var(--text); }
.ai-body blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.ai-body hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.ai-wait { color: var(--muted); font-style: italic; margin: 0; }
.ai-msg.typing .ai-body::after { content: ""; display: inline-block; width: 7px; height: 14px; margin-left: 3px; vertical-align: -2px; background: var(--accent); border-radius: 1px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-error { color: var(--danger-text); margin: 8px 0 0; }
.ai-empty { margin: auto; text-align: center; color: var(--muted); max-width: 520px; }
.ai-empty .big { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--link); margin-bottom: 8px; }
.ai-empty .big .icon { width: 26px; height: 26px; }
.ai-ideas { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }

/* --- Dashboard ------------------------------------------------------------------------ */
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.dash-card { padding: 14px 14px 0; border-radius: var(--radius); background: var(--surface-sunk); border: 1px solid var(--border-soft); overflow: hidden; }
.dc-head { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.dc-icon { display: none; }
.dc-value { font-size: 1.55rem; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dc-spark { margin: 10px -14px 0; height: 40px; }
.dash-svg { display: block; width: 100%; height: 100%; }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 12px; }
.dash-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.dash-panel { padding: 16px; border-radius: var(--radius); background: var(--surface-sunk); border: 1px solid var(--border-soft); min-width: 0; }
.dash-panel h3 { margin: 0 0 12px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.dash-big { height: 190px; }
.dash-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.dash-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.dash-legend .axis { margin-left: auto; }
.dash-services { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dash-services li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.dash-services li i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dash-services li.down i { background: var(--danger); }
.dash-services b { font-weight: 500; }
.dash-services small { color: var(--muted); font-size: 12.5px; }
.dash-services li.down small { color: var(--danger-text); }
.dash-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.dash-cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 4px; }
.core { aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--text);
  background: color-mix(in srgb, var(--accent) calc(var(--load, 0) * 100%), var(--surface)); transition: background 0.6s; }
.dash-bar { height: 6px; border-radius: 99px; background: var(--border-soft); overflow: hidden; }
.dash-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.6s var(--ease); }
.dash-bar > span.alt { background: var(--accent-4); }
.dash-bar > span.warm { background: var(--accent-3); }
.dash-bar > span.hot { background: var(--danger); }
.gpu-name { margin: 0 0 12px; font-weight: 600; font-size: 14px; }
.gpu-row { margin-bottom: 10px; }
.gr-top, .dd-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.gr-top span, .dd-top span { color: var(--muted); }
.dash-kv { display: grid; gap: 8px; }
.dash-kv div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.dash-kv span { color: var(--muted); }
.dash-disk { margin-bottom: 12px; }
.dash-procs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dash-procs li { display: grid; grid-template-columns: minmax(0, 1.2fr) 1fr 70px; align-items: center; gap: 10px; font-size: 13.5px; }
.dash-procs .pn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-procs .pm { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.dash-foot { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

/* --- Inbox ------------------------------------------------------------------------------- */
.inbox-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.inbox-list li { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-sunk); border: 1px solid var(--border-soft); }
.inbox-list li.unread { border-left: 3px solid var(--accent); }
.msg-head { font-size: 13px; color: var(--muted); }
.msg-head b { color: var(--text); font-weight: 600; }
.msg-reply { margin: 4px 0 0; font-size: 13px; color: var(--link); word-break: break-all; }
.msg-text { margin: 8px 0 10px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; font-size: 14.5px; }

/* --- Small screens ------------------------------------------------------------------------ */
@media (max-width: 860px) {
  .dash-grid, .dash-grid.three { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .ai-wrap { grid-template-columns: 1fr; }
  .ai-chats { max-height: 120px; }
  .ai-msg { max-width: 96%; }
  .dash-cards { grid-template-columns: repeat(2, 1fr); }
}
