/* ============================================================
   ATLAS CHAT — animated demo conversation
   An auto-playing chat surface that streams a Facility-Management
   spend overview: retrieval toasts → summary (counting stats) →
   pie, supplier bars, spend-trend area chart → recommendations.
   Mounts into [data-atlas-chat]. Product colorway.
   ============================================================ */

.ac-stage { padding: 0 !important; display: block !important; background: #fff !important; }
.atlas-chat {
  --ac-ink: #1f2733;
  --ac-muted: #6b7280;
  --ac-border: #EAECF1;
  position: relative;
  display: flex; flex-direction: column;
  height: 100%; width: 100%;
  background: #fff;
  font-family: var(--font-body);
  color: var(--ac-ink);
  overflow: hidden;
}

/* scroll region (scrollbar hidden — it auto-follows the stream) */
.ac-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 22px 24px 8px;
  scrollbar-width: none;
}
.ac-scroll::-webkit-scrollbar { width: 0; height: 0; }
.ac-thread { display: flex; flex-direction: column; gap: 15px; max-width: 720px; }

/* entrance */
.ac-row { opacity: 0; transform: translateY(9px); transition: opacity .42s var(--ease), transform .42s var(--ease); }
.ac-row.in { opacity: 1; transform: none; }
html.anim-off .ac-row { opacity: 1; transform: none; transition: none; }

/* user bubble */
.ac-user { align-self: flex-end; max-width: 80%; }
.ac-user .ac-bubble {
  background: var(--ink); color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 11px 16px; font-size: 13.5px; line-height: 1.5;
}

/* assistant blocks */
.ac-asst { display: flex; flex-direction: column; gap: 11px; }
.ac-asst p { font-size: 13.5px; line-height: 1.62; color: #353c47; margin: 0; }
.ac-asst p strong, .ac-asst li strong { color: var(--ac-ink); font-weight: 600; }

/* retrieval toast */
.ac-toast {
  display: inline-flex; align-items: center; gap: 9px; width: fit-content;
  background: var(--green-bg); border: 1px solid #c7e8d1;
  border-radius: 9px; padding: 7px 13px 7px 10px;
  font-size: 12.5px; font-weight: 600; color: #1c7d40;
}
.ac-toast .ac-toast-ic {
  width: 18px; height: 18px; border-radius: 5px; flex: 0 0 auto;
  background: #fff; color: var(--green);
  display: grid; place-items: center;
}
.ac-toast .ac-toast-ic svg { width: 12px; height: 12px; }

/* section heading */
.ac-h {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-head); font-weight: 600; font-size: 14.5px;
  color: var(--ac-ink); letter-spacing: -0.01em; margin-top: 4px;
}
.ac-h .ac-h-ic {
  width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto;
  background: #EAEFFE; color: var(--really-blue);
  display: grid; place-items: center;
}
.ac-h .ac-h-ic svg { width: 15px; height: 15px; }

/* summary stat cards */
.ac-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ac-stat {
  border: 1px solid var(--ac-border); border-radius: 10px;
  padding: 13px 15px; background: #FCFCFD;
}
.ac-stat .ac-stat-n {
  font-family: var(--font-head); font-weight: 700; font-size: 21px;
  color: var(--ink); letter-spacing: -0.02em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ac-stat .ac-stat-l { font-size: 11px; color: var(--ac-muted); margin-top: 6px; letter-spacing: .01em; }

/* ranked / bulleted lists */
.ac-list { display: flex; flex-direction: column; gap: 7px; counter-reset: acl; }
.ac-li {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 13px; color: #353c47; line-height: 1.45;
}
.ac-li .ac-li-n {
  font-family: var(--font-head); font-weight: 700; font-size: 12px;
  color: var(--really-blue); flex: 0 0 auto; min-width: 15px;
  font-variant-numeric: tabular-nums;
}
.ac-li .ac-li-v { color: var(--ac-ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* supplier bars */
.ac-bars { display: flex; flex-direction: column; gap: 9px; }
.ac-bar { display: grid; grid-template-columns: 168px 1fr 64px; align-items: center; gap: 12px; }
.ac-bar .ac-bar-name { font-size: 12.5px; color: #353c47; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-bar .ac-bar-track { display: block; height: 9px; background: #EEF1F6; border-radius: 999px; overflow: hidden; }
.ac-bar .ac-bar-fill {
  display: block;
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #0a2da0, #2f72d4);
  transition: width 1s var(--ease);
}
.ac-bar .ac-bar-v { font-size: 12px; color: var(--ac-ink); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px){ .ac-bar { grid-template-columns: 110px 1fr 52px; } }

/* chart card */
.ac-card {
  border: 1px solid var(--ac-border); border-radius: 12px;
  background: #fff; padding: 16px 18px;
}
.ac-card-title { font-family: var(--font-head); font-weight: 600; font-size: 13px; color: var(--ac-ink); text-align: center; }
.ac-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 9px 0 4px; }
.ac-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ac-muted); }
.ac-legend i { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }

/* pie */
.ac-pie-wrap { display: flex; align-items: center; justify-content: center; gap: 26px; flex-wrap: wrap; padding: 6px 0 2px; }
.ac-pie {
  width: 168px; height: 168px; border-radius: 50%; flex: 0 0 auto;
  transform: scale(.6) rotate(-12deg); opacity: 0;
  transition: transform .8s var(--ease), opacity .6s var(--ease);
  box-shadow: 0 8px 22px rgba(11,14,20,.12);
}
.ac-pie.in { transform: none; opacity: 1; }
.ac-pie-legend { display: flex; flex-direction: column; gap: 8px; }
.ac-pie-legend .ac-pl { display: flex; align-items: center; gap: 9px; font-size: 12px; color: #353c47; }
.ac-pie-legend .ac-pl i { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.ac-pie-legend .ac-pl b { margin-left: auto; font-weight: 600; color: var(--ac-ink); font-variant-numeric: tabular-nums; padding-left: 14px; }

/* swept area / line chart reveal */
.ac-chart-reveal { clip-path: inset(0 100% 0 0); transition: clip-path 1.25s var(--ease); }
.ac-chart-reveal.in { clip-path: inset(0 0 0 0); }
.ac-area-svg { width: 100%; height: auto; display: block; }
.ac-axis { font-size: 9.5px; fill: #9aa0ac; font-family: var(--font-body); }
.ac-gridline { stroke: #EEF1F6; stroke-width: 1; }

/* suggestion chips */
.ac-sugs { display: flex; flex-direction: column; gap: 8px; }
.ac-sug {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--ac-border); border-radius: 10px;
  padding: 10px 13px; font-size: 12.5px; color: #3c4250; background: #FCFCFD;
}
.ac-sug .ac-sug-ar { margin-left: auto; color: #b6bac4; width: 15px; height: 15px; flex: 0 0 auto; }
.ac-sug .ac-sug-ar svg { width: 15px; height: 15px; }

/* typing indicator */
.ac-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.ac-typing i { width: 6px; height: 6px; border-radius: 50%; background: #c2c8d2; animation: acBlink 1.2s infinite ease-in-out; }
.ac-typing i:nth-child(2){ animation-delay: .2s; } .ac-typing i:nth-child(3){ animation-delay: .4s; }
@keyframes acBlink { 0%,80%,100%{ opacity:.3; transform: translateY(0);} 40%{ opacity:1; transform: translateY(-3px);} }

/* bottom input (demo chrome) */
.ac-input {
  display: flex; flex-direction: column; gap: 10px; flex: 0 0 auto;
  margin: 4px 16px 16px; padding: 13px 14px 12px;
  border: 1px solid var(--ac-border); border-radius: 14px;
  background: #fff; box-shadow: var(--shadow-xs);
}
.ac-input-row { display: flex; align-items: center; gap: 10px; }
.ac-input .ac-input-ph { flex: 1; font-size: 13.5px; color: #aab0bc; }
.ac-input .ac-input-ph.ac-typed { color: var(--ac-ink); }
.ac-input .ac-up {
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; background: var(--ink);
}
.ac-input .ac-up svg { width: 15px; height: 15px; }
.ac-input-tip { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: #aab0bc; }
.ac-input-tip kbd {
  font-family: var(--font-body); font-size: 10.5px; font-weight: 600; color: #6b7280;
  background: #F1F2F6; border: 1px solid var(--ac-border); border-radius: 4px; padding: 1px 5px;
}
.ac-input-tip .ac-model {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #3c4250;
}
/* render the EXACT homepage orb (56px mesh/blur/displacement/swirl) and scale
   it down so every proportion matches the homepage; negative margin collapses
   the scaled footprint back to ~19px in the layout */
.ac-input-tip .ac-model-dot.agent-orb {
  width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto;
  transform: scale(0.34); transform-origin: center;
  margin: -18px -19px;
}
.ac-input-tip .ac-model svg { width: 13px; height: 13px; color: var(--ac-muted); }

/* ============================================================
   TWO-PANE ATLAS LAYOUT — chat history rail + chat
   ============================================================ */
.ac-layout { display: grid; grid-template-columns: 226px 1fr; flex: 1 1 auto; min-height: 0; height: 100%; }
@media (max-width: 720px) { .ac-layout { grid-template-columns: 1fr; } .ac-history { display: none; } }

.ac-history {
  display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--ac-border);
  background: #FBFBFC; padding: 12px 10px; min-height: 0;
}
.ac-ws {
  display: flex; align-items: center; gap: 6px; width: fit-content;
  background: none; border: 0; padding: 6px 8px; border-radius: 8px;
  font-family: var(--font-head); font-weight: 600; font-size: 15px; color: var(--ink); letter-spacing: -0.01em;
}
.ac-ws:hover { background: #F0F1F4; }
.ac-ws .ac-ws-chev { width: 14px; height: 14px; color: var(--ac-muted); display: inline-flex; }
.ac-newchat {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; padding: 9px 10px; border-radius: 9px; margin-bottom: 4px;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500; color: #2f3540; text-align: left;
}
.ac-newchat:hover { background: #F0F1F4; }
.ac-newchat .ac-nc-ic { width: 17px; height: 17px; color: #6b7280; flex: 0 0 auto; }
.ac-newchat .ac-nc-ic svg { width: 17px; height: 17px; }

.ac-hist { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; min-height: 0; scrollbar-width: none; }
.ac-hist::-webkit-scrollbar { width: 0; }
.ac-hist-day { font-size: 10.5px; font-weight: 600; color: #aab0bc; padding: 13px 10px 6px; }
.ac-hist-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; color: #3c4250;
}
.ac-hist-item > span:first-child { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-hist-item:hover { background: #F0F1F4; }
.ac-hist-item.active { background: #ECECF0; color: var(--ink); font-weight: 500; }
.ac-hist-more { width: 16px; height: 16px; color: #b6bac4; flex: 0 0 auto; opacity: 0; transition: opacity .12s; }
.ac-hist-item:hover .ac-hist-more, .ac-hist-item.active .ac-hist-more { opacity: 1; }
.ac-hist-more svg { width: 16px; height: 16px; }

.ac-main { display: flex; min-width: 0; min-height: 0; }
.ac-main .atlas-chat { height: 100%; }

/* word-by-word streaming reveal for assistant text */
@keyframes acWordIn { from { opacity: 0; filter: blur(2.5px); } to { opacity: 1; filter: none; } }
.ac-w { display: inline; opacity: 0; animation: acWordIn .3s var(--ease) forwards; }
html.anim-off .ac-w { opacity: 1; animation: none; filter: none; }

/* replay control */
.ac-replay {
  position: absolute; top: 12px; right: 14px; z-index: 5;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-body); font-size: 11.5px; font-weight: 600; color: var(--ac-muted);
  background: rgba(255,255,255,.9); border: 1px solid var(--ac-border);
  border-radius: 999px; padding: 5px 12px;
  opacity: 0; transition: opacity .3s; cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.ac-replay svg { width: 13px; height: 13px; }
.atlas-chat.done .ac-replay { opacity: 1; }
.ac-replay:hover { color: var(--ink); border-color: #c8ccd6; }

/* caret while a paragraph "types" */
.ac-caret::after {
  content: ""; display: inline-block; width: 2px; height: 1em;
  background: var(--really-blue); margin-left: 2px; vertical-align: -2px;
  animation: acCaret .8s steps(1) infinite;
}
@keyframes acCaret { 50% { opacity: 0; } }
