/* Vista «como en Town». Tokens y medidas portados de porter-agents-web: theme/mockup.css (:root[data-ui='v2']),
   theme/global.css (.rich-text), features/channel/MessageItem.module.css (overrides v2) y
   features/agent-cards/AgentCards.module.css. Todo va bajo .tv para no tocar el resto de la plataforma. */
/* Inter variable (@fontsource-variable/inter 5.2.8, la de Town; licencia OFL), servida desde /app/fonts. */
@font-face { font-family: 'Inter Variable'; font-style: normal; font-display: swap; font-weight: 100 900; src: url('/app/fonts/inter-latin-wght-normal.woff2') format('woff2-variations'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter Variable'; font-style: normal; font-display: swap; font-weight: 100 900; src: url('/app/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
.tv {
  --bg: #fbfbfa; --surface: #ffffff; --surface-2: #f4f4f2; --surface-3: #ececE9;
  --text: #18181b; --text-2: #52525b; --text-3: #8a8a93;
  --border: #dfdfda; --border-strong: #c8c8c1;
  --accent: #4f46e5; --accent-soft: #eef0ff; --accent-text: #3730a3;
  --ok: #0f8a5f; --ok-soft: #e6f6ef; --warn: #b45309; --warn-soft: #fef3e2; --danger: #c0262d;
  --glow-a: #6366f1; --glow-b: #c084fc;
  --r: 12px;
  --color-code-text: #c01343; --color-code-bg: rgba(192, 19, 67, 0.04); --color-code-border: rgba(192, 19, 67, 0.13);
  --color-quote-bar: #dddddd; --color-border-tertiary: #5e5d6021; --color-bg-tertiary: #eaeaea; --color-bg-hover: #4544470f;
  background: var(--surface);
  color: var(--text);
  font: 14.5px/1.5 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  border-radius: var(--r);
  padding: 6px 0;
}
@media (prefers-color-scheme: dark) {
  .tv {
    --bg: #0e0e10; --surface: #161618; --surface-2: #1d1d20; --surface-3: #26262a;
    --text: #f4f4f5; --text-2: #b4b4bc; --text-3: #7c7c86;
    --border: #2c2c31; --border-strong: #3e3e45;
    --accent: #8b85ff; --accent-soft: #23214a; --accent-text: #c7c4ff;
    --ok: #3dd39b; --ok-soft: #10291f; --warn: #f5b454; --warn-soft: #2e2210; --danger: #ff6b6b;
    --color-code-bg: rgba(255, 129, 170, 0.08); --color-code-border: rgba(255, 129, 170, 0.2); --color-code-text: #ff81aa;
    --color-quote-bar: #3e3e45; --color-border-tertiary: #2c2c31; --color-bg-tertiary: #26262a; --color-bg-hover: #ffffff0a;
  }
}
.tv-day { display: flex; align-items: center; gap: 10px; margin: 14px 14px 6px; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: capitalize; }
.tv-day::before, .tv-day::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.tv-msg { display: flex; gap: 10px; padding: 6px 14px; transition: background 150ms; }
.tv-msg:hover { background: var(--surface-2); }
.tv-error { box-shadow: inset 3px 0 0 var(--danger); }
.tv-gutter { display: flex; justify-content: center; flex: none; width: 34px; }
.tv-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #0ea5e9; color: #fff; font-weight: 700; font-size: 14px; }
.tv-avatar-porter { background: linear-gradient(135deg, var(--glow-a), var(--glow-b)); border-radius: 28%; }
.tv-content { flex: 1; min-width: 0; }
.tv-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; line-height: 1.5; }
.tv-author { font-weight: 700; font-size: 14px; color: var(--text); }
.tv-time { font-size: 11.5px; color: var(--text-3); }
.tv-edited { font-size: 12px; color: var(--text-3); }
.tv-pill { white-space: nowrap; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.tv-pill-bad { background: #ffe8ef; color: var(--danger); }
.tv-system { color: var(--text-3); font-size: 13px; }
.tv-system .rich-text { display: inline; }
.tv-body > * + * { margin-top: 6px; }

/* .rich-text de Town (theme/global.css) */
.tv .rich-text { overflow-wrap: anywhere; }
.tv .rich-text p { margin: 0; }
.tv .rich-text p + p { margin-top: 4px; }
.tv .rich-text h1, .tv .rich-text h2, .tv .rich-text h3, .tv .rich-text h4, .tv .rich-text h5, .tv .rich-text h6 { margin: 1em 0 4px; font-size: 15px; line-height: 22px; font-weight: 900; font-family: inherit; color: var(--text); }
.tv .rich-text h1 { font-size: 22px; line-height: 30px; }
.tv .rich-text h2 { font-size: 18px; line-height: 24px; }
.tv .rich-text > :first-child:is(h1, h2, h3, h4, h5, h6) { margin-top: 0; }
.tv .rich-text ul, .tv .rich-text ol { margin: 4px 0; padding-left: 0; }
.tv .rich-text li { margin-left: 20px; padding-left: 8px; }
.tv .rich-text li > ul, .tv .rich-text li > ol { margin: 0; }
.tv .rich-text blockquote { position: relative; margin: 4px 0; padding-left: 16px; }
.tv .rich-text blockquote::before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 4px; border-radius: 8px; background: var(--color-quote-bar); }
.tv .rich-text code { font-family: 'Roboto Mono', Monaco, Menlo, monospace; font-size: 12px; line-height: 18px; color: var(--color-code-text); background: var(--color-code-bg); border: 1px solid var(--color-code-border); border-radius: 3px; padding: 2px 3px 1px; }
.tv .rich-text pre { margin: 4px 0 16px; padding: 8px; background: var(--color-code-bg); border: 1px solid var(--color-code-border); border-radius: 4px; white-space: pre-wrap; font-family: 'Roboto Mono', Monaco, Menlo, monospace; font-size: 12px; line-height: 18px; }
.tv .rich-text pre code { color: var(--text); background: none; border: 0; padding: 0; }
.tv .rich-text a { color: var(--accent); }
.tv .rich-text a:hover { text-decoration: underline; }
.tv .rich-text .table-wrap { max-width: 100%; margin: 4px 0 8px; overflow-x: auto; }
.tv .rich-text table { border-collapse: collapse; font-size: 13px; line-height: 18px; }
.tv .rich-text th, .tv .rich-text td { padding: 6px 10px; border: 1px solid var(--color-border-tertiary); text-align: left; vertical-align: top; min-width: 64px; max-width: 360px; }
.tv .rich-text th { font-weight: 700; background: var(--color-bg-tertiary); white-space: nowrap; }
.tv .rich-text tbody tr:nth-child(even) td { background: var(--color-bg-hover); }
.tv .mention { padding: 0 2px; border-radius: 3px; background: var(--accent-soft); color: var(--accent-text); font-weight: 500; }
.tv .channel-ref { color: var(--accent); }

/* Pasos del agente (theme/mockup.css .steps) */
.tv .steps { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); overflow: hidden; margin: 4px 0 10px; max-width: 640px; }
.tv .steps-h { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; font-size: 13px; color: var(--text-2); background: none; border: 0; cursor: pointer; font: inherit; font-size: 13px; }
.tv .steps-h .chev { margin-left: auto; transition: transform 250ms; }
.tv .steps.closed .chev { transform: rotate(-90deg); }
.tv .steps.closed .steps-l { display: none; }
.tv .steps-l { list-style: none; margin: 0; padding: 0 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.tv .step { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.tv .step .st { width: 16px; height: 16px; flex: none; display: grid; place-items: center; }
.tv .check { color: var(--ok); }
.tv .st.bad, .tv .step-bad { color: var(--danger); }
.tv .step code { font-size: 12px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; color: var(--text-2); }

/* Bloques y tarjetas (AgentBlocks / AgentCards) */
.tv-block { max-width: 760px; }
.tv-block-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.tv-context { font-size: 12.5px; color: var(--text-3); }
.tv-divider { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.tv-fields { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 4px 0; font-size: 13px; }
.tv-fields dt { color: var(--text-3); }
.tv-fields dd { margin: 0; }
.tv-chart svg { max-width: 640px; color: var(--text-2); }
.tv-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; }
.tv-callout { padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; max-width: 640px; }
.tv-callout[data-tone='warning'] { background: var(--warn-soft); color: var(--warn); }
.tv-callout[data-tone='success'] { background: var(--ok-soft); color: var(--ok); }
.tv-callout[data-tone='error'] { background: #ffe8ef; color: var(--danger); }
.tv-card { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; max-width: 560px; background: var(--surface); }
.tv-card[data-state='connected'], .tv-card[data-state='launched'], .tv-card[data-state='approved'], .tv-card[data-state='executed'] { border-left-color: var(--ok); }
.tv-card[data-state='error'], .tv-card[data-state='failed'], .tv-card[data-state='rejected'] { border-left-color: var(--danger); }
.tv-card[data-state='blocked'], .tv-card[data-state='expired'] { border-left-color: var(--text-3); }
.tv-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tv-card-title { font-weight: 600; }
.tv-badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.tv-meta { font-size: 13px; color: var(--text-2); margin: 0; }
.tv-carousel { display: flex; gap: 8px; overflow-x: auto; }
.tv-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tv-btn { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text); background: var(--surface); cursor: default; }
.tv-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tv-btn.danger { color: var(--danger); border-color: var(--danger); }

/* Adjuntos (MessageItem.module.css .file) */
.tv-files { display: flex; flex-wrap: wrap; gap: 8px; }
.tv-file { display: flex; align-items: center; gap: 12px; width: min(360px, 100%); height: 56px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); }
.tv-file-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); font-size: 16px; }
.tv-file-meta { display: flex; flex-direction: column; min-width: 0; }
.tv-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 14px; line-height: 20px; }
.tv-file-size { font-size: 12px; color: var(--text-2); }
.tv-failed { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--danger); }
.tv-link { color: var(--accent); }
.conv-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.conv-toggle button { border: 0; background: var(--bg); padding: 5px 12px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--text-2); }
.conv-toggle button.on { background: var(--plum-70); color: #fff; }
.tv-agent { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-text); }
.tv-pill-warn { background: var(--warn-soft); color: var(--warn); }
.tv-grouped { padding-top: 1px; padding-bottom: 6px; }
.tv-hover-time { visibility: hidden; padding-top: 4px; font-size: 10.5px; color: var(--text-3); text-align: center; }
.tv-msg:hover .tv-hover-time { visibility: visible; }
