/* Trace Virtual CFO — chat agent UI.
   Brand alignment per apps/bingo-ui/BRAND.md:
   - Surfaces: page #1c1c1f, card #191919, border #e3e2e2/10
   - Identity: lime #BFFF00; solid lime fg #162A16 for AA contrast
   - Type: Geist (sans), Geist Mono (caption)
   - Buttons: pill (rounded-full); solid lime recipe; cta-hover-glow-lime
*/

:root {
  --bg: #1c1c1f;
  --bg-card: #191919;
  --bg-card-2: #232327;
  --fg: #fafafa;
  --fg-muted: #a3a3a3;
  --border: rgba(227, 226, 226, 0.1);
  --border-strong: rgba(227, 226, 226, 0.18);

  --lime: #bfff00;
  --lime-fg: #162a16;
  --lime-tint-bg: rgba(191, 255, 0, 0.12);
  --lime-tint-border: rgba(191, 255, 0, 0.4);

  --error: #ff6b6b;
  --radius: 12px;

  --font-sans: "Geist", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Funnel Display", "Geist", ui-sans-serif, -apple-system, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* Display class: matches brand `display-1` recipe (font-display, weight 700, tracking-tight) */
.display-1 {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.display-title {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.025em;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 4px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

img.brand-mark {
  height: clamp(14px, 2.5vw, 18px);
  width: auto;
  display: block;
}

/* "Virtual CFO" tagline — display-2 per BRAND.md (Funnel Display, 22-28px fluid, 700, tracking-tight) */
.brand-sub {
  font-family: var(--font-display);
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--fg-muted);
}

#session-info {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}

.badge.muted {
  color: var(--fg-muted);
}

/* ---------- Main + auth ---------- */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 0;
}

#auth-pane {
  display: grid;
  place-items: center;
  min-height: 50vh;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 440px;
  width: 100%;
}

.auth-card h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.auth-card p {
  color: var(--fg-muted);
  margin: 0 0 18px;
  font-size: 14px;
}

.auth-card input,
#composer textarea {
  background: var(--bg-card-2);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.auth-card input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.auth-card input:focus,
#composer textarea:focus {
  outline: none;
  border-color: var(--lime);
  box-shadow: 0 0 0 3px var(--lime-tint-bg);
}

/* ---------- PillButton (solid lime recipe) ----------
   Brand says: solid lime bg, #162A16 fg. lg = px-6 py-3 text-base, rounded-full.
   Hover gets `cta-hover-glow-lime` box-shadow per brand recipe.
*/

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.18s ease, transform 0.08s ease;
  text-decoration: none;
  white-space: nowrap;
}

.pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Sizes per brand matrix */
.pill-md {
  padding: 10px 20px;
  font-size: 13px;
}
.pill-lg {
  padding: 12px 24px;
  font-size: 14px;
}

/* Variants */
.pill-solid-lime {
  background: var(--lime);
  color: var(--lime-fg);
}
.pill-solid-lime:hover:not(:disabled) {
  background: var(--lime);
  box-shadow: 0 0 22px rgba(191, 255, 0, 0.35);
}
.pill-solid-lime:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 0 14px rgba(191, 255, 0, 0.25);
}
.pill-solid-lime:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}

.pill-tinted-lime {
  background: var(--lime-tint-bg);
  border-color: var(--lime-tint-border);
  color: var(--lime);
}
.pill-tinted-lime:hover:not(:disabled) {
  background: rgba(191, 255, 0, 0.18);
}

/* Full-width variant for primary CTAs in cards */
.pill-block {
  width: 100%;
}

/* ---------- Chat pane ---------- */

#chat-pane {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

#messages {
  display: flex;
  flex-direction: column;
  min-height: 200px;
  padding-bottom: 8px;
}

/* ---------- CommentRow (ported from bingo-ui/feed/CommentRow.tsx) ---------- */

.comment {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child {
  border-bottom: 0;
}

.comment-avatar-col {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.4);
  transform-origin: center;
}

.comment-avatar-initial {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--fg);
  background: rgba(191, 255, 0, 0.10);
  color: var(--lime);
}

.comment-content {
  flex: 1;
  min-width: 0; /* allow body overflow handling */
}

.comment-byline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.3;
  margin-bottom: 4px;
}

.comment-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
}

.comment-firm {
  font-size: 13px;
  color: var(--fg-muted);
}

.comment-firm::before {
  content: "·";
  margin: 0 4px;
  color: var(--fg-muted);
}

/* Lime "YOU" pill — solid lime per CommentRow recipe */
.comment-you {
  background: var(--lime);
  color: var(--lime-fg);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  font-family: var(--font-sans);
}

/* Subtle "Virtual CFO" verified-style chip for the agent */
.comment-verified {
  background: var(--lime-tint-bg);
  border: 1px solid var(--lime-tint-border);
  color: var(--lime);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
}

.comment-dot {
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1;
}

.comment-time {
  font-size: 12px;
  color: var(--fg-muted);
}

.comment-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg);
  white-space: normal;
  word-wrap: break-word;
}

.comment-body p:first-child { margin-top: 0; }
.comment-body p:last-child { margin-bottom: 0; }

.comment.error .comment-body {
  color: var(--error);
}

.comment-body code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.comment-body pre {
  background: rgba(0, 0, 0, 0.35);
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.comment-body pre code {
  background: transparent;
  padding: 0;
}

.comment-body table {
  border-collapse: collapse;
  margin: 10px 0;
  width: 100%;
  font-size: 13.5px;
}

.comment-body th,
.comment-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.comment-body th {
  background: var(--bg-card-2);
  font-weight: 600;
}

.comment-body a {
  color: var(--lime);
  text-decoration: none;
  border-bottom: 1px solid var(--lime-tint-border);
}

.comment-body a:hover {
  border-bottom-color: var(--lime);
}

.comment-body ul,
.comment-body ol {
  padding-left: 1.4em;
  margin: 8px 0;
}

.cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--lime);
  margin-left: 2px;
  animation: blink 0.9s step-end infinite;
  vertical-align: text-bottom;
  box-shadow: 0 0 6px rgba(191, 255, 0, 0.45);
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- Composer ---------- */

#composer {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

#composer textarea {
  flex: 1;
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 70px;
}

#composer .pill {
  flex: 0 0 auto;
}

#status {
  min-height: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* CSS-only spinner ring — lime accent on dark base */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Inline soft hint inside the assistant message bubble on first request */
.first-load-hint {
  display: inline;
  color: var(--fg-muted);
  font-size: 13px;
  font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--lime);
  }
}

.muted {
  color: var(--fg-muted);
}
.small {
  font-size: 12px;
}

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--border);
  padding: 16px 4px;
  text-align: center;
}

footer .muted {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none;
  }
  .pill {
    transition: none;
  }
}
