/*
 * Shared styles for the in-browser WASM demo surfaces (Original preview +
 * A2UI streaming renderer). Used by both the homepage demo (index.html) and
 * the workbench (workbench.html). Anything that styles output produced by
 * docs/js/wasm-demo.js belongs here, not inline on a single page — that's
 * how we keep the two surfaces from drifting.
 *
 * Loaded after design-system.css so it can reference --dp-blue, --border,
 * --text-*, --bg-*, --radius-sm, --font-mono, --font-display, --success,
 * --success-bg, --dp-blue-faded, --dp-blue-border.
 */

/* ── A2UI streaming demo ────────────────────────────────────── */
.a2ui-demo { display: flex; flex-direction: column; gap: 0; }
.a2ui-label { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }

/* Rich document panel */
.a2ui-rich-doc { }
.a2ui-rich-doc h1, .a2ui-rich-doc h2, .a2ui-rich-doc h3,
.a2ui-rich-doc h4, .a2ui-rich-doc h5, .a2ui-rich-doc h6 {
  font-family: var(--font-display); color: var(--text-primary); margin: 0 0 8px; line-height: 1.3; letter-spacing: -0.3px;
}
.a2ui-rich-doc h1 { font-size: 24px; }
.a2ui-rich-doc h2 { font-size: 20px; }
.a2ui-rich-doc h3 { font-size: 17px; }
.a2ui-rich-doc h4 { font-size: 15px; }
.a2ui-rich-text { font-size: 14px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 8px; }
.a2ui-rich-text[data-style] { font-style: italic; color: var(--text-muted); font-size: 13px; }
.a2ui-rich-table-wrap { overflow-x: auto; margin-bottom: 12px; }
.a2ui-rich-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.a2ui-rich-table th { padding: 8px 12px; text-align: left; font-weight: 600; background: var(--dp-blue-faded); border: 1px solid var(--border); color: var(--text-primary); font-size: 12px; }
.a2ui-rich-table td { padding: 6px 12px; border: 1px solid var(--border); color: var(--text-secondary); }
.a2ui-rich-table tbody tr:hover { background: rgba(37,99,235,0.03); }
.a2ui-rich-list { margin: 0 0 12px 20px; padding: 0; font-size: 14px; color: var(--text-secondary); line-height: 1.7; }
.a2ui-rich-list li { margin-bottom: 2px; }
.a2ui-rich-callout { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 8px; }
.a2ui-rich-callout--insert { background: var(--success-bg); border-left: 3px solid var(--success); color: var(--success); }
.a2ui-rich-callout--delete { background: #fef2f2; border-left: 3px solid #ef4444; color: #ef4444; }
.a2ui-rich-callout-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 1px 6px; border-radius: 3px; background: rgba(0,0,0,0.08); }
.a2ui-rich-callout-meta { font-family: var(--font-mono); font-size: 10px; color: inherit; opacity: 0.7; }
.a2ui-rich-image { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(236,72,153,0.05); border: 1px dashed rgba(236,72,153,0.3); border-radius: 6px; color: #ec4899; font-size: 13px; margin-bottom: 8px; }
.a2ui-rich-media { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(168,85,247,0.05); border: 1px dashed rgba(168,85,247,0.3); border-radius: 6px; color: #a855f7; font-size: 13px; margin-bottom: 8px; }
.a2ui-rich-media-icon { font-size: 18px; }
.a2ui-rich-kv { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.a2ui-rich-kv-label { font-weight: 600; color: var(--text-primary); }
.a2ui-rich-doc hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Collapsible JSON panel */
.a2ui-json { border-top: 1px solid var(--border); margin-top: 8px; }
.a2ui-json-toggle { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: none; padding: 8px 0; cursor: pointer; font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-muted); transition: color 0.15s; }
.a2ui-json-toggle:hover { color: var(--dp-blue); }
.a2ui-json-toggle svg { transition: transform 0.2s; transform: rotate(-90deg); }
.a2ui-json-toggle.open svg { transform: rotate(0deg); }
.a2ui-json-badge { font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 3px; background: var(--dp-blue-faded); color: var(--dp-blue); }
.a2ui-json-content { max-height: 300px; overflow: auto; scrollbar-width: thin; }
.a2ui-json-content pre { margin: 0; font-family: var(--font-mono); font-size: 11px; line-height: 1.6; color: var(--text-secondary); white-space: pre-wrap; word-break: break-word; }

/* Streaming animation */
.a2ui-node--hidden { opacity: 0; transform: translateY(8px); }
.a2ui-demo--streaming .a2ui-node--hidden { animation: a2ui-nodeReveal 0.3s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes a2ui-nodeReveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Stream controls */
.a2ui-stream-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.a2ui-stream-header .a2ui-label { margin-bottom: 0; }
.a2ui-stream-controls { display: flex; gap: 6px; align-items: center; }
.a2ui-stream-status { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--dp-blue); padding: 2px 8px; border-radius: 4px; background: var(--dp-blue-faded); display: inline-flex; align-items: center; gap: 4px; }
.a2ui-stream-status.done { color: #059669; background: rgba(5,150,105,0.08); }
.a2ui-replay-btn { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--dp-blue); background: var(--dp-blue-faded); border: 1px solid var(--dp-blue-border); border-radius: 4px; padding: 2px 10px; cursor: pointer; transition: all 0.2s ease; }
.a2ui-replay-btn:hover { background: var(--dp-blue); color: #fff; transform: translateY(-1px); }
.a2ui-replay-btn:active { transform: translateY(0) scale(0.97); }
@media (prefers-reduced-motion: reduce) {
  .a2ui-demo--streaming .a2ui-node--hidden { animation: none !important; opacity: 1; transform: none; }
}

/* ── Original / preview pane ──────────────────────────────── */
.office-preview-page {
  background: #fff; padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 500px; overflow-y: auto;
  font-size: 14px; line-height: 1.7; color: var(--text-primary);
}
.office-preview-page img { max-width: 100%; height: auto; }
.office-preview-page table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.office-preview-page th, .office-preview-page td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; font-size: 13px; }
.office-preview-page th { background: var(--dp-blue-faded); font-weight: 600; }
.office-preview-note { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.office-preview-fallback { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }
.office-preview-text {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; max-height: 500px; overflow: auto;
}
.office-preview-text pre {
  margin: 0; font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  color: var(--text-primary); white-space: pre-wrap; word-break: break-word;
}
.office-preview-image {
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.office-preview-image img { max-width: 100%; max-height: 500px; }
.office-preview-pdf { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }

/* XLSX sheets */
.xlsx-sheet-tabs { display: flex; gap: 2px; margin-bottom: 12px; flex-wrap: wrap; }
.xlsx-sheet-tab {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 5px 14px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s;
}
.xlsx-sheet-tab:hover { border-color: var(--dp-blue-border); color: var(--dp-blue); }
.xlsx-sheet-tab.active { background: var(--dp-blue-faded); border-color: var(--dp-blue-border); color: var(--dp-blue); }
.xlsx-sheet-content { display: none; }
.xlsx-sheet-content.active { display: block; }
.xlsx-table-wrap { overflow-x: auto; }
.xlsx-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.xlsx-table th, .xlsx-table td { padding: 5px 10px; border: 1px solid var(--border); text-align: left; }
.xlsx-table th { background: var(--dp-blue-faded); font-weight: 600; font-size: 11px; }
.xlsx-table tbody tr:hover { background: rgba(37, 99, 235, 0.02); }
.xlsx-sheet-name { font-family: var(--font-display); font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }

/* PPTX slides */
.pptx-slides { display: flex; flex-direction: column; gap: 16px; }
.pptx-slide { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.pptx-slide-number {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 6px 14px; background: var(--bg-input);
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.pptx-slide-content { padding: 16px 20px; }
.pptx-slide-content h1, .pptx-slide-content h2, .pptx-slide-content h3, .pptx-slide-content h4 {
  font-family: var(--font-display); margin: 0 0 8px; color: var(--text-primary);
}
.pptx-slide-content p { margin: 0 0 6px; font-size: 14px; color: var(--text-secondary); line-height: 1.6; }
.pptx-slide-content ul, .pptx-slide-content ol { margin: 0 0 8px 20px; font-size: 14px; color: var(--text-secondary); }
