/* ============================================================
   Throughline AI — Customer Triage Inbox (demo-specific styles)
   Loads on top of ../styles.css and demo.css (palette + chrome).
   All colors use existing CSS variables only.
   ============================================================ */

/* ---------- app shell (fills space under the fixed demo-bar) ---------- */
.triage-app {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
}

/* ---------- sidebar ---------- */
.triage-aside {
  border-right: 1px solid var(--line);
  background: var(--paper-2);
  padding: 1.2rem 1.1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.triage-aside .mt-block { margin-top: 1.5rem; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.55rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.55rem;
}
.stat-num {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  transition: color .2s ease;
}
.stat-num.bump { animation: numBump .45s ease; }
@keyframes numBump {
  0%   { transform: none; color: var(--accent); }
  35%  { transform: translateY(-3px) scale(1.12); color: var(--accent); }
  100% { transform: none; }
}
.stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.2;
}

.triage-aside .source-list { list-style: none; margin: 0; padding: 0; }
.triage-aside .source {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0.5rem;
  border-radius: 8px;
}
.triage-aside .dot-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  margin-top: 0.42rem;
  flex: 0 0 auto;
  animation: livePulse 2.4s ease infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  60%  { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
}
.triage-aside .source-name { font-weight: 600; font-size: 0.92rem; line-height: 1.3; }
.triage-aside .source-meta { font-size: 0.76rem; color: var(--muted); }
.triage-aside .demo-aside-note {
  margin-top: auto;
  padding-top: 1.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ---------- main column ---------- */
.triage-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.triage-head {
  flex: 0 0 auto;
  padding: 1.2rem clamp(1rem, 4vw, 2.2rem) 0.9rem;
  border-bottom: 1px solid var(--line);
}
.triage-h { margin: 0 0 0.3rem; font-size: 1.5rem; }
.triage-sub { margin: 0; font-size: 0.92rem; color: var(--muted); max-width: 62ch; }

.triage-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.4rem clamp(1rem, 4vw, 2.2rem) 2.4rem;
  scroll-behavior: smooth;
}

.queue-section, .resolved-section { max-width: 760px; margin: 0 auto; }
.resolved-section { margin-top: 2rem; }

.section-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.section-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.section-rule { flex: 1 1 auto; height: 1px; background: var(--line); }

/* ---------- triage card ---------- */
.tcard {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem 1.15rem;
  margin-bottom: 1.1rem;
  animation: rise .35s ease both;
}
.tcard.flagged { border-color: color-mix(in srgb, var(--warm) 55%, var(--line)); }
.tcard.leaving { animation: cardLeave .42s ease forwards; }
@keyframes cardLeave {
  to { opacity: 0; transform: translateY(-6px) scale(.98); }
}

.tcard-top {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.tcard-sender { font-weight: 700; font-size: 0.98rem; }
.tcard-route { font-size: 0.82rem; color: var(--muted); }
.tcard-route .chan {
  text-transform: capitalize;
}
.tcard-conf {
  margin-left: auto;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 999px;
  padding: 0.16rem 0.55rem;
  white-space: nowrap;
}

.tcard-msg {
  border-left: 3px solid var(--line);
  padding: 0.15rem 0 0.15rem 0.85rem;
  margin: 0 0 0.95rem;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--ink);
}

/* ---------- AI steps ---------- */
.tcard-steps {
  list-style: none;
  margin: 0 0 0.95rem;
  padding: 0;
}
.triaging {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--muted); font-size: 0.92rem; font-weight: 600;
}
.triaging .dots { display: inline-flex; gap: 4px; }
.triaging .dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: blink 1.1s infinite both;
}
.triaging .dots i:nth-child(2) { animation-delay: .18s; }
.triaging .dots i:nth-child(3) { animation-delay: .36s; }

.step {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.92rem;
  line-height: 1.4;
  padding: 0.18rem 0;
  color: var(--ink);
  opacity: 0;
  animation: stepIn .32s ease forwards;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: none; }
}
.step .tick {
  flex: 0 0 auto;
  width: 1.05rem; height: 1.05rem;
  margin-top: 0.08rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.step .step-text strong { font-weight: 700; }
.step .step-src { color: var(--muted); }

/* ---------- flag banner ---------- */
.tcard-flag {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--warm);
  background: color-mix(in srgb, var(--warm) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--warm) 40%, var(--line));
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  margin: 0 0 0.95rem;
  opacity: 0;
  animation: stepIn .32s ease forwards;
}
.tcard-flag .flag-mark {
  flex: 0 0 auto;
  font-size: 0.95rem;
  line-height: 1;
}

/* ---------- drafted reply ---------- */
.draft-wrap {
  opacity: 0;
  animation: rw .4s ease forwards;
}
.draft-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 0.45rem;
}
.draft-body {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  font-size: 0.96rem;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--ink);
}
.draft-edit {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.96rem;
  line-height: 1.55;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  resize: vertical;
  min-height: 7.5rem;
}
.draft-edit:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.draft-edited-tag {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-left: 0.5rem;
}

/* ---------- gate buttons ---------- */
.gate {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.9rem;
}
.gate-btn {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.05rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
  transition: transform .04s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.gate-btn:active { transform: translateY(1px); }
.gate-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gate-btn.approve { background: var(--accent); color: #fff; border-color: transparent; }
.gate-btn.approve:hover { background: var(--accent-ink); }
.gate-btn.edit:hover { border-color: var(--accent); color: var(--accent); }
.gate-btn.save { background: var(--accent); color: #fff; border-color: transparent; }
.gate-btn.save:hover { background: var(--accent-ink); }
.gate-btn.deny:hover { border-color: var(--warm); color: var(--warm); }
.gate-btn.cancel:hover { border-color: var(--muted); color: var(--muted); }
.gate-hint {
  align-self: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- resolved cards ---------- */
.rcard {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.7rem;
  font-size: 0.92rem;
  animation: rise .35s ease both;
}
.rcard .r-mark {
  flex: 0 0 auto;
  width: 1.3rem; height: 1.3rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: #fff;
}
.rcard.sent .r-mark { background: var(--accent); }
.rcard.denied .r-mark { background: var(--warm); }
.rcard .r-who { font-weight: 700; }
.rcard .r-summary { color: var(--muted); }
.rcard .r-status {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.rcard.sent .r-status { color: var(--accent); }
.rcard.denied .r-status { color: var(--warm); }
.rcard .r-by {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.queue-empty {
  font-size: 0.92rem;
  color: var(--muted);
  font-style: italic;
  padding: 0.4rem 0 0.6rem;
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .triage-app { grid-template-columns: 1fr; }
  .triage-aside {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 0.9rem 1rem;
  }
  .triage-aside .demo-aside-note { display: none; }
  .triage-aside .mt-block { margin-top: 1rem; }
  .triage-aside .source-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
  }
  .triage-aside .source { padding: 0.2rem 0; }
  .tcard-conf { margin-left: 0; }
  .gate-btn { flex: 1 1 auto; text-align: center; }
}
