/* Chat view: conversation region, searchable conversation list, bubbles, reply
   tags, participant-change rows, composer, and request rows. */

/* The conversation list now lives in the navigation panel, so the centre is a
   single column: header, bubbles, composer. */
.conv-region {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--wf-surface);
}

.conv-region .app-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Conversation list */

.chat-search-summary {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: var(--wf-space-3);
  margin-bottom: var(--wf-space-2);
  padding: var(--wf-space-2) var(--wf-space-3) var(--wf-space-3);
  border-bottom: 1px solid var(--wf-border);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-line);
}

.chat-search-summary[hidden] {
  display: none;
}

.chat-search-summary strong {
  color: var(--wf-text);
}

.chat-search-summary__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wf-space-3);
}

.chat-search-summary__action {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--wf-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.chat-search-summary__action:hover {
  text-decoration: underline;
}

.chat-search-summary__clear {
  color: var(--wf-text);
  font-weight: 700;
  text-decoration: none;
}

.chat-search-summary__clear:hover {
  text-decoration: underline;
}

.app-empty--compact {
  padding: var(--wf-space-6) var(--wf-space-3);
}

.app-empty--compact .app-empty__body {
  max-width: 240px;
}

.conv-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  gap: 2px;
  list-style: none;
}

/* Rendered as a button in the live list and as a link where it is context
   only, so the row must not inherit link decoration. */
.conv {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-2) var(--wf-space-3);
  border: 0;
  border-radius: var(--wf-radius-3);
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

.conv:hover {
  background: var(--wf-gray-100);
}

.conv[aria-current="true"],
.conv[aria-current="true"]:hover {
  background: var(--wf-gray-200);
}

.conv__body {
  min-width: 0;
}

.conv__names {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  min-width: 0;
  font-size: var(--wf-text-sm);
}

.conv__names-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv__names .wf-icon {
  width: 13px;
  height: 13px;
  color: var(--wf-gray-500);
}

.conv__preview {
  display: block;
  overflow: hidden;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv[data-unread="true"] .conv__names,
.conv[data-unread="true"] .conv__preview {
  color: var(--wf-text);
  font-weight: 700;
}

.conv__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--wf-space-1);
}

.conv__time {
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
  white-space: nowrap;
}

.conv__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--wf-gray-600);
}

.conv[data-unread="false"] .conv__dot {
  visibility: hidden;
}

.conv mark,
.conv-head mark,
.bubbles mark,
.details-block mark {
  padding: 0 2px;
  background: var(--wf-gray-300);
  color: inherit;
  font-weight: 700;
}

/* Conversation header */

.conv-head {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: 60px;
  padding: var(--wf-space-2) var(--wf-space-4);
  border-bottom: 1px solid var(--wf-border);
}

.conv-head__body {
  flex: 1;
  min-width: 0;
}

.conv-head__names {
  overflow: hidden;
  font-size: var(--wf-text-md);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-head__meta {
  overflow: hidden;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-head__tools {
  display: flex;
  align-items: center;
  gap: var(--wf-space-1);
}

.conv-head__tools .wf-icon {
  width: 16px;
  height: 16px;
}

/* Thread of bubbles */

.thread-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--wf-space-5) var(--wf-space-5) var(--wf-space-3);
  background: var(--wf-gray-25);
}

.bubbles {
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-3);
  width: min(100%, 720px);
  margin-inline: auto;
}

.chat-search-empty-center {
  align-self: stretch;
  margin: auto;
  padding-block: var(--wf-space-8);
}

.day-mark {
  align-self: center;
  padding: 2px var(--wf-space-3);
  border: 1px solid var(--wf-border);
  border-radius: 999px;
  background: var(--wf-white);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
}

/* Participant-change row */

.system-row {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-1) 0;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
}

.system-row::before,
.system-row::after {
  flex: 1;
  height: 1px;
  background: var(--wf-border);
  content: "";
}

.system-row__text {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
  text-align: center;
}

.system-row__text .wf-icon {
  width: 14px;
  height: 14px;
}

/* Subject change marker */

.subject-mark {
  align-self: center;
  max-width: 100%;
  overflow: hidden;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-mark strong {
  color: var(--wf-text-muted);
}

/* Message bubble */

.msg {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: var(--wf-space-2);
  max-width: 82%;
}

.msg--own {
  grid-template-columns: minmax(0, 1fr);
  margin-left: auto;
  justify-items: end;
}

.msg__avatar {
  align-self: end;
  margin-bottom: 18px;
}

.msg[data-grouped="true"] .msg__avatar {
  visibility: hidden;
}

.msg__stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg--own .msg__stack {
  align-items: flex-end;
}

.msg__sender {
  padding-left: var(--wf-space-3);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
  font-weight: 700;
}

.msg[data-grouped="true"] .msg__sender {
  display: none;
}

/* Reply tag: the messenger rendering of an email reply relationship */

.reply-tag {
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  margin-bottom: -2px;
  padding: var(--wf-space-1) var(--wf-space-3);
  border: 1px solid var(--wf-border);
  border-bottom: 0;
  border-radius: var(--wf-radius-3) var(--wf-radius-3) 0 0;
  background: var(--wf-gray-100);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
  text-align: left;
}

.reply-tag:hover {
  background: var(--wf-gray-200);
  color: var(--wf-text);
}

.reply-tag .wf-icon {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.reply-tag__who {
  flex: 0 0 auto;
  font-weight: 700;
}

.reply-tag__quote {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg__body {
  position: relative;
  max-width: 100%;
  padding: var(--wf-space-2) var(--wf-space-3);
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius-4);
  background: var(--wf-white);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-line);
}

.msg__body p {
  margin: 0 0 var(--wf-space-2);
}

.msg__body p:last-child {
  margin-bottom: 0;
}

.msg--own .msg__body {
  border-color: var(--wf-gray-500);
  background: var(--wf-gray-500);
  color: var(--wf-white);
}

.msg--own .reply-tag {
  border-color: var(--wf-gray-400);
  background: var(--wf-gray-200);
  color: var(--wf-gray-700);
}

.msg[data-highlight="true"] .msg__body {
  border-color: var(--wf-gray-700);
  box-shadow: 0 0 0 3px var(--wf-gray-200);
}

.msg__attachment {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
  margin-top: var(--wf-space-2);
  padding: var(--wf-space-1) var(--wf-space-2);
  border: 1px solid var(--wf-border-strong);
  border-radius: var(--wf-radius-2);
  background: var(--wf-gray-50);
  color: var(--wf-text);
  font-size: var(--wf-text-2xs);
}

.msg__attachment .wf-icon {
  width: 13px;
  height: 13px;
  color: var(--wf-gray-500);
}

.msg__foot {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  padding-inline: var(--wf-space-2);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
}

.msg__reply {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-1);
  background: transparent;
  color: var(--wf-text-subtle);
  opacity: 0;
}

.msg__reply .wf-icon {
  width: 13px;
  height: 13px;
}

.msg:hover .msg__reply,
.msg:focus-within .msg__reply {
  opacity: 1;
}

.msg__reply:hover {
  background: var(--wf-gray-200);
  color: var(--wf-text);
}

/* Composer */

.composer {
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-2);
  padding: var(--wf-space-3) var(--wf-space-4);
  border-top: 1px solid var(--wf-border);
  background: var(--wf-surface);
}

.composer[hidden] {
  display: none;
}

.composer__chip {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  padding: var(--wf-space-2) var(--wf-space-3);
  border-left: 3px solid var(--wf-gray-500);
  border-radius: var(--wf-radius-2);
  background: var(--wf-gray-50);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
}

.composer__chip[hidden] {
  display: none;
}

.composer__chip-body {
  flex: 1;
  min-width: 0;
}

.composer__chip-who {
  display: block;
  color: var(--wf-text);
  font-weight: 700;
}

.composer__chip-quote {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer__row {
  display: flex;
  align-items: flex-end;
  gap: var(--wf-space-2);
}

/* The input and the emoji trigger share one rounded field. */
.composer__field {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}

.composer__input {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  padding: var(--wf-space-2) var(--wf-space-10) var(--wf-space-2) var(--wf-space-3);
  border: 1px solid var(--wf-border-strong);
  border-radius: var(--wf-radius-4);
  background: var(--wf-white);
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  resize: none;
}

.composer__emoji {
  position: absolute;
  right: var(--wf-space-1);
  bottom: 4px;
}

.composer__row .composer__emoji .wf-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: var(--wf-radius-2);
  color: var(--wf-text-subtle);
}

.composer__row .composer__emoji .wf-icon {
  width: 16px;
  height: 16px;
}

.composer__emoji-panel {
  right: 0;
  left: auto;
  width: 288px;
  max-height: 260px;
  overflow: auto;
  padding: var(--wf-space-3);
}

.composer__emoji-heading {
  margin: 0 0 var(--wf-space-2);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.composer__emoji-heading + .composer__emoji-grid {
  margin-bottom: var(--wf-space-3);
}

.composer__emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.composer__emoji-key {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-2);
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.composer__emoji-key:hover {
  background: var(--wf-gray-100);
}

.composer__row .wf-button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 999px;
}

.composer__row .wf-icon {
  width: 17px;
  height: 17px;
}

/* Conversation details panel */

.details-block + .details-block {
  margin-top: var(--wf-space-5);
  padding-top: var(--wf-space-5);
  border-top: 1px solid var(--wf-border);
}

.details-block__title {
  margin: 0 0 var(--wf-space-3);
  font-size: var(--wf-text-sm);
  font-weight: 700;
}

/* Request rows */

.request-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.request {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--wf-space-3);
  padding: var(--wf-space-3);
  border-radius: var(--wf-radius-3);
  background: transparent;
}

.request:hover {
  background: var(--wf-gray-50);
}

.request[aria-current="true"],
.request[aria-current="true"]:hover {
  background: var(--wf-gray-200);
}

.request__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-2);
}

.request__who {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--wf-space-2);
  font-size: var(--wf-text-sm);
  font-weight: 700;
}

.request__address {
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  font-weight: 400;
}

.request__subject {
  font-size: var(--wf-text-sm);
}

.request__snippet {
  margin: 0;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
}

.request__participants {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-1);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
}

.request__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2);
  padding-top: var(--wf-space-1);
}

.request__actions .wf-button {
  min-height: 30px;
  padding: 0 var(--wf-space-3);
  font-size: var(--wf-text-xs);
}

.request__actions .wf-icon {
  width: 14px;
  height: 14px;
}

/* The overlay makes the whole row selectable; the action buttons sit above it.
   .request__body stays static so it does not trap the buttons in its own
   stacking context. */
.request__open {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: transparent;
}

.request__actions {
  position: relative;
  z-index: 3;
}

.request-preview {
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-4);
  padding: var(--wf-space-5);
}

.request-preview__head {
  display: flex;
  align-items: flex-start;
  gap: var(--wf-space-3);
  padding-bottom: var(--wf-space-4);
  border-bottom: 1px solid var(--wf-border);
}

.request-preview__body {
  font-size: var(--wf-text-sm);
}

.request-preview__body p {
  margin: 0 0 var(--wf-space-3);
}

@media (max-width: 899.98px) {
  .msg {
    max-width: 92%;
  }

  .thread-scroll {
    padding: var(--wf-space-4) var(--wf-space-3);
  }
}
