/* Inbox — owner / administrator / specialist. Tokens and components: /ui/ds.css. */

.demo-hint { font-size: 12.5px; }
.demo-hint ul { padding-left: 18px; margin: 6px 0 0; }

/* app frame */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

/* funnel strip in the navy bar */
.funnel { display: flex; align-items: center; gap: 2px; margin-left: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.fstep { display: flex; flex-direction: column; align-items: flex-start; padding: 4px 10px; border-radius: 8px; }
.fstep b { font-size: 15px; font-weight: 800; color: var(--on-bar); line-height: 1; }
.fstep span { font-size: 11.5px; color: #D6EEF8; margin-top: 3px; white-space: nowrap; font-weight: 600; }
.fstep.win b { color: var(--on-bar); }
.fstep.win { background: var(--glass); }
.farr { color: var(--glass-line); font-size: 12px; }
.fmeta { font-size: 11.5px; color: var(--navy-muted); padding-left: 10px; margin-left: 4px;
  border-left: 1px solid var(--navy-line); line-height: 1.3; white-space: nowrap; }
.fmeta b { color: var(--on-bar); }
/* Wait-summary moved here from the list pane (§ радикальное упрощение, 23.10) — it's the same
   kind of response-time number as .fmeta's own "1-й ответ" average, so they now sit together.
   Solid color + white text, not the soft/pastel pill used on light surfaces elsewhere — this bar
   is navy, same pattern as .bell's own unread-count badge. */
.wait-summary { display: flex; gap: 6px; margin-left: 8px; }
.wait-sum { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; color: var(--on-bar); }
.wait-sum.red { background: var(--pink-ink); }
.wait-sum.amber { background: var(--glass-2); box-shadow: inset 0 0 0 1px var(--glass-line); }

/* two panes; the request rail lives inside the thread */
.layout { flex: 1; display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: 0; }

/* list pane */
.list { background: var(--list-wash); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  min-height: 0; min-width: 0; }
.list .tabs .tab { flex: 1; justify-content: center; text-align: center; padding: 9px 6px; }
.filters { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.rows { list-style: none; margin: 0; padding: 2px 8px 12px; overflow-y: auto; flex: 1; display: grid; gap: 2px; align-content: start; }
/* Row, take 3 — radical simplification (§ 23.10, direct ask): avatar, name, last message text,
   nothing else. The one surviving signal is how long a human has owed a reply — expressed purely
   as color (ring + row tint, escalating ok→amber→red) and bold text, no separate chip or badge. */
.row { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 12px;
  cursor: pointer; min-width: 0; }
.row:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.row.on { background: var(--surface); box-shadow: var(--shadow); }
.row.on .name { color: var(--accent-ink); }
.row.unread:not(.on) .name { color: var(--ink); }
/* Wait-level as a row-level accent — loses to .on (selected) and .unread's own tint when those
   also apply, same cascade order as the priority-accent version this replaced. */
.row.wl-amber:not(.on) { background: color-mix(in srgb, var(--high-soft) 60%, transparent); }
.row.wl-red:not(.on) { background: color-mix(in srgb, var(--pink-soft) 75%, transparent); }
.row.is-lost:not(.on) { opacity: .85; }
.row-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); color: var(--accent-ink);
  font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: inset 0 0 0 1.5px var(--border-2); overflow: hidden; }
.row-avatar.ring-amber { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--high); }
.row-avatar.ring-red { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--pink); }
.row-body { min-width: 0; flex: 1; }
.row.unread .name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--pink); margin-right: 7px; flex-shrink: 0; vertical-align: 1px; }
.row .name { display: block; font-weight: 700; font-size: 15px; color: var(--ink); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.snippet { font-size: 13.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.snippet .ic { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
/* "входящий ⇒ жирным" (§ 23.10): bold whenever the client sent the last message and nobody from
   our side has answered yet — independent of read/unread, which only drives the row tint above. */
.snippet.needs-reply { font-weight: 700; color: var(--ink); }

/* thread */
.thread { display: flex; min-height: 0; min-width: 0; background: var(--canvas); position: relative; }
.thread-view { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; min-width: 0; }
.conv-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.conv-h { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex: none; min-width: 0; }
.conv-h .name { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-h .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 3px; }
.chan { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--ink-soft); }
.chan .cd { width: 8px; height: 8px; }
.back, .rail-toggle { display: none; }

.msgs { list-style: none; margin: 0; flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column;
  gap: 14px; }
.bub { max-width: min(640px, 76%); padding: 10px 14px 11px; border-radius: 18px; font-size: 14px; line-height: 1.5;
  align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-xs); }
.bub .who { font-size: 12px; font-weight: 700; margin-bottom: 3px;
  color: var(--accent-ink); display: flex; gap: 8px; align-items: center; }
.bub .who time, .bub .who .t, .bub .who span + span { color: var(--muted); font-weight: 600; }
.bub .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bub.out { align-self: flex-end; background: var(--bubble-out); color: var(--on-bar); border-color: transparent;
  border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; box-shadow: var(--shadow-bubble); }
.bub.out .who, .bub.out .who time, .bub.out .who .t, .bub.out .who span + span { color: #DDF0F8; }
/* Everyone on "our" side — bot, specialist, admin — sits on the RIGHT; only the color and the
   "who" label tell them apart (§ окончательно определились со стороной, 23.10: earlier moved
   the bot to the left, then un-did it — the rule is simply in=left, out=right, no exceptions). */
.bub.bot { background: color-mix(in srgb, var(--accent-soft) 80%, var(--surface)); color: var(--ink-soft);
  border-color: color-mix(in srgb, var(--accent) 14%, transparent); font-size: 13.5px; box-shadow: none; }
.bub.out.bot .who { color: var(--accent-ink); }
.bub.out.bot .who time, .bub.out.bot .who .t, .bub.out.bot .who span + span { color: var(--muted); }
.bub .dstatus { text-transform: none; letter-spacing: 0; font-weight: 700; }
.bub .dstatus.failed { color: #ffd2d0; }
.bub.in .dstatus.failed, .bub.bot .dstatus.failed { color: var(--urgent); }
.bub .buttons { margin-top: 8px; display: flex; gap: 5px; flex-wrap: wrap; }
.bub .buttons span { font-size: 12px; font-weight: 600; border: 1px solid var(--border-2); border-radius: 999px;
  padding: 3px 10px; color: var(--accent-ink); background: var(--surface); }
.bub .photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.bub .photos img { width: 168px; aspect-ratio: 4/3; object-fit: cover; border-radius: 13px; cursor: zoom-in;
  border: 1px solid var(--border); background: var(--surface-3); }

.composer { flex: none; border-top: 1px solid var(--border); background: var(--surface); padding: 12px 16px; }
.composer textarea { width: 100%; border-radius: 14px; padding: 12px 14px; font-size: 14px; resize: none;
  background: var(--surface-2); border-color: var(--border); }
.composer textarea:focus { background: var(--surface); }
.acts { display: flex; gap: 9px; margin-top: 11px; flex-wrap: wrap; align-items: center; }
.acts-inline { display: contents; }
.acts select { margin-left: auto; max-width: 180px; }

/* booking panel */
.booking { margin: 12px 20px 0; padding: 14px 16px; display: grid; gap: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.booking .line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.slots { display: flex; gap: 6px; flex-wrap: wrap; }
.slots button { font-variant-numeric: tabular-nums; }
.slots button.selected { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* request rail */
.rail { background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; padding: 18px; min-width: 0; }
.rail .desc { margin: 12px 0 0; padding: 11px 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; font-size: 13px;
  color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.rail .ai { margin-top: 16px; }
.rail .tl { margin-top: 18px; }
.rail .hint { margin-top: 12px; font-size: 12px; color: var(--muted); }
.rail .rail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.rail .rail-actions select { flex: 1; min-width: 0; }
.rail .outcome-note { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; opacity: .75; }
.rail .outcome-note select, .rail .outcome-note input { font-size: 12px; }
.client-card { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 8px;
  font-size: 12.5px; color: var(--ink-soft); }
.client-card .line { display: flex; gap: 8px; align-items: flex-start; }
.client-card .line .ic { margin-top: 1px; color: var(--muted); }
.client-card .line input { flex: 1; min-width: 0; padding: 4px 8px; font-size: 13px; } /* имя клиента, 05.11 */
.client-card .actions { display: flex; flex-wrap: wrap; gap: 6px; }

#photo-dialog form { text-align: right; margin-top: 10px; }

.client-card .line .visits-btn { border: none; background: none; color: var(--accent); cursor: pointer;
  font-size: 12.5px; padding: 0; margin-left: 4px; font-family: inherit; text-decoration: underline; }
.visits-dialog { width: min(420px, 92vw); }
.visits-dialog h3 { margin: 0 0 10px; font-size: 15px; }
.visits-dialog form { text-align: right; margin-top: 12px; }
.visits-dialog .total { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; }
.visits-dialog .visit { padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.visits-dialog .visit:first-of-type { border-top: none; }
.visits-dialog .visit .d { font-weight: 700; }
.visits-dialog .visit .s { color: var(--ink-soft); margin-top: 2px; }
.visits-dialog .empty { color: var(--ink-soft); font-size: 13px; }

/* responsive */
.tnav .user .lbl { white-space: nowrap; }
@media (max-width: 1560px) { .tnav .lbl { display: none; } }
@media (max-width: 1280px) { .fmeta, .wait-summary { display: none; } }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 320px minmax(0, 1fr); }
  .thread-view { grid-template-columns: minmax(0, 1fr); }
  .rail-toggle { display: inline-flex; }
  .rail { position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 100%); z-index: 5; box-shadow: var(--shadow-lg);
    display: none; }
  .thread.rail-open .rail { display: block; }
  .rail-toggle.on { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
}
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 0 10px; }
  .funnel, .wait-summary, .brand .clinic, .tnav .user { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .app.has-thread .list { display: none; }
  .app:not(.has-thread) .thread { display: none; }
  .back { display: inline-flex; }
  .conv-h { padding: 10px 12px; gap: 8px; }
  .conv-h .avatar { display: none; }
  .msgs { padding: 14px 12px; }
  .bub { max-width: 88%; }
  .composer { padding: 10px 12px; }
  .acts select { margin-left: 0; max-width: 100%; flex: 1; }
  .booking { margin: 10px 12px 0; }
  .rail { width: 100%; }
}
.handoff { border-color: var(--accent-soft); }
.head-acts { display: flex; gap: 8px; flex: none; }
.head-acts:empty { display: none; }
.head-acts .handoff-btn { border-color: var(--accent); color: var(--accent-ink); }
@media (max-width: 760px) { .head-acts .handoff-btn .lbl { display: none; } }


/* Связной (09.11): счётчик «Разобрать» */
.list .tabs .tab-n { font-style: normal; margin-left: 6px; min-width: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; display: inline-block; }

/* Связной (09.11): черновик бота над полем ответа */
.bot-draft { margin: 8px 12px 0; padding: 10px 12px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--surface, #fff); }
.bot-draft .bd-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.bot-draft .bd-head .muted { font-size: 12px; }
.bot-draft .bd-text { white-space: pre-wrap; margin: 6px 0 8px; font-size: 14px; }
.bot-draft .bd-acts { display: flex; gap: 8px; flex-wrap: wrap; }
