/* Concierge Desk — post-acceptance brokering (mediation) view.

   A brokering MODE of the job workspace: a pinned brokering bar over two
   side-by-side channels (homeowner SMS, left; provider channel, right).
   Spans the full workspace frame (the rail is folded away in this mode).
   Stacks on narrow widths with a sticky channel switcher. */

.broker {
  grid-column: 1 / -1; min-width: 0; min-height: 0;
  display: grid; grid-template-rows: auto 1fr; background: var(--ha-surface);
}

/* ---- brokering bar (the "is this job safe" reading) ---- */
.broker-bar {
  border-bottom: 1px solid var(--ha-border); background: var(--ha-surface);
  padding: 14px 24px; display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.6fr) auto;
  gap: 8px 22px; align-items: start;
}
.broker-bar .blk { min-width: 0; }
.broker-bar .lab {
  font-size: 11px; color: var(--ha-ink-muted); text-transform: uppercase;
  letter-spacing: 0.03em; font-weight: var(--ha-weight-medium);
}

.appt { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.appt .when { font-size: 18px; font-weight: var(--ha-weight-bold); letter-spacing: -0.01em; }
.appt .when.unset { color: var(--ha-ink-muted); font-weight: var(--ha-weight-medium); }
.appt .edit {
  background: none; border: 0; padding: 0; font: inherit; font-size: 12px;
  color: var(--ha-blue-text); cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.appt-job-line { font-size: 12px; color: var(--ha-ink-muted); margin-top: 3px; }

.appt-edit { margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.appt-edit[hidden] { display: none; }
.appt-edit input[type="datetime-local"],
.appt-edit input[type="text"] {
  height: 32px; border: 1px solid var(--ha-border); border-radius: var(--ha-radius-md);
  padding: 0 10px; font: inherit; font-size: 13px; color: var(--ha-ink);
  background: var(--ha-surface);
}
.appt-edit input:focus { outline: none; border-color: var(--ha-blue-accent); box-shadow: var(--ha-focus-ring); }

/* reminder + confirmation timeline */
.timeline {
  margin-top: 5px; display: grid; grid-template-columns: auto 1fr 1fr;
  gap: 7px 14px; align-items: center; font-size: 12px;
}
.timeline .h { color: var(--ha-ink-muted); font-size: 11px; font-weight: var(--ha-weight-medium); }
.timeline .offset { color: var(--ha-ink-muted); font-size: 11px; }

.pillst {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: var(--ha-radius-pill); font-size: 12px; font-weight: var(--ha-weight-medium);
  width: max-content;
}
.pillst svg { width: 12px; height: 12px; flex: none; }
.pillst.st-sent { background: var(--ha-border-strong); color: var(--ha-remind-sent); }
.pillst.st-confirmed { background: var(--ha-remind-confirmed-bg); color: var(--ha-remind-confirmed); }
.pillst.st-at-risk { background: var(--ha-remind-at-risk-bg); color: var(--ha-remind-at-risk); }
.pillst.st-none { background: transparent; color: var(--ha-ink-muted); padding-left: 0; }

.broker-bar .actions {
  display: flex; gap: 8px; justify-self: end; align-self: center; flex-wrap: wrap;
}

.broker-note {
  grid-column: 1 / -1; margin-top: 2px; font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.broker-note.ok { color: var(--ha-success); }
.broker-note.warn { color: var(--ha-ink-muted); }
.broker-note svg { width: 13px; height: 13px; flex: none; }

/* fulfilled / lost terminal banners */
.broker-terminal {
  grid-column: 1 / -1; margin-top: 4px; padding: 9px 13px; font-size: 13px;
  border-radius: var(--ha-radius-md); display: inline-flex; align-items: center; gap: 8px;
}
.broker-terminal.fulfilled { background: var(--ha-success-tint); border: 1px solid var(--ha-success-edge); }
.broker-terminal.lost { background: var(--ha-danger-bg); border: 1px solid var(--ha-danger); color: var(--ha-danger); }
.broker-terminal svg { width: 15px; height: 15px; flex: none; }

/* ---- channel switcher (narrow widths only) ---- */
.channel-switcher { display: none; }

/* ---- two channels ---- */
.channels { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; min-width: 0; }
.chan {
  display: grid; grid-template-rows: auto 1fr auto; min-height: 0; min-width: 0;
  border-right: 1px solid var(--ha-border);
}
.chan:last-child { border-right: 0; }

.chan-head {
  padding: 11px 18px; border-bottom: 1px solid var(--ha-border-strong);
  display: flex; align-items: center; gap: 10px;
  font-weight: var(--ha-weight-bold); font-size: 13px;
}
.chan-head .tag { font-size: 11px; font-weight: var(--ha-weight-medium); color: var(--ha-ink-muted); }
.chan.home .chan-head {
  background: var(--ha-channel-homeowner); box-shadow: inset 0 -2px 0 0 var(--ha-channel-homeowner-edge);
}
.chan.prov .chan-head {
  background: var(--ha-channel-provider); box-shadow: inset 0 -2px 0 0 var(--ha-channel-provider-edge);
}
.chan-head .who-ico {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ha-surface); flex: none;
}
.chan.home .who-ico { background: var(--ha-blue-text); }
.chan.prov .who-ico { background: var(--ha-blue-primary-soft); }
.chan-head .who-ico svg { width: 13px; height: 13px; }

.chan-thread {
  overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px;
}
.chan-empty { color: var(--ha-ink-muted); font-size: 13px; text-align: center; padding: 28px 12px; }

.cmsg { max-width: 86%; }
.cmsg .bubble { padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 20px; }
.cmsg.in .bubble {
  background: var(--ha-surface-subtle); border: 1px solid var(--ha-border);
  border-bottom-left-radius: 5px;
}
.cmsg.out { align-self: flex-end; }
.cmsg.out .bubble {
  background: var(--ha-blue-primary); color: var(--ha-surface); border-bottom-right-radius: 5px;
}
.cmsg .foot { font-size: 11px; color: var(--ha-ink-muted); margin-top: 4px; }
.cmsg.out .foot { text-align: right; }

.relay-row { margin-top: 5px; }
.relay-btn {
  font: inherit; font-size: 11px; color: var(--ha-blue-text); background: none; border: 0;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 2px 0;
}
.relay-btn svg { width: 12px; height: 12px; }
.relay-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

.csys {
  align-self: center; font-size: 11px; color: var(--ha-ink-muted);
  background: var(--ha-surface-subtle); border: 1px solid var(--ha-border-strong);
  padding: 3px 11px; border-radius: var(--ha-radius-pill);
  display: inline-flex; gap: 6px; align-items: center; text-align: center;
}
.csys svg { width: 12px; height: 12px; color: var(--ha-success); flex: none; }

/* ---- voice card (consent / processing / suggested) ---- */
.voice {
  align-self: stretch; background: var(--ha-surface); border: 1px solid var(--ha-border);
  border-radius: var(--ha-radius-md); padding: 12px 14px; box-shadow: var(--ha-shadow-card);
}
.voice .vh { font-size: 12px; font-weight: var(--ha-weight-bold); display: flex; align-items: center; gap: 7px; }
.voice .vh svg { width: 14px; height: 14px; color: var(--ha-blue-primary-soft); flex: none; }
.voice .proc { font-size: 12px; color: var(--ha-ink-muted); margin-top: 7px; display: inline-flex; align-items: center; gap: 6px; }
.voice .dotpulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ha-voice-pulse);
  animation: voice-pulse 1.2s ease-in-out infinite;
}
@keyframes voice-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.voice .ai-extract[hidden] { display: none; }
.voice .ai-extract {
  margin-top: 9px; background: var(--ha-ai-surface); border: 1px dashed var(--ha-ai-border);
  border-radius: var(--ha-radius-sm); padding: 10px 12px;
}
.voice .ai-extract .al {
  font-size: 10px; font-weight: var(--ha-weight-bold); color: var(--ha-blue-text);
  text-transform: uppercase; letter-spacing: 0.02em; display: flex; gap: 6px; align-items: center;
}
.voice .ai-extract .al svg { width: 11px; height: 11px; flex: none; }
.voice .ai-extract .row { font-size: 13px; margin-top: 6px; }
.voice .ai-extract .edit-row { display: none; margin-top: 7px; }
.voice .ai-extract .edit-row.open { display: block; }
.voice .ai-extract .edit-input {
  width: 100%; border: 1px solid var(--ha-border); border-radius: var(--ha-radius-sm);
  padding: 6px 8px; font: inherit; font-size: 13px; color: var(--ha-ink);
}
.voice .ai-extract .acts { display: flex; gap: 6px; margin-top: 9px; }
.voice .voice-done { font-size: 12px; color: var(--ha-success); margin-top: 7px; display: inline-flex; gap: 6px; align-items: center; }
.voice .voice-done svg { width: 13px; height: 13px; flex: none; }

/* ---- provider quick-template chips (the brokering-pane provider chips reuse
   .tpl; the homeowner-relay composer was removed -- warm relays go in the
   homeowner thread directly) ---- */
.tpl {
  height: 26px; padding: 0 11px; border-radius: var(--ha-radius-pill);
  border: 1px dashed var(--ha-border); background: var(--ha-surface); font: inherit;
  font-size: 11px; cursor: pointer; color: var(--ha-ink);
}
.tpl:hover { border-color: var(--ha-blue-accent); background: var(--ha-row-hover); }
.tpl:focus-visible { outline: none; box-shadow: var(--ha-focus-ring); }

/* ---- narrow: stack channels (homeowner first), sticky switcher, bar pinned ---- */
@media (max-width: 1000px) {
  .broker-bar { grid-template-columns: 1fr; }
  .broker-bar .actions { justify-self: start; }

  .channel-switcher {
    display: flex; gap: 8px; padding: 9px 16px; position: sticky; top: 0; z-index: 2;
    background: var(--ha-surface); border-bottom: 1px solid var(--ha-border-strong);
  }
  .channel-switcher button {
    height: 30px; padding: 0 14px; border-radius: var(--ha-radius-pill); font: inherit;
    font-size: 12px; font-weight: var(--ha-weight-medium); cursor: pointer;
    border: 1px solid var(--ha-border); background: var(--ha-surface); color: var(--ha-ink-muted);
  }
  .channel-switcher button.active {
    background: var(--ha-blue-primary); color: var(--ha-surface); border-color: var(--ha-blue-primary);
  }
  .channel-switcher button:focus-visible { outline: none; box-shadow: var(--ha-focus-ring); }

  .channels { grid-template-columns: 1fr; }
  .chan { border-right: 0; }
  .chan[data-channel-switcher-target="panel"][hidden] { display: none; }
}

/* ---- embedded provider channel (rendered standalone in the lane stage zone,
   not inside .channels): drop the inter-channel right border and bound the
   thread so it scrolls rather than running forever in the lane flow. ---- */
.stage .chan.prov { border-right: 0; }
.stage .chan.prov .chan-thread { max-height: 360px; }
