/* ════════════════════════════════════════════════════════════════════════
   Ask Argus — chat UI
   ════════════════════════════════════════════════════════════════════════ */

.askargus {
  display: flex;
  gap: 0;
  height: calc(100vh - var(--topbar-height) - 132px);
  min-height: 480px;
}

/* ── left rail (drag-resizable; width held in --rail-w) ────────────────── */
.askargus__rail {
  flex: 0 0 var(--rail-w, 256px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.askargus__rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.askargus__rail-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: 600;
}
/* Drag handle between rail and thread — grab it to widen/narrow the rail so
   long conversation titles are readable. */
.askargus__resizer {
  flex: 0 0 10px;
  cursor: col-resize;
  position: relative;
  align-self: stretch;
}
.askargus__resizer::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--border-subtle);
  border-radius: 2px;
  transition: background var(--duration-fast) var(--ease-out);
}
.askargus__resizer:hover::before,
.askargus__resizer:focus-visible::before,
.askargus.is-resizing .askargus__resizer::before {
  background: var(--accent);
  width: 3px;
}
.askargus.is-resizing { cursor: col-resize; user-select: none; }
.askargus__main { position: relative; }
.askargus__newbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.askargus__newbtn:hover { background: var(--accent-hover); }

.askargus__convos {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px;
}
.askargus__convos-empty { padding: 16px 12px; font-size: 12px; }

.askargus__convo {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.askargus__convo:hover { background: var(--bg-surface-raised); }
.askargus__convo.is-active { background: var(--accent-soft); color: var(--text-primary); }
.askargus__convo-pin { color: var(--accent-secondary); font-size: 8px; flex: 0 0 auto; }
.askargus__convo-title {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.askargus__convo-menu { position: relative; flex: 0 0 auto; }
.askargus__convo-menu-btn {
  opacity: 0;
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  transition: opacity var(--duration-fast), color var(--duration-fast);
}
.askargus__convo:hover .askargus__convo-menu-btn { opacity: 1; }
.askargus__convo-menu-btn:hover { color: var(--text-primary); background: var(--bg-surface-strong); }
.askargus__convo-actions {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 30;
  min-width: 130px;
  background: var(--bg-surface-strong);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
}
.askargus__convo-actions.is-open { display: block; }
.askargus__convo-actions button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.askargus__convo-actions button:hover { background: var(--bg-surface-raised); color: var(--text-primary); }
.askargus__convo-actions button.is-danger:hover { background: var(--down-soft); color: var(--down-bright); }

/* ── main column ───────────────────────────────────────────────────────── */
.askargus__main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-width: 0;
}

.askargus__notice {
  display: flex;
  gap: 12px;
  margin: 14px;
  padding: 12px 14px;
  background: var(--warning-soft);
  border: 1px solid rgba(247, 185, 85, 0.3);
  border-radius: var(--radius-md);
}
.askargus__notice-icon { color: var(--warning); flex: 0 0 auto; }
.askargus__notice-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.askargus__notice p { font-size: 12.5px; color: var(--text-secondary); line-height: 1.55; margin: 0; }

.askargus__thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px clamp(16px, 6%, 64px);
  scroll-behavior: smooth;
}

/* welcome / empty state */
.askargus__welcome {
  max-width: 640px;
  margin: clamp(16px, 6vh, 64px) auto 0;
  text-align: center;
}
.askargus__welcome-mark {
  width: 60px; height: 60px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  color: var(--accent-secondary);
  background: var(--accent-soft);
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: 50%;
}
.askargus__welcome-title { font-size: 26px; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 8px; }
.askargus__welcome-sub { font-size: 14px; color: var(--text-tertiary); line-height: 1.6; margin: 0 auto 24px; max-width: 520px; }
.askargus__starters { display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin: 0 auto; }
.askargus__starter {
  text-align: left;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  padding: 11px 14px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.askargus__starter:hover {
  background: var(--bg-surface-strong);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* ── messages ──────────────────────────────────────────────────────────── */
.aa-msg { display: flex; gap: 12px; margin-bottom: 22px; }
.aa-msg--user { justify-content: flex-end; }
.aa-msg--user .aa-msg__body { max-width: 80%; }
.aa-msg__avatar {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--accent-secondary);
  background: var(--accent-soft);
  border-radius: 50%;
  margin-top: 2px;
}
.aa-msg__avatar svg { width: 17px; height: 17px; }
/* The Argus mark gently pulses while it's thinking / streaming. */
.askargus.is-streaming .aa-msg:last-child .aa-msg__avatar {
  animation: aa-think 1.5s ease-in-out infinite;
}
@keyframes aa-think {
  0%, 100% { opacity: 0.45; transform: scale(0.94); }
  50%      { opacity: 1;    transform: scale(1); }
}
.aa-msg__body { min-width: 0; flex: 1 1 auto; }
.aa-msg--user .aa-msg__body { flex: 0 1 auto; }

.aa-bubble {
  display: inline-block;
  background: rgba(37, 99, 235, 0.13);
  border: 1px solid rgba(96, 165, 250, 0.22);
  color: var(--text-primary);
  padding: 9px 13px;
  border-radius: 13px 13px 3px 13px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

/* tool chips */
.aa-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.aa-tools:empty { display: none; }
.aa-tool-wrap { display: flex; flex-direction: column; }
.aa-tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 11px;
  font-size: 12px;
  color: var(--text-secondary);
}
.aa-tool--err {
  border-color: rgba(239, 83, 80, 0.35);
  background: var(--down-softer);
}
.aa-tool--expandable { cursor: pointer; }
.aa-tool--expandable:hover { border-color: var(--border-default); }
.aa-tool__icon { display: grid; place-items: center; color: var(--accent-secondary); flex: 0 0 auto; }
.aa-tool__icon svg { width: 13px; height: 13px; }
.aa-tool__label { display: inline-flex; gap: 6px; align-items: baseline; min-width: 0; }
.aa-tool__name { color: var(--text-primary); font-weight: 500; white-space: nowrap; }
.aa-tool__detail { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.aa-tool__summary { font-family: var(--font-mono); font-size: 11px; color: var(--up-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; flex: 0 1 auto; }
.aa-tool--err .aa-tool__summary { color: var(--down-bright); }
.aa-tool__spin {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent-secondary);
  border-radius: 50%;
  animation: aa-spin 0.7s linear infinite;
}
@keyframes aa-spin { to { transform: rotate(360deg); } }
.aa-tool--ok .aa-tool__icon { color: var(--up); }
.aa-tool__sql {
  margin: 4px 0 0;
  padding: 10px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-x: auto;
}
.aa-tool__chart {
  width: 100%;
  min-height: 280px;
  margin-top: 4px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
}
.aa-table-prev { margin-top: 2px; }
.aa-table-prev summary { font-size: 12px; color: var(--text-tertiary); cursor: pointer; padding: 4px 0; }
.aa-table-prev__wrap { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); margin-top: 4px; }

/* Everything in a chat answer must be freely selectable / copyable — these
   are answers people want to grab. Force text selection on (overrides any
   inherited user-select:none). */
.aa-md, .aa-bubble, .aa-tool__sql, .aa-tool__summary, .aa-table-prev,
.aa-msg, .aa-md * {
  -webkit-user-select: text;
  user-select: text;
}
.askargus__thread { -webkit-user-select: text; user-select: text; }

/* assistant markdown */
.aa-md { font-size: 13.5px; line-height: 1.62; color: var(--text-secondary); }
.aa-md > *:first-child { margin-top: 0; }
.aa-md > *:last-child { margin-bottom: 0; }
.aa-md p { margin: 0 0 11px; }
.aa-md h1, .aa-md h2, .aa-md h3, .aa-md h4 { color: var(--text-primary); font-weight: 600; line-height: 1.3; margin: 18px 0 8px; }
.aa-md h1 { font-size: 18px; } .aa-md h2 { font-size: 16px; } .aa-md h3 { font-size: 14px; } .aa-md h4 { font-size: 13px; }
.aa-md ul, .aa-md ol { margin: 0 0 11px; padding-left: 20px; }
.aa-md li { margin-bottom: 4px; }
.aa-md strong { color: var(--text-primary); font-weight: 600; }
.aa-md a { color: var(--accent-secondary); text-decoration: none; }
.aa-md a:hover { text-decoration: underline; }
.aa-md code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-inset); border: 1px solid var(--border-faint);
  padding: 1px 5px; border-radius: var(--radius-xs); color: var(--accent-secondary);
}
.aa-md pre {
  background: var(--bg-inset); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 12px 14px; overflow-x: auto; margin: 0 0 12px;
}
.aa-md pre code { background: none; border: 0; padding: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.55; }
.aa-md blockquote {
  border-left: 3px solid var(--accent); margin: 0 0 12px; padding: 2px 0 2px 14px; color: var(--text-tertiary);
}
.aa-md table {
  width: 100%; border-collapse: collapse; margin: 4px 0 14px; font-size: 12.5px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden;
}
.aa-md thead th {
  background: var(--bg-inset); text-align: left; padding: 8px 11px;
  font-weight: 600; color: var(--text-secondary); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
}
.aa-md tbody td { padding: 7px 11px; border-bottom: 1px solid var(--border-faint); font-variant-numeric: tabular-nums; }
.aa-md tbody tr:last-child td { border-bottom: 0; }
.aa-md tbody td:not(:first-child) { font-family: var(--font-mono); }

.aa-error {
  background: var(--down-soft); border: 1px solid rgba(239, 83, 80, 0.3);
  color: var(--down-bright); border-radius: var(--radius-md);
  padding: 9px 12px; font-size: 12.5px; margin-top: 6px;
}

/* typing indicator */
.aa-typing { display: inline-flex; gap: 4px; padding: 6px 2px; }
.aa-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  animation: aa-blink 1.2s infinite both;
}
.aa-typing span:nth-child(2) { animation-delay: 0.2s; }
.aa-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aa-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ── composer ──────────────────────────────────────────────────────────── */
.askargus__composer {
  border-top: 1px solid var(--border-subtle);
  padding: 12px clamp(16px, 6%, 64px) 10px;
  background: var(--bg-surface);
}
.askargus__composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 14px;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.askargus__composer-inner:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer); }
.askargus__composer textarea {
  flex: 1 1 auto;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  max-height: 200px;
  padding: 5px 0;
  outline: none;
}
.askargus__composer textarea::placeholder { color: var(--text-muted); }
.askargus__send {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.askargus__send:hover:not(:disabled) { background: var(--accent-hover); }
.askargus__send:disabled { opacity: 0.4; cursor: not-allowed; }
.askargus.is-streaming .askargus__send { opacity: 0.5; }
.askargus__composer-foot {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 7px; font-size: 11px; flex-wrap: wrap;
}

/* ── responsive ────────────────────────────────────────────────────────── */
@media (max-width: 880px) {
  .askargus { flex-direction: column; height: auto; }
  .askargus__rail { flex: none; max-height: 220px; }
  .askargus__main { min-height: 70vh; }
  .aa-msg--user .aa-msg__body { max-width: 90%; }
}
