/* Unified conversation presentation for Groups, Direct and Support.
   This layer is visual only: it does not change message transport or APIs. */

.conversation-reference-surface {
  --conversation-accent: #0f747b;
  --conversation-accent-strong: #075b62;
  --conversation-border: #dbe6ea;
  --conversation-muted: #6b7c87;
  --conversation-surface: #ffffff;
  --conversation-canvas: #f8fbfc;
  overflow: hidden;
  border-color: var(--conversation-border);
  background: var(--conversation-surface);
}

.conversation-reference-surface .admin-inbox-thread-header,
.conversation-reference-surface .group-chat-header {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--conversation-border);
  background: rgba(255, 255, 255, 0.98);
}

.conversation-reference-surface .admin-inbox-thread-messages,
.conversation-reference-surface .group-message-list {
  box-sizing: border-box;
  display: flex;
  min-block-size: 0;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(246, 250, 251, 0.72), rgba(255, 255, 255, 0.94));
  scrollbar-gutter: stable;
}

.conversation-message-row {
  box-sizing: border-box;
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: flex-end;
  gap: 8px;
}

.conversation-message-row.theirs {
  justify-content: flex-start;
}

.conversation-message-row.mine {
  justify-content: flex-end;
}

.conversation-message-avatar {
  display: inline-flex;
  width: 34px;
  height: 34px;
  min-width: 34px;
  flex: 0 0 34px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: linear-gradient(145deg, #198a91, #0e6970);
  box-shadow: 0 3px 10px rgba(15, 116, 123, 0.16);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.conversation-message-row.theirs .conversation-message-avatar {
  background: linear-gradient(145deg, #2f80c9, #3978b4);
}

.conversation-reference-surface .conversation-message-row .direct-message-bubble {
  box-sizing: border-box;
  width: fit-content;
  max-width: min(72%, 760px);
  min-width: 0;
  margin: 0 !important;
  padding: 10px 13px 8px;
  border: 1px solid var(--conversation-border);
  border-radius: 15px 15px 15px 5px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.055);
  color: #1d2933;
  overflow-wrap: anywhere;
}

.conversation-reference-surface .conversation-message-row.mine .direct-message-bubble {
  border-color: color-mix(in srgb, var(--conversation-accent) 78%, white);
  border-radius: 15px 15px 5px 15px;
  background: linear-gradient(145deg, var(--conversation-accent), var(--conversation-accent-strong));
  box-shadow: 0 4px 12px rgba(9, 93, 99, 0.13);
  color: #ffffff;
}

.conversation-reference-surface .direct-message-bubble .message-sender-label {
  display: block;
  margin: 0 24px 4px 0;
  color: #2476c8;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.25;
}

.conversation-reference-surface .conversation-message-row.mine .message-sender-label {
  display: none;
}

.conversation-reference-surface .direct-message-bubble p,
.conversation-reference-surface .direct-message-bubble .message-text,
.conversation-reference-surface .direct-message-bubble .group-message-text {
  margin-block: 0;
  line-height: 1.48;
}

.conversation-reference-surface .conversation-message-row.mine .direct-message-bubble a {
  color: #e8ffff;
}

.conversation-reference-surface .message-action-trigger {
  opacity: 0.72;
}

.conversation-reference-surface .conversation-message-row.mine .message-action-trigger {
  color: #ffffff;
}

.conversation-reference-surface .conversation-message-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 5px;
  color: var(--conversation-muted);
  font-size: 0.64rem;
  line-height: 1.2;
}

.conversation-reference-surface .conversation-message-row.mine .conversation-message-meta {
  color: rgba(255, 255, 255, 0.78);
}

.conversation-reference-surface .conversation-message-meta .message-bubble-time {
  margin: 0 !important;
  color: inherit !important;
  font-size: inherit !important;
}

.conversation-sent-indicator {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

/* Only actual system/typing elements are enhanced. This stylesheet never
   fabricates presence, read or delivery state. */
.conversation-reference-surface .conversation-system-row,
.conversation-reference-surface [data-system-message],
.conversation-reference-surface .system-message,
.conversation-reference-surface .group-system-message,
.conversation-reference-surface .message-system-event {
  box-sizing: border-box;
  width: 100%;
  margin: 2px 0;
  padding: 8px 12px;
  border: 1px solid #dbe7e9;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  color: #337178;
  font-size: 0.76rem;
  line-height: 1.35;
}

.conversation-reference-surface .conversation-typing-row,
.conversation-reference-surface [data-typing-indicator],
.conversation-reference-surface .typing-indicator,
.conversation-reference-surface .message-typing {
  align-self: flex-start;
  max-width: min(78%, 360px);
  padding: 7px 11px;
  border: 1px dashed #91c8cb;
  border-radius: 999px;
  background: #f6ffff;
  color: #18777d;
  font-size: 0.75rem;
  font-weight: 600;
}

.conversation-reference-surface .direct-message-composer,
.conversation-reference-surface .group-message-composer {
  box-sizing: border-box;
  margin: 0 !important;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--conversation-border);
  background: rgba(248, 251, 252, 0.98);
}

.conversation-reference-surface .message-composer-bar {
  min-height: 48px;
  gap: 5px;
  padding: 4px 5px;
  border: 1px solid #d6e2e6;
  border-radius: 25px;
  background: #ffffff;
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.08);
}

.conversation-reference-surface .message-composer-input {
  min-height: 38px;
  padding-block: 9px;
  background: transparent;
  line-height: 1.35;
}

.conversation-reference-surface .message-icon-button,
.conversation-reference-surface .message-send-button {
  flex: 0 0 auto;
}

.conversation-reference-surface .message-send-button {
  box-shadow: 0 3px 10px rgba(15, 116, 123, 0.18);
}

.conversation-reference-surface .message-composer-footer:empty,
.conversation-reference-surface .message-attachment-status:empty {
  display: none;
}

.conversation-reference-surface .direct-message-empty {
  display: grid;
  min-height: 0;
  padding: 28px 18px;
  place-items: center;
  color: var(--conversation-muted);
  text-align: center;
}

@media (max-width: 700px) {
  .conversation-reference-surface .admin-inbox-thread-messages,
  .conversation-reference-surface .group-message-list {
    gap: 7px;
    padding: 12px 9px 14px;
  }

  .conversation-message-row {
    gap: 5px;
  }

  .conversation-message-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    flex-basis: 28px;
    font-size: 0.58rem;
  }

  .conversation-reference-surface .conversation-message-row .direct-message-bubble {
    max-width: calc(100% - 40px);
    padding: 9px 11px 7px;
    border-radius: 14px 14px 14px 5px;
  }

  .conversation-reference-surface .conversation-message-row.mine .direct-message-bubble {
    border-radius: 14px 14px 5px 14px;
  }

  .conversation-reference-surface .direct-message-composer,
  .conversation-reference-surface .group-message-composer {
    padding: 7px 7px 9px;
  }
}
