/* Document Editor live demo (homepage + /product/editor).
   Paired with static/js/editor_live_demo.js and templates/_editor_demo.html.
   Colours and class names follow the product's editor stylesheet. */
/* ==========================================================
   DOCUMENT EDITOR LIVE DEMO (#editor)
   Class names and colours follow the product's editor stylesheet:
   accent #2563eb, toolbar #f1f5f9, borders #e2e8f0, text #0f172a,
   chat panel #f8fafc, redlines .chat-insertion / .chat-deletion.
   Designed at a fixed width and scaled to the column by JS.
   A copy of this block lives in the session patch; keep it here.
   ========================================================== */
/* Slot used by /product/editor. A grid item defaults to min-width:auto, so the
   demo's 440px design width pushed the column past the phone viewport. */
.editor-demo-slot {
    min-width: 0;
    max-width: 100%;
}

.ed-demo {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-frame);
    background: #fff;
    transition: opacity 0.6s ease;
    --ed-w: 760px;
    --ed-h: 540px;
}
.ed-demo.ed-fade { opacity: 0; }
.ed-stage {
    position: relative;
    width: var(--ed-w);
    height: var(--ed-h);
    transform-origin: top left;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    color: #0f172a;
    font-size: 12px;
    line-height: 1.45;
    overflow: hidden;
    background: #fff;
}
.ed-stage i { font-style: normal; }
.ed-stage .is-pressed { transform: scale(0.96); filter: brightness(0.92); }

/* Tab bar (product: 50px bar, 36px controls, tab vertically centred) */
.ed-tabbar {
    display: flex; align-items: center; gap: 8px;
    height: 46px; padding: 0 10px;
    background: #f1f5f9; border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.ed-ctl {
    display: inline-flex; align-items: center; justify-content: center; gap: 2px;
    min-width: 32px; height: 32px; padding: 0 9px;
    background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 12px;
}
.ed-ctl .ed-chev { font-size: 7px; }
.ed-tab {
    display: inline-flex; align-items: center;
    height: 32px; padding: 0 10px; min-width: 150px; max-width: 200px;
    background: #2563eb; color: #fff; border: 1px solid #2563eb; border-radius: 6px 6px 0 0;
    font-size: 12px;
}
.ed-tab-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 8px; }
.ed-tab-input {
    flex: 1; min-width: 0; height: 22px; margin-right: 8px; padding: 0 6px;
    background: #fff; color: #0f172a; border: 1px solid #bfdbfe; border-radius: 4px; font-size: 12px; line-height: 20px;
    white-space: nowrap; overflow: hidden;
}
.ed-tab-input.typing::after { content: ''; display: inline-block; width: 1px; height: 12px; background: #0f172a; margin-left: 1px; vertical-align: -2px; animation: edCaret 0.9s steps(2) infinite; }
.ed-tab-btn { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 3px; font-size: 10px; opacity: 0.75; }
.ed-tab-btn.ed-rename { margin-right: 2px; }
.ed-spacer { flex: 1; }
.ed-save-status { font-size: 11px; font-weight: 500; color: #0f172a; opacity: 0.6; white-space: nowrap; }
.ed-save-status.saving { opacity: 0.45; }
.ed-save, .ed-export {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 11px; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.ed-save { background: #34c759; color: #fff; }
.ed-export-wrap { position: relative; }
.ed-export { background: rgba(0, 122, 255, 0.1); border: 1px solid rgba(0, 122, 255, 0.2); color: #007aff; }
.ed-export .ed-chev { font-size: 8px; margin-left: 2px; }
.ed-export-menu {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 20;
    min-width: 168px; padding: 4px 0;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    opacity: 0; visibility: hidden; transform: translateY(-4px) scale(0.95);
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s;
}
.ed-export-menu.open { opacity: 1; visibility: visible; transform: none; }
.ed-export-option { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 12px; color: #0f172a; white-space: nowrap; }
.ed-export-option i { width: 14px; text-align: center; color: #64748b; }
.ed-export-option.ed-word i { color: #2b579a; }
.ed-export-option.ed-pdf i { color: #d93025; }
.ed-export-option.is-pressed { background: #f1f5f9; transform: none; }

/* Notification (product: .notification-success, top right) */
.ed-notice {
    position: absolute; top: 56px; right: 12px; z-index: 30;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
    background: #d4edda; color: #155724; border: 1px solid #c3e6cb; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0; transform: translateX(24px); transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none;
}
.ed-notice.show { opacity: 1; transform: none; }

/* Body split */
.ed-body { display: flex; flex: 1; min-height: 0; }
.ed-editor { flex: 1; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid #e2e8f0; position: relative; overflow: hidden; }

/* Toolbar (product: .toolbar-btn 32px, .toolbar-select native select min 80px) */
.ed-toolbar {
    display: flex; align-items: center; gap: 0; flex-wrap: nowrap; overflow: hidden;
    padding: 7px 10px; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.ed-group { display: inline-flex; align-items: center; gap: 2px; padding-right: 10px; margin-right: 10px; border-right: 1px solid #ddd; }
.ed-group:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.ed-group i, .ed-select {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 27px; height: 27px; padding: 0 6px;
    background: #fff; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 11.5px; color: #0f172a;
}
.ed-select { min-width: 84px; justify-content: space-between; gap: 10px; padding: 0 7px 0 9px; font-size: 11.5px; white-space: nowrap; }
.ed-select .ed-chev { font-size: 8px; color: #475569; }

/* AI badge (product: .streaming-indicator, absolute top right of the editor pane) */
.ed-badge {
    position: absolute; top: 52px; right: 12px; z-index: 10;
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 12px; border-radius: 5px;
    background: rgba(37, 99, 235, 0.94); color: #fff; font-size: 12px; font-weight: 500;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    opacity: 0; transform: translateY(-4px); transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none;
}
.ed-badge.on { opacity: 1; transform: none; }
.ed-badge.on i { animation: edPulse 1s infinite; }
@keyframes edPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Document */
.ed-doc-panel { flex: 1; min-height: 0; overflow: hidden; background: #fff; scroll-behavior: smooth; }
.ed-doc {
    padding: 40px 40px 60px;
    font-family: 'Times New Roman', Times, serif;
    font-size: 13px; line-height: 1.55; color: #0f172a;
}
.ed-doc p { margin: 0 0 10px; }
.ed-doc .ed-title { text-align: center; font-weight: 700; margin-bottom: 14px; }
.ed-doc .ed-placeholder { color: #94a3b8; }
.ed-caret {
    display: inline-block; width: 1.5px; height: 1em; margin-left: 1px;
    background: #2563eb; vertical-align: -0.15em; animation: edCaret 0.9s steps(2) infinite;
}
@keyframes edCaret { 50% { opacity: 0; } }

/* Redlines (copied from the product) */
.ed-change { margin: 4px 0 10px; border-radius: 6px; }
.ed-doc .chat-deletion, .ed-doc .chat-insertion {
    border-radius: 4px; padding: 3px 8px; margin: 4px 0; position: relative;
}
.ed-doc .chat-deletion { background: #fee2e2; border-left: 3px solid #ef4444; }
.ed-doc .chat-insertion { background: #dcfce7; border-left: 3px solid #22c55e; }
.ed-doc .chat-deletion::before, .ed-doc .chat-insertion::before {
    display: inline-block; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    padding: 1px 6px; border-radius: 3px; margin-right: 6px;
}
.ed-doc .chat-deletion::before { content: 'Removed'; color: #dc2626; background: #fecaca; }
.ed-doc .chat-insertion::before { content: 'Added'; color: #16a34a; background: #bbf7d0; }
.ed-doc .chat-deletion span { text-decoration: line-through; color: #991b1b; }
.ed-doc .chat-insertion span { color: #166534; }
.ed-doc .chat-change-current { outline: 3px solid #eab308; outline-offset: 2px; }

/* Chat panel */
.ed-chat { flex: 0 0 316px; display: flex; flex-direction: column; min-height: 0; background: #f8fafc; }
.ed-tabs { display: flex; background: #f1f5f9; border-bottom: 1px solid #e2e8f0; flex-shrink: 0; }
.ed-tabs span {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px; font-size: 12px; font-weight: 500; color: #0f172a; opacity: 0.7;
    border-bottom: 2px solid transparent;
}
.ed-tabs span.active { color: #2563eb; border-bottom-color: #2563eb; background: rgba(37, 99, 235, 0.1); opacity: 1; }
.ed-messages {
    flex: 1; min-height: 0; overflow: hidden;
    padding: 14px; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px;
}
.ed-msg { max-width: 92%; animation: edFade 0.3s ease-out; }
.ed-msg.ed-welcome { max-width: 100%; }
.ed-msg.user { align-self: flex-end; }
.ed-msg.assistant { align-self: flex-start; }
.ed-label { font-size: 9.5px; color: #6c757d; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.ed-msg.user .ed-label { text-align: right; }
.ed-bubble { padding: 9px 12px; border-radius: 12px; font-size: 12px; line-height: 1.5; }
.ed-msg.user .ed-bubble { background: #2563eb; color: #fff; border-bottom-right-radius: 4px; }
.ed-msg.assistant .ed-bubble { background: #fff; color: #0f172a; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
/* Product: .chat-action-buttons is its own bordered box under the welcome bubble */
.ed-actions {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px;
    margin-top: 10px; padding: 10px;
    background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px;
}
.ed-actions span {
    display: inline-flex; align-items: center; gap: 6px; min-width: 0;
    padding: 8px 9px; background: #fff; border: 1px solid #cbd5e1; border-radius: 6px;
    font-size: 10.5px; font-weight: 500; color: #0f172a; white-space: nowrap; overflow: hidden;
}
.ed-actions span i { flex-shrink: 0; width: 12px; text-align: center; color: #475569; }
.ed-pending { display: inline-flex; align-items: center; gap: 8px; color: #0f172a; font-weight: 500; }
.ed-dots { display: inline-flex; gap: 3px; }
.ed-dots i { width: 5px; height: 5px; border-radius: 50%; background: #2563eb; opacity: 0.35; animation: edDot 1.2s ease-in-out infinite; display: block; }
.ed-dots i:nth-child(2) { animation-delay: 0.15s; }
.ed-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes edDot { 0%, 80%, 100% { opacity: 0.35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes edFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Input (product: textarea grows to a max, then scrolls with the caret) */
.ed-input-box {
    display: flex; align-items: center; gap: 8px;
    margin: 0 12px 12px; padding: 8px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; flex-shrink: 0;
}
.ed-attach {
    width: 34px; height: 34px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid rgba(15, 23, 42, 0.1); background: rgba(248, 250, 252, 0.9); border-radius: 10px; font-size: 13px; color: #1f2937;
}
.ed-input {
    flex: 1; min-width: 0; min-height: 34px; max-height: 64px; padding: 6px 4px;
    font-size: 12px; line-height: 1.45; color: #0f172a;
    overflow-y: auto; overflow-x: hidden; scrollbar-width: none; overflow-wrap: break-word;
}
.ed-input::-webkit-scrollbar { display: none; }
.ed-input:empty::before { content: attr(data-placeholder); color: rgba(71, 85, 105, 0.7); }
.ed-input.typing::after { content: ''; display: inline-block; width: 1.5px; height: 1em; background: #0f172a; margin-left: 1px; vertical-align: -0.15em; animation: edCaret 0.9s steps(2) infinite; }
.ed-send {
    width: 36px; height: 36px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; border-radius: 11px; font-size: 13px;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
}

/* Review controls */
.ed-review { display: flex; flex-direction: column; gap: 9px; padding: 12px 14px; background: #f8f9fa; border-top: 2px solid #2563eb; flex-shrink: 0; }
.ed-review[hidden] { display: none; }
.ed-summary-row { display: flex; align-items: center; gap: 7px; padding: 6px 10px; background: #e3f2fd; border-radius: 6px; font-size: 11px; color: #1976d2; }
.ed-nav { display: flex; align-items: center; justify-content: center; gap: 10px; }
.ed-navbtn { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #ddd; border-radius: 6px; font-size: 10px; }
.ed-counter { font-size: 11px; font-weight: 500; color: #495057; min-width: 46px; text-align: center; }
.ed-review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ed-rbtn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 7px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 600; color: #fff; }
.ed-accept { background: #28a745; } .ed-reject { background: #fd7e14; } .ed-accept-all { background: #2563eb; } .ed-dismiss { background: #dc3545; }

/* Fake pointer */
.ed-cursor { position: absolute; left: 0; top: 0; opacity: 0; pointer-events: none; transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease; z-index: 40; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }

@media (max-width: 640px) {
    .ed-demo { --ed-w: 440px; --ed-h: 560px; }
    .ed-chat { flex-basis: 200px; }
    .ed-ctl:nth-of-type(2), .ed-ctl:nth-of-type(3), .ed-save-status, .ed-group-more { display: none; }
    .ed-tab { min-width: 150px; max-width: 190px; }
    .ed-doc { padding: 40px 18px 60px; font-size: 12px; }
    .ed-input:empty::before { content: attr(data-placeholder-short); }
    .ed-actions { grid-template-columns: minmax(0, 1fr); }
    .ed-review-actions { grid-template-columns: 1fr; }
    .ed-notice { top: 52px; right: 8px; font-size: 11px; }
}
