/* ============================================================================
   Nurture Workspace — SGM-108
   Two-pane queue + thread + composer. Structure mirrors inbox.css (SGM-694),
   which is the app's proven pattern for a human-initiated, per-contact,
   per-user surface. Colours/radius/shadow are app.css tokens only (zero raw
   hex); spacing is px on an 8px rhythm, matching inbox.css's own convention.

   ONE deliberate divergence from inbox.css: names and companies WRAP rather
   than truncating. The Inbox ellipsises because a mail subject is disposable;
   here the company is what distinguishes two people with the same first name,
   and a hidden company makes her open the wrong record. Caught by the screen
   review on the approved mockup.
   ============================================================================ */

/* The available height belongs to the WRAP, and .nur-page flexes into whatever
   the stats strip leaves. inbox.css puts `calc(100vh - var(--topbar-h) - 32px)`
   on the panel itself, which is exact there because the panel is the only thing
   under the topbar. Nurture stacks a stats strip above the same panel, so
   copying that constant overflowed the viewport by the strip's height and
   pushed the composer — the primary action — below the fold. Letting layout
   measure the strip is correct at any strip height; a constant is not. */
.nur-wrap { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 32px); min-height: 480px; }
.nur-page { display: flex; flex: 1; min-height: 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

/* ── Queue pane ── */
.nur-queue { width: 340px; flex-shrink: 0; background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.nur-qhead { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.nur-qtitle { font-weight: 700; font-size: 14px; color: var(--text); }
.nur-qcount { font-size: 12px; color: var(--text-muted); }
.nur-qhead .btn { margin-left: auto; }
.nur-qsearch { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.nur-qsearch input { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; font-size: 13px; background: var(--bg-input); color: var(--text); }
.nur-qsearch input:focus { outline: none; border-color: var(--border-focus); }
.nur-qtabs { display: flex; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.nur-qtab { font-size: 12px; padding: 4px 10px; border-radius: var(--radius-full); border: 1px solid var(--border); background: var(--bg-card); color: var(--text-muted); cursor: pointer; }
.nur-qtab:hover { background: var(--bg-card-hover); }
.nur-qtab.is-on { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary); font-weight: 700; }
.nur-qlist { flex: 1; overflow-y: auto; min-height: 0; }

.nur-row { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; border-left: 3px solid transparent; transition: background var(--transition); }
.nur-row:hover { background: var(--bg-card-hover); }
.nur-row.is-sel { background: var(--primary-bg); border-left-color: var(--primary); }
.nur-av { width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--radius-full); background: var(--primary-bg); color: var(--primary); font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.nur-mid { min-width: 0; flex: 1; }
.nur-name { font-weight: 600; font-size: 13.5px; color: var(--text); line-height: 1.35; }
.nur-co { display: block; font-weight: 400; color: var(--text-muted); font-size: 12px; margin-top: 1px; }
.nur-snip { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nur-right { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.nur-due { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.nur-due.is-over { color: var(--danger); font-weight: 700; }
.nur-empty-list { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── Thread pane ── */
.nur-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.nur-chead { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--bg-card); flex-wrap: wrap; }
.nur-cname { font-weight: 700; font-size: 15px; color: var(--text); }
.nur-cmeta { font-size: 12px; color: var(--text-muted); }
.nur-sp { flex: 1; }
.nur-body { flex: 1; overflow-y: auto; padding: 18px; min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.nur-msg { max-width: 74%; }
.nur-msg .nur-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.nur-bub { padding: 11px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; box-shadow: var(--shadow-xs); white-space: pre-wrap; word-break: break-word; }
.nur-msg.is-out { align-self: flex-end; }
.nur-msg.is-out .nur-meta { text-align: right; }
.nur-msg.is-out .nur-bub { background: var(--primary); color: var(--text-inverse); border-bottom-right-radius: 4px; }
.nur-msg.is-in { align-self: flex-start; }
.nur-msg.is-in .nur-bub { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.nur-sysline { align-self: center; font-size: 11.5px; color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 3px 12px; }
.nur-convo-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; height: 100%; color: var(--text-muted); padding: 40px 24px; }
.nur-convo-empty h3 { font-size: 15px; color: var(--text-secondary); margin: 0 0 4px; }
.nur-convo-empty p { font-size: 13px; margin: 0 0 16px; max-width: 46ch; line-height: 1.5; }

/* ── Log bar ──
   One button and a caveat. The composer that used to live here was a textarea
   plus four inputs, permanently occupying ~60% of the thread pane for an
   action taken once per visit — so a 20-message history was squeezed into the
   strip above a form nobody was reading. The form moved into a modal; the
   thread got the pane back. */
.nur-logbar { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--border); background: var(--bg-card); padding: 10px 18px; }
.nur-logbar-hint { font-size: 12px; color: var(--text-muted); }
.nur-readonly { border-top: 1px solid var(--border); background: var(--bg-card); padding: 12px 18px; font-size: 12.5px; color: var(--text-muted); }

/* ── Log modal (the former composer) ── */
.nur-logtabs { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.nur-logtab { padding: 6px 16px; font-size: 12.5px; border: none; background: var(--bg-card); color: var(--text-muted); cursor: pointer; }
.nur-logtab:hover { background: var(--bg-card-hover); }
.nur-logtab.is-on { background: var(--primary-bg); color: var(--primary); font-weight: 700; }
.nur-lab { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }
.nur-logmodal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.nur-logmodal-body { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: 13.5px; line-height: 1.5; background: var(--bg-input); color: var(--text); resize: vertical; min-height: 132px; font-family: inherit; }
.nur-logmodal-body:focus { outline: none; border-color: var(--border-focus); }
.nur-inp { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; font-size: 13px; background: var(--bg-input); color: var(--text); font-family: inherit; }
.nur-inp:focus { outline: none; border-color: var(--border-focus); }
/* Three fields, one row on a desktop modal; stacked when there is no room. */
.nur-logfields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-top: 16px; }
.nur-logfields .form-group { margin: 0; }
.nur-ai-panel { margin-top: 12px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.nur-ai-panel .nur-lab { display: block; margin-bottom: 5px; }
.nur-ai-panel .nur-inp { margin-bottom: 10px; }
.nur-airow { display: flex; align-items: center; gap: 10px; }

/* ── Stats strip ── */
.nur-stats { display: flex; gap: 12px; padding: 14px 18px; background: var(--bg-card); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.nur-stat { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 15px; min-width: 112px; }
.nur-stat-v { font-size: 21px; font-weight: 700; color: var(--primary); line-height: 1; }
.nur-stat-l { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 3px; }
.nur-delta { font-size: 11px; font-weight: 700; margin-left: 6px; }
.nur-delta.is-up { color: var(--success); }
.nur-delta.is-down { color: var(--danger); }

/* ── AI draft popover states ── */
.nur-ai-hint { font-size: 11.5px; color: var(--text-dim); margin-top: 8px; }
.nur-ai-err { font-size: 12.5px; color: var(--danger); margin-top: 8px; }

@media (max-width: 620px) {
  .nur-logfields { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  /* Below 900px the two panes stack, so a fixed viewport height would clip
     them. Both the wrap and the panel release their height together — the
     wrap owns it now, so releasing only the panel would have no effect. */
  .nur-wrap { height: auto; min-height: 0; }
  .nur-page { flex-direction: column; height: auto; }
  .nur-queue { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 320px; }
}
