/* chat_planner.css — embedded planner card inside an assistant chat bubble.
 * Reuses surface tokens from theme.css (--surface, --border, --fg) and the
 * chat-bubble layout in chat.css. Tuned to bubble width: ~180px chart, dense
 * stat strip, compact monospaced table. */

.chat-planner-card {
  margin-top: 0.5rem;
  padding: 0.875rem 1rem 0.75rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.75rem;
  background: var(--surface, #fff);
  box-shadow: var(--shadow-card, 0 1px 2px rgba(0, 0, 0, 0.04));
  font-variant-numeric: tabular-nums;
  max-width: 100%;
}

/* ── Stat strip ─────────────────────────────────────────── */

.chat-planner-card [data-cpc-stats] {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.cpc-tile {
  padding: 0.5rem 0.625rem;
  /* Faint tile bg so the eyebrow has its own contrast surface, not the same
   * grey as the surrounding card. Solid colour, not a token alias, so the
   * card isn't at the mercy of whatever the host theme defines. */
  background: #f5f5f5;
  border-radius: 0.5rem;
  min-width: 0;
}

.cpc-tile-eyebrow {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  /* Theme has no --muted token; --fg-2 (#666) gives ~5.7:1 on #f5f5f5,
   * the earlier #6b7280 fallback read as ghost-text. */
  color: var(--fg-2, #555);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cpc-tile-value {
  margin-top: 0.1875rem;
  font-size: 1rem;
  font-weight: 650;
  color: var(--fg, #111);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cpc-tile-sub {
  margin-top: 0.1875rem;
  font-size: 0.75rem;
  color: var(--fg-2, #555);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Chart ─────────────────────────────────────────────── */

.cpc-chart {
  position: relative;
  height: 180px;
  margin: 0 -0.25rem 0.5rem;
}

.cpc-chart canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Projection table ───────────────────────────────────── */

.chat-planner-card [data-cpc-table] {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  margin-bottom: 0.625rem;
}

.cpc-th {
  text-align: right;
  font-weight: 600;
  /* Same reason: --muted is undefined; force a readable secondary colour. */
  color: var(--fg-2, #555);
  font-size: 0.75rem;
  padding: 0.3125rem 0.375rem;
  border-bottom: 1px solid var(--border-strong, #d4d4d4);
  white-space: nowrap;
}

.cpc-th-year { text-align: left; }

.cpc-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  margin-right: 0.375rem;
  vertical-align: middle;
}

.cpc-td-year {
  text-align: left;
  padding: 0.3125rem 0.375rem;
  color: var(--fg-2, #555);
  font-weight: 600;
}

.cpc-td-num {
  text-align: right;
  padding: 0.25rem 0.375rem;
  color: var(--fg, #111);
  font-weight: 500;
}

.chat-planner-card [data-cpc-table] tr + tr td {
  border-top: 1px solid var(--border-faint, rgba(0, 0, 0, 0.04));
}

/* ── CTA ───────────────────────────────────────────────── */

.cpc-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--fg, #111);
  color: var(--surface, #fff);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.cpc-cta:hover { opacity: 0.85; }
.cpc-cta:focus-visible {
  outline: 2px solid var(--accent, #10b981);
  outline-offset: 2px;
}

/* ── Assumptions block ─────────────────────────────────── */
/* Surfaces the actual scenario inputs that produced the projection —
 * rentvest gets two side-by-side panels (PPR + Rentvest), goal gets one
 * panel per strategy with a property strategy's full input list expanded. */

.chat-planner-card [data-cpc-assumptions] {
  margin: 0.625rem 0 0.75rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border, #eaeaea);
}

.cpc-assumptions-title {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--fg-2, #555);
  margin-bottom: 0.625rem;
}

.cpc-asm-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.cpc-asm-col { min-width: 0; }

.cpc-asm-col-head {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--fg, #111);
  padding-bottom: 0.375rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border, #eaeaea);
}

.cpc-asm-col-sub {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--fg-2, #666);
}

.cpc-asm-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  padding: 0.1875rem 0;
}

.cpc-asm-key { color: var(--fg-2, #555); }
.cpc-asm-val { color: var(--fg, #111); font-weight: 600; white-space: nowrap; }

/* Globals strip — secondary inputs that aren't per-side */
.cpc-asm-globals {
  margin-top: 0.625rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border, #eaeaea);
  font-size: 0.75rem;
  color: var(--fg-2, #555);
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
}

.cpc-asm-globals strong {
  color: var(--fg, #111);
  font-weight: 650;
}

/* Goal-card flavour — strategies stacked, each in its own faint panel */
.cpc-strats {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 0.625rem;
}

.cpc-strat {
  padding: 0.5rem 0.625rem;
  background: #f5f5f5;
  border-radius: 0.5rem;
}

.cpc-strat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.cpc-strat-name {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--fg, #111);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.cpc-strat-rate {
  color: var(--fg-2, #555);
  font-weight: 600;
  white-space: nowrap;
}

.cpc-strat-details {
  margin: 0.4375rem 0 0;
  font-size: 0.75rem;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.75rem;
  row-gap: 0.1875rem;
}

.cpc-strat-details dt { color: var(--fg-2, #555); font-weight: 500; }
.cpc-strat-details dd {
  margin: 0;
  color: var(--fg, #111);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

/* Narrow bubbles — collapse to 2 columns on small screens */
@media (max-width: 480px) {
  .chat-planner-card [data-cpc-stats] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .chat-planner-card [data-cpc-stats] .cpc-tile:nth-child(3) {
    grid-column: 1 / -1;
  }
  .cpc-chart { height: 160px; }
  .cpc-asm-cols { grid-template-columns: 1fr; }
}
