/* ============================================================================
   scene-nlq.css · Demo 1 — "Ask Mity" natural-language analytics chat for CPF
   restaurant operations. Scripted Mity chat (thinking trace → streamed answer →
   inline chart → cited source → read-aloud). Chat DOM mirrors the copilot contract.
   ========================================================================== */
.scene-nlq { display: block; }

/* ---- Chat column ---- */
.nlq-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.copilot { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px 26px; min-height: 0; }
.copilot__inner { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 760px; gap: 20px; }
.copilot.is-chat { justify-content: flex-start; padding: 22px 24px 24px; }
.copilot.is-chat .copilot__inner { align-items: stretch; gap: 14px; flex: 1; height: 100%; }
.copilot.is-chat .copilot__greeting { display: none; }

.copilot__greeting { display: flex; align-items: center; gap: 22px; }
.copilot__mascot { width: 104px; height: 104px; flex-shrink: 0; }
.copilot__mascot img { width: 100%; height: 100%; object-fit: contain; }
.copilot__text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 300px; }
.copilot__title { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -.01em; line-height: 1.08; }
.copilot__sub { font-size: 14px; color: var(--text-dim); }

.chat__messages { display: none; flex-direction: column; gap: 16px; }
.copilot.is-chat .chat__messages { display: flex; flex: 1; min-height: 0; overflow-y: auto; padding: 6px 2px 14px; scroll-behavior: smooth; }

.chat__msg { display: flex; align-items: flex-end; gap: 10px; animation: chat-in .25s ease-out; }
@keyframes chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.chat__msg--user { justify-content: flex-end; }
.chat__bubble { max-width: 78%; padding: 10px 16px; font-size: 14px; line-height: 1.55; word-wrap: break-word; white-space: pre-wrap; }
.chat__bubble--user { background: var(--ink); color: #fff; border-radius: 18px 18px 4px 18px; }
.chat__msg--assistant { justify-content: flex-start; align-items: flex-start; }
.chat__mini-mascot { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; overflow: hidden; background: var(--mint-tint); }
.chat__mini-mascot img { width: 100%; height: 100%; object-fit: cover; }
.chat__assistant-body { display: flex; flex-direction: column; gap: 9px; min-width: 0; max-width: 90%; }
.chat__bubble--assistant { background: transparent; color: var(--text-1); max-width: 100%; padding: 4px 0; white-space: pre-wrap; font-size: 14px; line-height: 1.62; }
.chat__bubble--assistant:not(.is-streaming) { white-space: normal; }

/* thinking block */
.chat__thinking { border: 1px solid var(--line); border-radius: 10px; background: var(--softer); overflow: hidden; }
.chat__thinking-toggle { display: flex; align-items: center; gap: 6px; padding: 8px 12px; cursor: pointer; font-size: 12px; color: var(--text-2); user-select: none; list-style: none; }
.chat__thinking-toggle::-webkit-details-marker { display: none; }
.chat__thinking-chevron { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; transition: transform .18s; }
.chat__thinking[open] .chat__thinking-chevron { transform: rotate(90deg); }
.chat__thinking-label { font-weight: 600; }
.chat__thinking.is-thinking .chat__thinking-label { background: linear-gradient(90deg, var(--text-soft), var(--text-1), var(--text-soft)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: think-shimmer 1.6s linear infinite; }
@keyframes think-shimmer { to { background-position: -200% 0; } }
.chat__thinking-content { padding: 8px 12px 10px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6; color: var(--text-dim); white-space: pre-wrap; }

/* markdown */
.chat__bubble--assistant p { margin: 0 0 8px; }
.chat__bubble--assistant p:last-child { margin-bottom: 0; }
.chat__bubble--assistant strong { font-weight: 700; color: var(--text-1); }
.chat__bubble--assistant ul, .chat__bubble--assistant ol { margin: 0 0 8px; padding-left: 20px; }
.chat__bubble--assistant ul { list-style: disc; } .chat__bubble--assistant ol { list-style: decimal; }
.chat__bubble--assistant li { margin: 3px 0; }
.chat__bubble--assistant table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.chat__bubble--assistant thead { background: #036b4d; }
.chat__bubble--assistant th { color: #fff; font-weight: 700; text-align: left; padding: 7px 11px; white-space: nowrap; }
.chat__bubble--assistant td { padding: 7px 11px; border-bottom: 1px solid var(--line-soft); }
.chat__bubble--assistant tbody tr:last-child td { border-bottom: 0; }
.chat__bubble--assistant tbody tr.hl { background: var(--mint-tint); font-weight: 600; }

.chat__bubble.is-streaming::after { content: ''; display: inline-block; width: 6px; height: 14px; margin-left: 3px; vertical-align: -2px; background: var(--mint); border-radius: 1px; animation: caret-blink .9s steps(2) infinite; }
@keyframes caret-blink { 50% { opacity: 0; } }

/* ---- inline chart card ---- */
.nlq-chart { border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px 12px; background: var(--surface); box-shadow: var(--shadow-sm); animation: lab-up .4s cubic-bezier(.2,.7,.2,1) backwards; }
.nlq-chart__h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.nlq-chart__h b { font-family: var(--font-display); font-weight: 800; font-size: 13.5px; }
.nlq-chart__h span { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-soft); margin-left: auto; }
.nlq-bars { display: flex; align-items: flex-end; gap: 10px; height: 132px; padding-bottom: 2px; }
.nlq-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.nlq-bar__col { width: 100%; max-width: 40px; border-radius: 7px 7px 0 0; background: linear-gradient(180deg, var(--mint-600), var(--mint)); height: 0; transition: height .9s cubic-bezier(.2,.7,.2,1); position: relative; }
.nlq-bar.is-hl .nlq-bar__col { background: linear-gradient(180deg, #07d39b, #03a87b); box-shadow: 0 6px 16px rgba(4,190,140,.35); }
.nlq-bar.is-dim .nlq-bar__col { background: linear-gradient(180deg, #cfe7df, #bcdfd2); }
.nlq-bar.is-risk .nlq-bar__col { background: linear-gradient(180deg, #f0705f, #dc2626); box-shadow: 0 6px 16px rgba(220,38,38,.28); }
.nlq-bar__val { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; color: var(--text-2); opacity: 0; transition: opacity .3s ease .6s; }
.nlq-bar.is-hl .nlq-bar__val { color: var(--mint-ink); }
.nlq-bar.is-risk .nlq-bar__val { color: #b42318; }
.nlq-bar__lab { font-family: var(--font-mono); font-size: 10px; color: var(--text-soft); text-align: center; }
.nlq-bar.is-hl .nlq-bar__lab { color: var(--text-1); font-weight: 700; }
.nlq-bars.is-shown .nlq-bar__val { opacity: 1; }
.nlq-chart__foot { display: flex; gap: 14px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.nlq-chart__metric b { font-family: var(--font-display); font-weight: 800; font-size: 16px; display: block; }
.nlq-chart__metric span { font-size: 10.5px; color: var(--text-soft); }
.nlq-chart__metric .up { color: var(--ok); } .nlq-chart__metric .down { color: var(--danger); }

/* ---- suggested chips ---- */
.nlq-chips { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; max-width: 760px; justify-content: center; }
.copilot.is-chat .nlq-chips { display: none; }
.nlq-chip { font-size: 13px; font-weight: 500; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 8px 15px; transition: transform .15s, border-color .15s, color .15s, box-shadow .15s; display: inline-flex; align-items: center; }
.nlq-chip:hover { transform: translateY(-1px); border-color: var(--mint); color: var(--mint-700); box-shadow: 0 4px 12px rgba(4,190,140,.12); }
.nlq-chip__ico { display: inline-flex; margin-right: 7px; }
.nlq-chip__ico .mi { width: 15px; height: 15px; color: var(--mint-700); }

/* ---- citation ---- */
.nlq-cite { display: flex; align-items: flex-start; gap: 10px; padding: 10px 13px; border: 1px solid var(--line); border-left: 3px solid var(--mint); border-radius: 0 12px 12px 0; background: var(--mint-tint-2); animation: cite-in .4s cubic-bezier(.2,.7,.2,1) backwards; }
@keyframes cite-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.nlq-cite__ico { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); }
.nlq-cite__ico .mi { width: 15px; height: 15px; color: var(--mint-700); }
.nlq-cite__title { font-size: 12.5px; font-weight: 700; }
.nlq-cite__sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); margin-top: 1px; }
.nlq-cite__tag { margin-left: auto; align-self: center; font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: .06em; color: var(--mint-ink); background: var(--mint-tint); padding: 3px 7px; border-radius: 6px; flex-shrink: 0; }

/* read-aloud row */
.nlq-speakrow { display: flex; align-items: center; gap: 8px; }

/* ---- input ---- */
.copilot__input { width: 100%; max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 7px 7px 7px 8px; display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s; }
.copilot.is-chat .copilot__input { margin-top: auto; }
.copilot__input:focus-within { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(4,190,140,.13), var(--shadow-sm); }
.copilot__field { flex: 1; background: transparent; border: none; outline: none; font-size: 14px; line-height: 1.5; color: var(--text-1); padding: 8px 6px; min-width: 0; resize: none; max-height: 120px; }
.copilot__field::placeholder { color: var(--text-soft); }
.copilot__attach { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--text-soft); flex: none; }
.copilot__attach .mi { width: 18px; height: 18px; }
.copilot__attach:hover { background: var(--soft); color: var(--text-1); }
.copilot__send { width: 38px; height: 38px; border-radius: 50%; background: var(--mint); color: #fff; display: grid; place-items: center; flex-shrink: 0; transition: background .15s, transform .15s; }
.copilot__send:hover { background: var(--mint-hover); }
.copilot__send:active { transform: scale(.94); }
.copilot__send svg { width: 16px; height: 16px; fill: currentColor; }
.copilot__input.is-pending .copilot__send { opacity: .55; pointer-events: none; }

/* ===== richer "AI working" trace ===== */
.nlq-steps { display: flex; flex-direction: column; gap: 1px; }
.nlq-step { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); }
.nlq-step__ic { width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
.nlq-step__ic .mi { width: 14px; height: 14px; color: var(--mint); }
.nlq-step__t { flex: 1; min-width: 0; }
.nlq-step.is-active .nlq-step__t { color: var(--text-1); }
.nlq-step.is-done { color: var(--text-soft); }
.nlq-spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--mint); animation: nlq-spin .7s linear infinite; }
@keyframes nlq-spin { to { transform: rotate(360deg); } }
.nlq-sql { background: #0e1a15; color: #d4efe2; font-family: var(--font-mono); font-size: 11px; line-height: 1.65; padding: 11px 13px; border-radius: 9px; margin: 4px 0 7px 25px; white-space: pre-wrap; border: 1px solid #1c2b23; overflow-x: auto; min-height: 1.6em; }
.nlq-scan { height: 3px; width: 64px; flex: none; background: var(--line); border-radius: 999px; overflow: hidden; margin-left: 10px; }
.nlq-scan i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mint-600), var(--mint)); transition: width 1s linear; }

/* analytics → action follow-ups */
.nlq-follow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; animation: cite-in .4s cubic-bezier(.2,.7,.2,1) backwards; }
.nlq-follow__lab { font-size: 11.5px; color: var(--text-soft); }
.nlq-follow__chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--mint-ink); background: var(--mint-tint); border-radius: 999px; padding: 6px 12px; transition: background .15s, color .15s, transform .15s; }
.nlq-follow__chip:hover { background: var(--mint); color: #fff; transform: translateY(-1px); }
.nlq-follow__chip .mi { width: 13px; height: 13px; }
.nlq-follow__chip.is-done { background: var(--soft); color: var(--text-soft); pointer-events: none; }
.nlq-follow__chip.is-done .mi { color: var(--ok); }

/* ===== platform chat fit (Demo 1 inside the Amity shell) ===== */
.pf-chat .copilot { padding: 36px 24px 22px; }
.pf-chat .copilot.is-chat { padding: 18px 24px 20px; }
.pf-chat .copilot__title { font-size: 34px; }

/* frontliner "today's tasks" checklist (in the left panel) */
.mity-tasks { display: flex; flex-direction: column; gap: 3px; }
.mity-task { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border-radius: 10px; transition: background .15s; }
.mity-task:hover { background: var(--soft); }
.mity-task__check { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; margin-top: 1px; transition: background .15s, border-color .15s; }
.mity-task__check .mi { width: 12px; height: 12px; color: transparent; }
.mity-task.is-done .mity-task__check { background: var(--mint); border-color: var(--mint); }
.mity-task.is-done .mity-task__check .mi { color: #fff; }
.mity-task__text { flex: 1; text-align: left; font-size: 12.5px; line-height: 1.4; color: var(--text-1); }
.mity-task__text:hover { color: var(--mint-ink); }
.mity-task.is-done .mity-task__text { color: var(--text-soft); text-decoration: line-through; }

/* awaiting-first-token typing dots */
.nlq-typing { display: inline-flex; gap: 5px; padding: 8px 2px; }
.nlq-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-soft); animation: nlq-typing 1.2s infinite; }
.nlq-typing i:nth-child(2) { animation-delay: .18s; } .nlq-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes nlq-typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* model selector in the composer */
.copilot__model { display: inline-flex; align-items: center; gap: 5px; flex: none; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px 4px 9px; transition: border-color .15s; }
.copilot__model:hover { border-color: var(--mint); }
.copilot__model-ic { display: inline-flex; }
.copilot__model-ic .mi { width: 14px; height: 14px; color: var(--mint-700); }
.copilot__model select { border: none; background: transparent; outline: none; font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; -webkit-appearance: none; appearance: none; padding-right: 2px; max-width: 92px; }

@media (max-width: 940px) {
  .copilot { min-height: 60vh; }
  .copilot__text { min-width: 0; }
}
@media (max-width: 620px) {
  .copilot__model select { max-width: 64px; }
}
