/* Ask Mira — data agent chat page */

.am-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 20px 8px;
  position: relative;
}

.am-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.am-new-btn {
  border: 1px solid #d7d7de;
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.am-new-btn:hover { background: #f5f5f7; }

/* Landing */
.am-landing { text-align: center; padding: 32px 0 8px; }
.am-greeting { font-size: 26px; font-weight: 650; margin: 8px 0 6px; }
.am-sub { color: #6b6b76; max-width: 560px; margin: 0 auto 22px; }
.am-chips {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  max-width: 680px; margin: 0 auto 28px;
}
.am-chip {
  border: 1px solid #e2e2e8; background: #fafafb; border-radius: 14px;
  padding: 10px 14px; font-size: 13px; color: #333; cursor: pointer; text-align: left;
}
.am-chip:hover { background: #f0f0f4; border-color: #cfcfd8; }

.am-history-label {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: #9a9aa4;
}
.am-history-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  background: none; border: 0; padding: 0; cursor: pointer; margin: 18px 0 8px;
}
.am-history-caret { color: #9a9aa4; transition: transform .15s ease; }
.am-history-toggle.am-open .am-history-caret { transform: rotate(90deg); }
.am-history { display: flex; flex-direction: column; gap: 6px; }
.am-history-collapsed { display: none; }                     /* dock: closed = nothing shown */
.am-history-capped > *:nth-child(n+4) { display: none; }     /* page: closed = first 3 shown */
.am-hist-item {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid #ececf1; background: #fff; border-radius: 8px;
  padding: 10px 12px; cursor: pointer; text-align: left; width: 100%;
}
.am-hist-item:hover { background: #f7f7f9; }
.am-hist-title { font-size: 14px; color: #26262c; }
.am-hist-date { font-size: 12px; color: #a0a0aa; }
.am-empty { color: #9a9aa4; font-size: 13px; padding: 6px 0; }

/* Thread */
.am-thread-wrap { margin-top: 8px; }
.am-thread { display: flex; flex-direction: column; gap: 14px; }
.am-msg { border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.am-user { align-self: flex-end; background: #eef1ff; max-width: 78%; }
.am-assistant { align-self: flex-start; background: #f6f6f8; width: 100%; }
.am-error { align-self: flex-start; background: #fdecec; color: #8a1c1c; }
.am-thinking { color: #8a8a94; font-style: italic; }

/* Live progress checklist */
.am-pending { display: flex; flex-direction: column; gap: 4px; }
.am-step { display: flex; align-items: center; gap: 7px; font-size: 13px; line-height: 1.4; }
.am-step-done { color: #9a9aa4; }
.am-step-done .am-step-check { color: #7AC020; font-weight: 700; }
.am-step-active { color: #26262c; }
.am-step-timer {
  margin-left: 6px; color: #b0b0b8; font-size: 12px;
  font-variant-numeric: tabular-nums; min-width: 2.5em;
}
.am-dots::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: am-dots 1.4s steps(1, end) infinite;
}
@keyframes am-dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
  100% { content: ""; }
}
.am-stop-btn {
  align-self: flex-start; margin-top: 6px;
  border: 1px solid #d7d7de; background: #fff; color: #6b6b76;
  border-radius: 8px; padding: 4px 12px; font-size: 12.5px; cursor: pointer;
}
.am-stop-btn:hover:not(:disabled) { background: #fdecec; border-color: #e0b4b4; color: #8a1c1c; }
.am-stop-btn:disabled { color: #b0b0b8; cursor: default; }
.am-md p:last-child { margin-bottom: 0; }
.am-md table { border-collapse: collapse; margin: 8px 0; }
.am-md th, .am-md td { border: 1px solid #e2e2e8; padding: 4px 8px; font-size: 13px; }
.am-artifact { margin-top: 10px; }
.am-fail-note {
  margin-top: 10px; font-size: 12.5px; color: #8a5a1c; line-height: 1.45;
  background: #fdf6ec; border: 1px solid #f0e0c0; border-radius: 8px; padding: 8px 10px;
}
.am-fail-icon { font-weight: 700; }
/* charts sit directly on the bubble (no nested box); tables get a light frame */
.am-chart { }
.am-table-wrap { background: #fff; border: 1px solid #ececf1; border-radius: 8px; padding: 6px; overflow: auto; }
.am-table { width: 100%; }

/* Input area — sticky within the content column (respects the nav rail), so it
   stays aligned with the messages instead of centering on the whole viewport. */
.am-inputwrap {
  position: sticky; bottom: 0;
  padding: 12px 0 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #fff 22%);
}
.am-inputbar {
  display: flex; gap: 8px; align-items: stretch;   /* button matches textarea height */
}
.am-disclaimer {
  font-size: 11px; color: #9a9aa4; text-align: center; line-height: 1.4;
  padding: 6px 8px 4px;
}
/* Attached-view chip — sits with the composer, so what the question will be
   asked about stays visible while the thread scrolls. Modelled on an editor's
   file attachment: an icon plus what is attached, and clicking the chip cycles
   the scope (eye = the visible rows, page = this page's whole dataset,
   globe = the whole study). Always visible, so the frame is never a guess. */
.am-ctxbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 0 2px 6px;
}
.am-ctxnav {
  display: none; align-items: center; background: none; border: 0;
  padding: 2px; cursor: pointer; color: #8a8a95;
}
.am-ctxbar-multi .am-ctxnav { display: inline-flex; }
.am-ctxnav:hover { color: #2c3a7a; }
.am-ctxchip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef1ff; border: 1px solid #c7d1f5; border-radius: 12px;
  padding: 3px 10px; font-size: 12px; color: #2c3a7a; cursor: pointer;
  text-align: left; animation: am-ctx-pop 0.35s ease;
}
.am-ctxchip:hover { background: #e3e8ff; border-color: #aebbf0; }
.am-ctxchip .am-ctxchip-icon { flex: none; }
/* Study scope: no page is attached, so the chip reads neutral rather than accented. */
.am-ctxchip-study {
  background: #f2f2f4; border-color: #dcdce2; color: #6a6a74;
}
.am-ctxchip-study:hover { background: #ececf0; border-color: #cfcfd8; }
/* A capture replaces the chip's children, replaying this — so a re-capture or a
   scope change is visibly acknowledged even when the resulting text is unchanged. */
@keyframes am-ctx-pop {
  0%   { transform: scale(0.96); background: #dfe6ff; }
  60%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}
.am-ctxchip-past {
  display: inline-flex; margin-bottom: 6px; cursor: default; animation: none;
  background: #e7eaf6; border-color: #d0d6ea; color: #4a5578; font-size: 11.5px;
}

.am-input {
  flex: 1; resize: none; border: 1px solid #d7d7de; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; min-height: 46px;
}
.am-send-btn {
  border: none; background: #3b5bdb; color: #fff; border-radius: 10px;
  padding: 0 22px; font-size: 14px; cursor: pointer;
}
.am-send-btn:hover { background: #2f4bc4; }
