/* Direct Messages — professional inbox */

.ec-dm-page {
  --dm-ink: #0f172a;
  --dm-muted: #64748b;
  --dm-line: rgba(15, 23, 42, 0.1);
  --dm-surface: #ffffff;
  --dm-surface-2: #f8fafc;
  --dm-green: #217c46;
  --dm-gold: #c9a227;
  --dm-mine: #217c46;
  --dm-theirs: #eef2f7;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 0;
  min-height: calc(100dvh - 7.5rem);
  border: 1px solid var(--dm-line);
  border-radius: 1rem;
  overflow: hidden;
  background: var(--dm-surface);
  color: var(--dm-ink);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

html.dark .ec-dm-page {
  --dm-ink: rgba(255, 255, 255, 0.94);
  --dm-muted: rgba(255, 255, 255, 0.55);
  --dm-line: rgba(255, 255, 255, 0.1);
  --dm-surface: rgba(8, 14, 24, 0.92);
  --dm-surface-2: rgba(255, 255, 255, 0.04);
  --dm-theirs: rgba(255, 255, 255, 0.08);
}

.ec-dm-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--dm-line);
  background: linear-gradient(180deg, var(--dm-surface) 0%, var(--dm-surface-2) 100%);
  min-height: 0;
}

.ec-dm-sidebar__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.15rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--dm-line);
}

.ec-dm-kicker {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dm-gold);
}

.ec-dm-sidebar__head h1 {
  margin: 0.15rem 0 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.ec-dm-sidebar__head p {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--dm-muted);
  line-height: 1.4;
}

.ec-dm-badge {
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ec-dm-sidebar__actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--dm-line);
}

.ec-dm-btn {
  border: 1px solid var(--dm-line);
  background: var(--dm-surface-2);
  color: var(--dm-ink);
  border-radius: 0.65rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.ec-dm-btn--primary {
  background: var(--dm-green);
  border-color: transparent;
  color: #fff;
}

.ec-dm-list {
  flex: 1;
  overflow: auto;
  padding: 0.5rem;
  min-height: 0;
}

.ec-dm-conv {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  border-radius: 0.85rem;
  padding: 0.7rem;
  cursor: pointer;
  margin-bottom: 0.25rem;
}

.ec-dm-conv:hover {
  background: var(--dm-surface-2);
}

.ec-dm-conv.is-active {
  background: rgba(33, 124, 70, 0.1);
  border-color: rgba(33, 124, 70, 0.25);
}

.ec-dm-conv.has-unread strong {
  font-weight: 800;
}

.ec-dm-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #217c46, #0f766e);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.ec-dm-avatar--lg {
  width: 2.85rem;
  height: 2.85rem;
  font-size: 0.9rem;
}

.ec-dm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ec-dm-conv__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ec-dm-conv__top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.ec-dm-conv__top strong {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ec-dm-conv__top time,
.ec-dm-conv__preview,
.ec-dm-conv__meta {
  font-size: 0.72rem;
  color: var(--dm-muted);
}

.ec-dm-conv__preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ec-dm-pill {
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--dm-green);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.2rem;
}

.ec-dm-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--dm-surface);
}

.ec-dm-thread-empty {
  margin: auto;
  text-align: center;
  padding: 2rem;
  color: var(--dm-muted);
}

.ec-dm-thread-empty h2 {
  margin: 0 0 0.35rem;
  color: var(--dm-ink);
  font-size: 1.15rem;
}

.ec-dm-thread-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--dm-line);
  background: var(--dm-surface-2);
}

.ec-dm-thread-head__meta h2 {
  margin: 0;
  font-size: 1.05rem;
}

.ec-dm-thread-head__meta p {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--dm-muted);
}

.ec-dm-stream {
  flex: 1;
  overflow: auto;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 280px;
  background:
    radial-gradient(ellipse at top, rgba(33, 124, 70, 0.05), transparent 50%),
    var(--dm-surface);
}

.ec-dm-bubble-row {
  display: flex;
  justify-content: flex-start;
}

.ec-dm-bubble-row.is-mine {
  justify-content: flex-end;
}

.ec-dm-bubble {
  max-width: min(72%, 520px);
  padding: 0.7rem 0.9rem;
  border-radius: 1rem;
  background: var(--dm-theirs);
  color: var(--dm-ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ec-dm-bubble-row.is-mine .ec-dm-bubble {
  background: var(--dm-mine);
  color: #fff;
  border-bottom-right-radius: 0.3rem;
}

.ec-dm-bubble-row:not(.is-mine) .ec-dm-bubble {
  border-bottom-left-radius: 0.3rem;
}

.ec-dm-bubble__text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.45;
}

.ec-dm-bubble__time {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.68rem;
  opacity: 0.72;
}

.ec-dm-composer {
  display: flex;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--dm-line);
  background: var(--dm-surface-2);
}

.ec-dm-composer textarea,
.ec-dm-field textarea,
.ec-dm-field input {
  width: 100%;
  border: 1px solid var(--dm-line);
  border-radius: 0.85rem;
  background: var(--dm-surface);
  color: var(--dm-ink);
  padding: 0.7rem 0.85rem;
  font: inherit;
  resize: vertical;
}

.ec-dm-composer textarea {
  flex: 1;
  min-height: 2.75rem;
  max-height: 8rem;
}

.ec-dm-send {
  align-self: flex-end;
  border: 0;
  border-radius: 0.75rem;
  background: var(--dm-green);
  color: #fff;
  font-weight: 700;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
}

.ec-dm-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ec-dm-empty {
  padding: 1rem;
  text-align: center;
  color: var(--dm-muted);
  font-size: 0.85rem;
}

.ec-dm-empty.is-error {
  color: #e11d48;
}

.ec-dm-compose-new {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.ec-dm-compose-body {
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ec-dm-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--dm-muted);
}

.ec-dm-search-results {
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ec-dm-search-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  border: 1px solid var(--dm-line);
  background: var(--dm-surface-2);
  color: inherit;
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
}

.ec-dm-search-item strong {
  display: block;
  font-size: 0.9rem;
}

.ec-dm-search-item em {
  display: block;
  font-style: normal;
  font-size: 0.72rem;
  color: var(--dm-muted);
}

.ec-dm-selected__chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.85rem;
  border-radius: 0.75rem;
  background: rgba(33, 124, 70, 0.1);
  border: 1px solid rgba(33, 124, 70, 0.25);
  font-size: 0.85rem;
}

.ec-dm-selected__chip button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--dm-green);
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 900px) {
  .ec-dm-page {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .ec-dm-sidebar {
    max-height: 42vh;
  }

  .ec-dm-thread {
    min-height: 55vh;
  }
}
