/* ========================================================
   Mindful Zen — Direct Messages (DM)
   Two-pane layout: thread list + active conversation.
   ======================================================== */

.dm-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.dm-loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--mag-ink-soft, #555);
}
.dm-loading-lotus {
  font-size: 48px;
  animation: cs-pulse 2s ease-in-out infinite;
  margin-bottom: 12px;
}

.dm-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  background: var(--mag-card, #fff);
  border: 1px solid var(--mag-border, #e5e5e5);
  border-radius: 18px;
  overflow: hidden;
  min-height: 600px;
}

/* ─── side panel ─── */
.dm-side {
  border-right: 1px solid var(--mag-border, #e5e5e5);
  display: flex;
  flex-direction: column;
  background: var(--mag-bg, #f7f7f7);
}
.dm-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--mag-border, #e5e5e5);
}
.dm-side-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--mag-ink, #1a1a1a);
}
.dm-new-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #0d9488);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.dm-new-btn:hover { transform: scale(1.05); }

.dm-admin-note {
  padding: 10px 14px;
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--mag-border, #e5e5e5);
}

.dm-threads {
  flex: 1;
  overflow-y: auto;
}
.dm-side-empty {
  padding: 30px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--mag-ink-soft, #888);
}

.dm-thread {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--mag-border, #e5e5e5);
  cursor: pointer;
  transition: background 0.12s;
}
.dm-thread:hover { background: var(--mag-card, #fff); }
.dm-thread-unread {
  background: rgba(13, 148, 136, 0.06);
}
.dm-thread-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #0d9488);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
}
.dm-thread-body { min-width: 0; }
.dm-thread-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.dm-thread-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--mag-ink, #1a1a1a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dm-thread-time {
  font-size: 11.5px;
  color: var(--mag-ink-soft, #888);
  flex-shrink: 0;
}
.dm-thread-sub {
  font-size: 11.5px;
  color: var(--mag-ink-soft, #888);
}
.dm-thread-snippet {
  font-size: 13px;
  color: var(--mag-ink-soft, #555);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── active conversation ─── */
.dm-conv {
  display: flex;
  flex-direction: column;
  min-height: 600px;
  position: relative;
}
.dm-conv-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--mag-ink-soft, #888);
}
.dm-conv-empty-icon { font-size: 48px; margin-bottom: 8px; }

.dm-admin-banner {
  padding: 10px 18px;
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.dm-conv-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--mag-border, #e5e5e5);
}
.dm-conv-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #0d9488);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  overflow: hidden;
}
.dm-conv-name-wrap { display: flex; flex-direction: column; }
.dm-conv-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--mag-ink, #1a1a1a);
  text-decoration: none;
}
.dm-conv-name:hover { text-decoration: underline; }
.dm-conv-handle {
  font-size: 12.5px;
  color: var(--mag-ink-soft, #888);
}

.dm-conv-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 56vh;
}
.dm-conv-loading {
  text-align: center;
  color: var(--mag-ink-soft, #888);
  font-size: 13px;
  padding: 30px 0;
}

.dm-msg {
  display: flex;
  max-width: 80%;
}
.dm-msg-mine  { align-self: flex-end; }
.dm-msg-other { align-self: flex-start; }

.dm-msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
}
.dm-msg-mine .dm-msg-bubble {
  background: linear-gradient(135deg, #7c3aed, #0d9488);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.dm-msg-other .dm-msg-bubble {
  background: var(--mag-bg, #f1f5f9);
  color: var(--mag-ink, #1a1a1a);
  border: 1px solid var(--mag-border, #e5e5e5);
  border-bottom-left-radius: 6px;
}
.dm-msg-content { word-wrap: break-word; white-space: pre-wrap; }
.dm-msg-time {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.75;
}
.dm-msg-trans {
  font-size: 11px;
  opacity: 0.75;
  margin-bottom: 4px;
  font-style: italic;
}

.dm-conv-form {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--mag-border, #e5e5e5);
}
.dm-conv-form textarea {
  flex: 1;
  border: 1px solid var(--mag-border, #e5e5e5);
  border-radius: 16px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  outline: none;
  background: var(--mag-card, #fff);
  color: var(--mag-ink, #1a1a1a);
}
.dm-conv-form textarea:focus { border-color: var(--mag-red, #d3000a); }

/* ─── modal ─── */
.dm-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}
.dm-modal-card {
  position: relative;
  background: var(--mag-card, #fff);
  border-radius: 16px;
  padding: 28px;
  width: 92%;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.dm-modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--mag-ink-soft, #555);
  cursor: pointer;
  line-height: 1;
}
.dm-modal-card h3 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--mag-ink, #1a1a1a);
}
.dm-modal-hint {
  font-size: 13px;
  color: var(--mag-ink-soft, #555);
  margin: 0 0 16px;
}
.dm-modal-input,
.dm-modal-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--mag-border, #e5e5e5);
  border-radius: 12px;
  background: var(--mag-card, #fff);
  color: var(--mag-ink, #1a1a1a);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  margin-bottom: 6px;
}
.dm-modal-textarea { resize: vertical; min-height: 80px; }
.dm-modal-input:focus,
.dm-modal-textarea:focus { border-color: var(--mag-red, #d3000a); }

.dm-modal-status {
  font-size: 12.5px;
  color: var(--mag-ink-soft, #888);
  min-height: 18px;
  margin-bottom: 8px;
}
.dm-modal-status-ok  { color: #0d9488; font-weight: 600; }
.dm-modal-status-bad { color: #ef4444; font-weight: 600; }

.dm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ─── responsive ─── */
@media (max-width: 720px) {
  .dm-shell { grid-template-columns: 1fr; }
  .dm-side {
    border-right: none;
    border-bottom: 1px solid var(--mag-border, #e5e5e5);
    max-height: 240px;
  }
}
