.dm-wrapper {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 8px;
  height: 600px;
  overflow: hidden;brightness(0.9)
  background: #fff;
}

.dm-list { width: 35%; border-right: 1px solid #eee; overflow-y: auto; }
.dm-list-header { padding: 12px; font-weight: 700; background: #f8f8f8; border-bottom: 1px solid #eee; display: flex; align-items: center; gap: 8px; }
.dm-list ul { list-style: none; margin: 0; padding: 0; }
.dm-thread { cursor: pointer; border-bottom: 1px solid #f3f3f3; transition: background .15s; }
.dm-thread:hover { background: #fafafa; }
.dm-thread.active { background: var(--ast-global-color-5); }
.thread-box { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; }
.thread-name { font-weight: 600; }
.thread-date { font-size: 12px; color: #999; }

.dm-chat { flex: 1; display: flex; flex-direction: column; }
.dm-messages { flex: 1; overflow-y: auto; padding: 14px; max-height: 600px; }

.dm-message { margin-bottom: 10px; display: flex; align-items: flex-start; word-wrap: break-word; }
.dm-message.me { justify-content: flex-end; }
.dm-message.me span {
  background: var(--ast-global-color-0);
  color: #fff;
  border-radius: 16px;
  padding: 8px 12px;
  display: inline-block;
  max-width: 100%;
  min-width: fit-content;
  word-break: break-word;
}
.dm-message.them { color: #333; }
.dm-avatar { width: 36px; height: 36px; border-radius: 50%; margin-right: 8px; object-fit: cover; }
.dm-bubble { background: #f2f2f2; padding: 8px 12px; border-radius: 12px; max-width: 100%; }
.dm-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #333; }
.dm-text { line-height: 1.4; color: #222; }

.dm-input { display: flex; border-top: 1px solid #eee; }
.dm-input input { flex: 1; border: none; padding: 12px; outline: none; }
.dm-input button { border: none; background: var(--ast-global-color-0); color: #fff; padding: 12px 16px; cursor: pointer; transition: opacity .2s; }
.dm-input button[disabled], .dm-input input[disabled] { cursor: default; opacity: 0.5; background: #ccc; }

.dm-unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ff4d4f;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

.dm-avatar-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  margin-right: 8px;
  flex-shrink: 0;
}

.dm-avatar-wrap img.dm-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
}

.dm-avatar-wrap img.dm-avatar.default {
  z-index: 1;
}

.dm-avatar-wrap img.dm-avatar.overlay {
  z-index: 2;
}

/* Mobile layout: list on top, chat below */
@media (max-width: 768px) {
  .dm-wrapper { flex-direction: column; height: auto; }
  .dm-list {
    width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid #eee;
    height: 40vh;
    max-height: 40vh;
    overflow-y: auto;
  }
  .dm-chat { width: 100%; height: auto; }
}

/* Admin page layout */
.sdm-read.yes {
  color: #4CAF50;
  font-weight: 600;
}
.sdm-read.no {
  color: #F44336;
  font-weight: 600;
}
.wrap table.widefat td {
  vertical-align: top;
}

.dm-time {
  font-size: 0.75em;
  color: #999;
  margin-top: 4px;
  text-align: right;
  display: block;
  white-space: nowrap;
}

.dm-message.me {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.dm-message.me .dm-time {
  margin-top: 4px;
  margin-right: 6px;
  text-align: right;
}

.dm-message.them {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 12px;
}
.dm-message.them .dm-top {
  display: flex;
  align-items: flex-start;
}
.dm-message.them .dm-time {
  font-size: 0.75em;
  color: #999;
  margin-left: 45px;
}

.dm-status-icon {
  position: relative;
  display: inline-block;
}

.dm-status-icon:hover .ast-card-action-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateX(-4px);
}
