/* ──────────────────────────────────────────────────────────────────
   inbox-view.css — shared email LIST+READER component styles.
   Lifted from my-inbox.html (lines 9–326), every class renamed to an
   `iv-` prefix and scoped under `.iv-root`. CSS-var fallbacks kept so
   the component works on any host (my-inbox, crm-accounts, harness).

   Host-only classes intentionally NOT ported (they stay on the host):
   scope-control, sender-menu, senders-overlay, filter-banner, compose-*,
   setup-*, sidebar/toolbar/page chrome. The component fires hooks; the
   host renders those overlays from its own state.

   Phase 1 — do NOT wire into any page.
   ────────────────────────────────────────────────────────────────── */

/* Sizing contract: flex column that fills the host container's height.
   Works in the full-viewport CRM drawer and the inbox page alike. */
.iv-root { display:flex; flex-direction:column; height:100%; min-height:0; }

/* ── 2-pane layout: list + detail ── */
.iv-body { flex:1; display:grid; grid-template-columns:var(--list-w, 300px) 1fr; overflow:hidden; min-height:0; position:relative; } /* --list-w user-draggable via crm-split.js (300–420) */
.iv-list { background:#fff; border-right:0.5px solid var(--border-light,#ddd8cf); overflow-y:auto; }
.iv-detail { background:#fff; overflow-y:auto; padding:24px 32px; }

/* ── List states ── */
.iv-loading { display:flex; align-items:center; justify-content:center; padding:40px; color:var(--text-muted,#5c6170); font-size:0.9em; }
.iv-loadmore { display:flex; align-items:center; justify-content:center; padding:16px; color:var(--text-muted,#5c6170); font-size:0.82em; }
.iv-empty { padding:40px; text-align:center; color:var(--text-muted,#5c6170); font-size:0.9em; }
.iv-error { padding:40px; text-align:center; color:var(--danger,#c53030); font-size:0.9em; }

/* ── Bulk select bar ── */
.iv-select-bar { display:flex; align-items:center; gap:14px; padding:8px 14px; border-bottom:1px solid var(--border-light,#ddd8cf); background:#fafafb; font-size:0.85em; position:sticky; top:0; z-index:5; }
.iv-select-bar label { display:flex; align-items:center; gap:7px; cursor:pointer; color:var(--text-muted,#5c6170); white-space:nowrap; }
.iv-select-bar .iv-sb-actions { display:flex; gap:8px; margin-left:auto; }
.iv-select-bar .iv-sb-btn { font-size:0.92em; padding:4px 12px; border:1px solid var(--border-light,#ddd8cf); border-radius:6px; background:#fff; cursor:pointer; white-space:nowrap; }
.iv-select-bar .iv-sb-btn:hover { border-color:var(--accent,#b8965a); }
.iv-select-bar .iv-sb-btn.danger { color:var(--danger,#dc2626); }
.iv-select-bar .iv-sb-btn.danger:hover { border-color:var(--danger,#dc2626); background:#fef2f2; }

/* ── Message rows ── */
.iv-message-row { position:relative; padding:12px 16px; border-bottom:0.5px solid var(--border-light,#ddd8cf); cursor:pointer; transition:background 0.08s; }
.iv-message-row:hover { background:#faf7f0; }
.iv-message-row.active { background:var(--primary-light,#e6f0ff); border-left:3px solid var(--primary,#007AFF); padding-left:13px; }
.iv-message-row.unread { font-weight:600; background:#fffbf0; }
.iv-message-row.unread.active { background:var(--primary-light,#e6f0ff); }
.iv-message-row.checked { background:rgba(184,150,90,0.08); }
.iv-message-row .iv-mr-check { position:absolute; top:12px; right:12px; width:17px; height:17px; cursor:pointer; z-index:2; }
.iv-message-row .iv-mr-top { padding-right:26px; }

.iv-mr-top { display:flex; justify-content:space-between; align-items:baseline; gap:8px; margin-bottom:3px; }
/* Badge + pills (★ / 📎 N / account / category) share one line — no separate pills row */
.iv-mr-dirline { display:flex; align-items:center; gap:5px; flex-wrap:wrap; margin-bottom:5px; padding-right:26px; }
.iv-mr-dir { display:inline-block; font-size:0.66em; font-weight:800; text-transform:uppercase; letter-spacing:0.04em;
  padding:2px 8px; border-radius:6px; }
.iv-mr-dir.sent { background:#f5cd4b; color:#000; }   /* you sent it — Amazon yellow, bold black */
.iv-mr-dir.recv { background:#007aff; color:#fff; }    /* you received it — Apple blue, bold white */
.iv-mr-from { font-size:0.92em; color:#000; font-weight:600; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.iv-mr-from-link { cursor:pointer; }
.iv-mr-from-link:hover { color:var(--accent,#b8965a); text-decoration:underline; }
.iv-mr-date { font-size:0.78em; color:var(--text-muted,#5c6170); flex-shrink:0; }
.iv-mr-subject { font-size:0.9em; color:#000; margin-bottom:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.iv-mr-snippet { font-size:0.82em; color:var(--text-muted,#5c6170); font-weight:400; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.iv-mr-pills { display:flex; gap:4px; margin-top:5px; flex-wrap:wrap; }
.iv-mr-pill { display:inline-block; padding:1px 7px; background:var(--primary-light,#e6f0ff); color:var(--primary,#007AFF); border-radius:8px; font-size:0.7em; font-weight:600; }
.iv-mr-pill.star { background:#fff3cd; color:#a06a00; }
.iv-mr-pill.cat { color:#000; }
.iv-mr-pill.folder { background:#eaf1e3; color:#3d5a2a; cursor:pointer; font-weight:600; max-width:240px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; vertical-align:bottom; }
.iv-mr-pill.folder:hover { background:#dce8d0; }

/* Attachment indicator — right side, just LEFT of the select box.
   Black clip + count; count reserves 2-digit width and sits between clip and box. */
.iv-mr-attach { position:absolute; top:11px; right:14px; z-index:2;
  display:inline-flex; align-items:center; gap:2px; pointer-events:none; }
.iv-mr-attach.has-check { right:38px; }   /* clear the 17px checkbox sitting at right:12px */
.iv-mr-clip { width:14px; height:14px; color:#000; display:block; }
.iv-mr-attn { min-width:1.5em; text-align:center; color:#000; font-size:0.72em; font-weight:700;
  line-height:1; font-variant-numeric:tabular-nums; }
/* keep badge line clear of the floating attach indicator */
.iv-mr-attach ~ .iv-mr-dirline { padding-right:50px; }
.iv-mr-attach.has-check ~ .iv-mr-dirline { padding-right:74px; }
.iv-mr-pill.cat.catr { background:#dff0e2; }   /* Transactions */
.iv-mr-pill.cat.catn { background:#e3ecff; }   /* Updates */
.iv-mr-pill.cat.catp { background:#ffe8d6; }   /* Promotions */

/* ── Detail / reader pane ── */
.iv-empty-detail { display:flex; flex-direction:column; align-items:center; justify-content:center; height:100%; color:var(--text-muted,#5c6170); text-align:center; padding:40px; }
.iv-detail-header { padding-bottom:18px; border-bottom:0.5px solid var(--border-light,#ddd8cf); margin-bottom:18px; }
.iv-detail-subject { font-size:1.35em; font-weight:600; margin-bottom:10px; }
.iv-detail-meta { display:grid; grid-template-columns:60px 1fr; gap:4px 10px; font-size:0.86em; color:var(--text-muted,#5c6170); }
.iv-detail-meta dt { font-weight:600; }
.iv-detail-meta dd { color:#000; }
.iv-detail-accounts { margin:14px 0; padding:10px 12px; background:var(--primary-light,#e6f0ff); border-radius:6px; font-size:0.84em; }
.iv-detail-accounts strong { color:var(--primary,#007AFF); font-weight:600; }
.iv-detail-accounts a { color:var(--primary,#007AFF); text-decoration:none; cursor:pointer; }
.iv-detail-accounts a:hover { text-decoration:underline; }
.iv-detail-body { font-size:0.94em; line-height:1.6; color:#000; }
.iv-detail-body img { max-width:100%; height:auto; }
/* sandboxed email render — isolates hostile email HTML from the admin page */
.iv-email-frame { width:100%; border:0; min-height:120px; background:#fff; display:block; }

/* Reply / Reply-All + hook buttons on the reader */
.iv-detail-actions { display:flex; gap:8px; margin-top:14px; flex-wrap:wrap; }
.iv-detail-actions .iv-btn { font-size:0.86em; }

/* Generic buttons (component-local so it doesn't depend on host .btn) */
.iv-btn { padding:7px 13px; background:var(--primary,#007AFF); color:#fff; border:none; border-radius:5px; cursor:pointer; font:inherit; font-size:0.88em; font-weight:500; }
.iv-btn:disabled { opacity:0.5; cursor:not-allowed; }
.iv-btn-secondary { background:#fff; color:#000; border:1px solid var(--border,#d8d0c4); }

/* ── Attachments ── */
.iv-detail-attachments { margin-top:24px; padding:18px; border:2px solid var(--accent,#b8965a); border-radius:14px; background:#fbf7ee; }
.iv-detail-attachments .iv-att-head { display:flex; align-items:center; gap:10px; font-size:1.15em; font-weight:700; color:#1a1a2e; margin-bottom:14px; }
.iv-detail-attachments .iv-att-head .iv-att-clip { font-size:1.4em; line-height:1; }
.iv-detail-attachments .iv-att-row { display:flex; align-items:center; gap:16px; padding:16px 18px; margin:10px 0 0; background:#fff; border:1px solid #e6e0d2; border-radius:12px; box-shadow:0 1px 3px rgba(0,0,0,0.05); }
.iv-detail-attachments .iv-att-icon { width:52px; height:52px; flex-shrink:0; border-radius:10px; background:#eef2ff; display:flex; align-items:center; justify-content:center; font-size:1.8em; line-height:1; }
.iv-detail-attachments .iv-att-info { flex:1; min-width:0; }
.iv-detail-attachments .iv-att-name { font-size:1.08em; font-weight:600; color:#1a1a2e; word-break:break-word; line-height:1.35; }
.iv-detail-attachments .iv-att-meta { font-size:0.9em; color:var(--text-muted,#5c6170); margin-top:4px; }
.iv-detail-attachments .iv-att-dl { flex-shrink:0; font-size:1em; font-weight:700; padding:12px 22px; border-radius:10px; background:#007aff; color:#fff; border:none; cursor:pointer; display:inline-flex; align-items:center; gap:8px; white-space:nowrap; }
.iv-detail-attachments .iv-att-dl:hover { filter:brightness(0.94); }
.iv-detail-attachments .iv-att-dl:disabled { opacity:0.5; cursor:wait; }
.iv-detail-attachments .iv-att-status { font-size:1em; color:var(--text-muted,#5c6170); padding:6px 2px; display:flex; align-items:center; gap:8px; }
.iv-detail-attachments .iv-att-pending { color:var(--text-muted,#5c6170); font-style:italic; font-size:0.95em; }
@media (max-width:600px){ .iv-detail-attachments .iv-att-row { flex-wrap:wrap; } .iv-detail-attachments .iv-att-dl { width:100%; justify-content:center; } }

/* ── Translation toggle ── */
.iv-translate-toggle { display:inline-flex; border:1px solid var(--border,#d8d0c4); border-radius:6px; overflow:hidden; margin:14px 0 8px; font-size:0.82em; }
.iv-translate-toggle button { padding:5px 12px; background:#fff; border:none; cursor:pointer; font:inherit; font-size:inherit; color:var(--text-muted,#5c6170); border-right:1px solid var(--border-light,#ddd8cf); }
.iv-translate-toggle button:last-child { border-right:none; }
.iv-translate-toggle button.active { background:var(--primary-light,#e6f0ff); color:var(--primary,#007AFF); font-weight:600; }
.iv-translate-status { font-size:0.78em; color:var(--text-muted,#5c6170); margin-left:10px; }
.iv-translate-status.err { color:var(--danger,#c53030); }
.iv-translate-status.ok { color:var(--success,#2a8c4a); }
.iv-translated-block { margin-top:14px; padding:12px 14px; background:#faf7f0; border-left:3px solid var(--primary,#007AFF); border-radius:0 6px 6px 0; font-size:0.94em; line-height:1.6; white-space:pre-wrap; }
.iv-translated-block .iv-lang-pill { display:inline-block; padding:1px 7px; background:var(--primary-light,#e6f0ff); color:var(--primary,#007AFF); border-radius:8px; font-size:0.72em; font-weight:600; margin-bottom:8px; }

/* ── Ren co-pilot panel ── */
.iv-ren-panel { margin-top:24px; padding:14px 16px; background:#f6f4ef; border:1px solid var(--border-light,#ddd8cf); border-radius:8px; }
.iv-ren-panel-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.iv-ren-panel-title { font-size:0.86em; font-weight:600; color:#000; display:flex; align-items:center; gap:6px; }
.iv-ren-panel-title .iv-ren-dot { width:8px; height:8px; border-radius:50%; background:var(--primary,#007AFF); flex-shrink:0; }
.iv-ren-panel-lang { display:inline-flex; border:1px solid var(--border,#d8d0c4); border-radius:5px; overflow:hidden; font-size:0.78em; }
.iv-ren-panel-lang button { padding:3px 9px; background:#fff; border:none; cursor:pointer; font:inherit; font-size:inherit; color:var(--text-muted,#5c6170); border-right:1px solid var(--border-light,#ddd8cf); }
.iv-ren-panel-lang button:last-child { border-right:none; }
.iv-ren-panel-lang button.active { background:var(--primary-light,#e6f0ff); color:var(--primary,#007AFF); font-weight:600; }
.iv-ren-draft { padding:10px 12px; background:#fff; border:1px solid var(--border-light,#ddd8cf); border-radius:6px; font-size:0.92em; line-height:1.55; white-space:pre-wrap; min-height:90px; }
.iv-ren-draft.placeholder { color:var(--text-muted,#5c6170); font-style:italic; min-height:42px; }
.iv-ren-reasoning { font-size:0.78em; color:var(--text-muted,#5c6170); margin-top:6px; font-style:italic; }
.iv-ren-reasoning.warn { color:var(--warning,#b76e00); font-style:normal; font-weight:500; }
.iv-ren-actions { display:flex; gap:6px; margin-top:10px; flex-wrap:wrap; }
.iv-ren-actions .iv-btn { font-size:0.82em; padding:5px 10px; }
.iv-ren-refine-row { display:none; gap:8px; margin-top:10px; }
.iv-ren-refine-row.show { display:flex; }
.iv-ren-refine-row input { flex:1; padding:6px 10px; border:1px solid var(--border,#d8d0c4); border-radius:5px; font:inherit; font-size:0.88em; }

/* ── Ren reply triage (analyze → decide → compose) ─────────────────── */
.iv-ren-triage { margin-bottom:12px; }
.iv-tri-loading, .iv-tri-error { padding:10px 12px; font-size:0.86em; color:var(--text-muted,#5c6170); font-style:italic; }
.iv-tri-error { color:var(--warning,#b76e00); font-style:normal; }
.iv-tri-tone { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:8px; font-size:0.82em; }
.iv-tri-tone-label { background:#1d1d1f; color:#fff; padding:2px 9px; border-radius:9px; font-weight:700; text-transform:capitalize; }
.iv-tri-tone-conf { color:var(--text-muted,#5c6170); text-transform:capitalize; }
.iv-tri-tone-ev { color:var(--text-muted,#5c6170); font-style:italic; }
.iv-tri-ctx { font-size:0.74em; color:var(--text-muted,#5c6170); margin-bottom:8px; }
.iv-tri-summary { font-size:0.85em; color:#000; margin-bottom:10px; line-height:1.45; }
.iv-tri-points { display:flex; flex-direction:column; gap:8px; }
.iv-tri-point { padding:9px 11px; background:#fff; border:1px solid var(--border-light,#ddd8cf); border-radius:7px; }
.iv-tri-point.needs { border-color:var(--warning,#b76e00); background:#fffaf2; }
.iv-tri-point.needs-unresolved { box-shadow:0 0 0 2px rgba(183,110,0,0.35); }
.iv-tri-sum { font-size:0.88em; color:#000; font-weight:500; line-height:1.4; }
.iv-tri-warn { color:var(--warning,#b76e00); font-weight:700; }
.iv-tri-row2 { display:flex; align-items:center; gap:8px; margin-top:7px; }
.iv-tri-stances { display:inline-flex; border:1px solid var(--border,#d8d0c4); border-radius:6px; overflow:hidden; }
.iv-tri-st { padding:4px 12px; background:#fff; border:none; border-right:1px solid var(--border-light,#ddd8cf); cursor:pointer; font:inherit; font-size:0.8em; color:var(--text-muted,#5c6170); }
.iv-tri-st:last-child { border-right:none; }
.iv-tri-st:hover { background:#f6f4ef; }
.iv-tri-st.active { background:var(--primary,#007AFF); color:#fff; font-weight:600; }
.iv-tri-customtoggle { margin-left:auto; padding:4px 9px; background:#fff; border:1px solid var(--border,#d8d0c4); border-radius:6px; cursor:pointer; font-size:0.82em; color:var(--text-muted,#5c6170); }
.iv-tri-customtoggle.active { background:var(--primary-light,#e6f0ff); color:var(--primary,#007AFF); border-color:var(--primary,#007AFF); }
.iv-tri-custom { width:100%; margin-top:7px; padding:6px 9px; border:1px solid var(--border,#d8d0c4); border-radius:5px; font:inherit; font-size:0.84em; box-sizing:border-box; }
.iv-tri-suggest { margin-top:6px; font-size:0.78em; color:var(--text-muted,#5c6170); font-style:italic; line-height:1.4; }
.iv-tri-foot { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:11px; }
.iv-tri-hint { font-size:0.78em; color:var(--warning,#b76e00); font-weight:500; }
