/* ============================================================
   Otonoma Goal Tree + No-App-App (NAA) phone components.
   Goal Tree tokens/rules ported from bd/goal-tree-style-guide.html
   (Figma "Otonoma Brand Library" → Goal Tree). Light mode only to
   match the site. Exact brand hex values preserved.
   ============================================================ */

.gt {
  /* status flags — fixed brand accents */
  --flag-default: #ADAAAA;   /* grey   · default / deactivated */
  --flag-waiting: #0099FF;   /* blue   · waiting               */
  --flag-complete: #75C964;  /* green  · complete              */
  --flag-alert: #F26522;     /* orange · alert                 */

  --gt-surface: #FFFFFF;
  --gt-stroke: #D9D9D9;
  --gt-text: #1E1E1E;
  --gt-alt-text: #535252;
  --gt-connector: #ADAAAA;
  --gt-flow: #4DA3FF;        /* live connector — matches the deck's path stroke */
  --gt-node-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);

  /* status pill colors (light mode) */
  --status-inprogress-fg: #003D6B; --status-inprogress-bg: #E6EFFD;
  --status-error-fg: #BA1A1A;      --status-error-bg: #FDEAE8;
  --status-completed-fg: #00391A;  --status-completed-bg: #D6F6DD;
  --status-canceled-fg: #535252;   --status-canceled-bg: rgba(217,217,217,.5);
}

/* ---------- Node ---------- */
.node {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--gt-surface);
  border: 1px solid var(--gt-stroke);
  border-radius: 10px;
  box-shadow: var(--gt-node-shadow);
  padding: 10px 14px 10px 10px;
  min-width: 240px;
  position: relative;
  text-align: left;
}
.node.wide { min-width: 320px; }
.node.auto { min-width: 0; }

.node .icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
}
.node .body { min-width: 0; }
.node .title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gt-text);
  line-height: 1.2;
}
.node .detail {
  font-size: 12px;
  font-weight: 400;
  color: var(--gt-alt-text);
  line-height: 1.3;
  margin-top: 2px;
}

/* status-flag colored icon squares */
.icon.flag-default { background: var(--flag-default); }
.icon.flag-waiting { background: var(--flag-waiting); }
.icon.flag-complete { background: var(--flag-complete); }
.icon.flag-alert { background: var(--flag-alert); }

/* connection ports */
.node .port {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--flag-default);
}
.node .port.top { top: -6px; }
.node .port.bottom { bottom: -6px; }
.node .port.black { border-color: var(--gt-text); }

/* alert/HIL callout tag on a node */
.node .tag {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--flag-alert);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  box-shadow: var(--gt-node-shadow);
}

/* ---------- Status pill ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  padding: 5px 14px;
  line-height: 1;
}
.pill.inprogress { color: var(--status-inprogress-fg); background: var(--status-inprogress-bg); }
.pill.error { color: var(--status-error-fg); background: var(--status-error-bg); }
.pill.completed { color: var(--status-completed-fg); background: var(--status-completed-bg); }
.pill.canceled { color: var(--status-canceled-fg); background: var(--status-canceled-bg); }
.pill.alert { color: #fff; background: var(--flag-alert); }

/* ---------- Vertical flow ---------- */
.flow {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
  align-items: center;
}
.flow .node { min-width: 300px; }
/* Live connector: flowing dashes travelling toward the goal. Mirrors the
   deck's `stroke-dasharray: 11 9` + animated dash-offset (bd
   travel-products/virtuoso/goal-tree.js) using a gradient, so no SVG is
   needed for these straight vertical runs. */
.flow .connector {
  width: 3px;
  height: 26px;
  position: relative;
  overflow: hidden;
}
/* The dashes live on a taller inner strip translated by exactly one dash
   period (20px), so the loop is seamless. Like the deck, direction is shown
   by the travelling dashes themselves — no arrowheads. */
.flow .connector::before {
  content: '';
  position: absolute;
  left: 0;
  top: -20px;
  width: 3px;
  height: calc(100% + 40px);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--gt-flow) 0 11px,
    transparent 11px 20px);
  animation: gtFlow 1.15s linear infinite;
}
@keyframes gtFlow { to { transform: translateY(20px); } }

/* Staggered "cascade" ring — the network sweeping the tree. */
.flow .node { animation: gtCascade 3.6s ease-in-out infinite; }
.flow .node:nth-child(1) { animation-delay: 0s; }
.flow .node:nth-child(3) { animation-delay: .45s; }
.flow .node:nth-child(5) { animation-delay: .9s; }
.flow .node:nth-child(7) { animation-delay: 1.35s; }
.flow .node:nth-child(9) { animation-delay: 1.8s; }
.flow .node:nth-child(11) { animation-delay: 2.25s; }
@keyframes gtCascade {
  0%, 18%, 100% { box-shadow: var(--gt-node-shadow); }
  8% { box-shadow: var(--gt-node-shadow), 0 0 0 6px rgba(0,153,255,.22); }
}

/* Alert nodes pulse an expanding orange ring until they are resolved. */
.flow .node:has(.icon.flag-alert) {
  animation: gtAlertRing 1.6s ease-out infinite;
}
@keyframes gtAlertRing {
  0% { box-shadow: var(--gt-node-shadow), 0 0 0 2px rgba(242,101,34,.55); }
  100% { box-shadow: var(--gt-node-shadow), 0 0 0 18px rgba(242,101,34,0); }
}

/* Live indicator usable beside a tree caption. */
.gt-live {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--flag-complete);
  animation: gtLiveDot 1.6s ease-in-out infinite;
}
@keyframes gtLiveDot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(117,201,100,.5); }
  50% { box-shadow: 0 0 0 7px rgba(117,201,100,0); }
}

/* Respect a reduced-motion preference: hold the finished state. */
@media (prefers-reduced-motion: reduce) {
  .flow .connector::before,
  .flow .node,
  .flow .node:has(.icon.flag-alert),
  .gt-live {
    animation: none;
  }
  .flow .connector::before {
    background-image: linear-gradient(var(--gt-flow), var(--gt-flow));
  }
}

/* legend row for the status flags */
.gt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  font-size: 0.9rem;
  color: var(--gt-alt-text);
}
.gt-legend span { display: inline-flex; align-items: center; gap: 8px; }
.gt-legend .dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* Goal tree surface panel */
.gt-panel {
  background: #EFF2F4;
  border: 1px solid var(--gt-stroke);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  justify-content: center;
}

/* ============================================================
   RICH-MESSAGING PHONE — unbranded, Otonoma blue.
   Ships as a static thread; js/rich-messaging.js replays it when
   present. Vocabulary adapted from
   bd/travel-products/virtuoso/naa-phone.js, re-tinted, with no
   customer branding and no named advisor.
   ============================================================ */
.naa-phone {
  --naa-accent: #0162C5;      /* Otonoma brand blue */
  --naa-accent-deep: #142866; /* navy */
  width: 320px;
  max-width: 100%;
  height: 660px;
  background: #0c0f16;
  border-radius: 52px;
  padding: 12px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 30px 55px rgba(8,12,20,.35), inset 0 0 0 2px #23262e;
  position: relative;
  font-family: var(--font, 'Roboto', sans-serif);
  flex: 0 0 auto;
}
.naa-phone .island {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 28px;
  background: #000;
  border-radius: 16px;
  z-index: 5;
}
.naa-phone .screen {
  width: 100%;
  height: 100%;
  border-radius: 42px;
  overflow: hidden;
  background: #EEF1F5;
  display: flex;
  flex-direction: column;
  color: #15110F;
}
.naa-phone .statusbar {
  height: 50px;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 24px 8px;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
}
.naa-phone .head {
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 11px;
  border-bottom: 1px solid #E6E9EF;
  flex: 0 0 auto;
}
.naa-phone .head .back { color: var(--naa-accent); font-size: 22px; line-height: 1; }
.naa-phone .head .av {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--naa-accent-deep);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.naa-phone .head .nm { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.naa-phone .head .nm b { color: var(--naa-accent); font-size: 11px; }
.naa-phone .head .sub { font-size: 10.5px; color: #8C919B; margin-top: 1px; }

.naa-phone .strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 11.5px;
  font-weight: 700;
  flex: 0 0 auto;
  border-bottom: 1px solid #E6E9EF;
}
.naa-phone .strip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.naa-phone .strip.ok { background: #E6F5EC; color: #1F9D57; }
.naa-phone .strip.watch { background: #FFF2DD; color: #C2790F; }

.naa-phone .area {
  flex: 1;
  overflow-y: auto;
  padding: 13px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.naa-phone .area::-webkit-scrollbar { width: 0; }
.naa-phone .date { text-align: center; font-size: 10.5px; color: #AEB4BD; margin: 2px 0; }
.naa-phone .sys {
  text-align: center;
  font-size: 10.5px;
  color: #8C919B;
  background: #fff;
  border-radius: 10px;
  padding: 6px 13px;
  margin: 3px auto;
  max-width: 250px;
  box-shadow: 0 1px 3px rgba(13,18,28,.08);
}
.naa-phone .row { display: flex; flex-direction: column; }
.naa-phone .row.user { align-items: flex-end; }
.naa-phone .advn {
  font-size: 10px;
  font-weight: 800;
  color: var(--naa-accent);
  margin: 0 0 2px 4px;
  letter-spacing: .3px;
}
.naa-phone .bub { padding: 9px 13px; font-size: 13px; line-height: 1.42; max-width: 86%; }
.naa-phone .bub.biz { background: #fff; border-radius: 4px 15px 15px 15px; box-shadow: 0 1px 3px rgba(13,18,28,.08); }
.naa-phone .bub.user { background: var(--naa-accent); color: #fff; border-radius: 15px 15px 4px 15px; }
.naa-phone .bub.alert { background: #FFF2DD; border-radius: 8px; border-left: 3px solid var(--flag-alert, #F26522); box-shadow: 0 1px 3px rgba(13,18,28,.08); }
.naa-phone .bub.alert b { color: #C2790F; }
.naa-phone .bub b { color: inherit; }

/* rich card inside the thread */
.naa-phone .rcard {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(13,18,28,.10);
  max-width: 92%;
}
.naa-phone .rcard .banner {
  background: linear-gradient(140deg, #1e5fa8, #0d2f57);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.naa-phone .rcard .banner .ic { font-size: 20px; }
.naa-phone .rcard .banner .lbl { font-size: 11px; font-weight: 700; opacity: .9; }
.naa-phone .rcard .banner .badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: rgba(255,255,255,.18);
  padding: 3px 8px;
  border-radius: 999px;
}
.naa-phone .rcard .rbody { padding: 11px 14px 13px; }
.naa-phone .rcard .rtitle { font-size: 13.5px; font-weight: 700; }
.naa-phone .rcard .rsub { font-size: 11.5px; color: #8C919B; margin-top: 2px; }
.naa-phone .rcard .rdesc { font-size: 12px; margin-top: 8px; line-height: 1.4; }
.naa-phone .rcard .ract {
  margin-top: 11px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--naa-accent);
  border: 1px solid #D6DEEA;
  border-radius: 8px;
  padding: 7px 12px;
}

/* focus-page layout helpers */
.focus-split {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 48px;
  align-items: center;
}
@media (max-width: 860px) {
  .focus-split { grid-template-columns: 1fr; justify-items: center; gap: 32px; }
}
.compiled-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media (max-width: 720px) { .compiled-stats { grid-template-columns: repeat(2, 1fr); } }
.compiled-stats .stat-tile { text-align: center; padding: 8px 4px; }
.compiled-stats .stat-tile .n { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 700; color: #0162C5; line-height: 1.1; }
.compiled-stats .stat-tile .l { font-size: 0.9rem; color: var(--muted, #555); margin-top: 6px; }

/* ---------- Animated thread (js/rich-messaging.js) ---------- */

/* Items start hidden only once the script takes over; without JS the whole
   conversation renders normally. */
.naa-phone .rm-hidden { display: none !important; }

.naa-phone .area > *:not(.rm-hidden) {
  animation: rmIn .32s ease-out both;
}
@keyframes rmIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Typing indicator — three bouncing dots in an advisor-shaped bubble. */
.naa-phone .typing {
  align-self: flex-start;
  background: #fff;
  border-radius: 4px 15px 15px 15px;
  padding: 11px 14px;
  display: flex;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(13,18,28,.10);
  width: fit-content;
  flex-shrink: 0;
}
.naa-phone .typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #B4BAC4;
  animation: rmTypeBounce 1.2s infinite;
}
.naa-phone .typing i:nth-child(2) { animation-delay: .2s; }
.naa-phone .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes rmTypeBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* The header strip animates as the network re-plans. */
.naa-phone .strip { transition: background .35s ease, color .35s ease; }
.naa-phone .strip.watch .dot { animation: rmBlip 1s infinite; }
@keyframes rmBlip {
  0% { box-shadow: 0 0 0 0 rgba(194,121,15,.5); }
  100% { box-shadow: 0 0 0 8px rgba(194,121,15,0); }
}

@media (prefers-reduced-motion: reduce) {
  .naa-phone .area > * { animation: none; }
  .naa-phone .strip.watch .dot { animation: none; }
}
