/* ═══════════════════════════════════════════════════════════
   DM / Messages — Messenger-style slide-in side panel
   ═══════════════════════════════════════════════════════════ */

/* Backdrop */
.dmp-backdrop {
  position: fixed; inset: 0; z-index: 8999;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.dmp-backdrop.open {
  opacity: 1; pointer-events: auto;
}

/* Panel */
.dmp-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  z-index: 9000;
  width: 380px; max-width: 92vw;
  background: var(--panel, var(--bg));
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  box-shadow: -8px 0 40px rgba(0,0,0,.3);
}
.dmp-panel.open {
  transform: translateX(0);
}

/* Header */
.dmp-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dmp-header .dmp-title {
  flex: 1; font-size: 17px; font-weight: 700; margin: 0;
}
.dmp-header .dmp-back-btn,
.dmp-header .dmp-new-btn,
.dmp-header .dmp-close-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 6px; border-radius: 8px;
  transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.dmp-header .dmp-back-btn:hover,
.dmp-header .dmp-new-btn:hover,
.dmp-header .dmp-close-btn:hover {
  color: var(--text); background: var(--surface);
}

/* Body */
.dmp-body {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-height: 0;
}

/* Thread list */
.dmp-list {
  flex: 1; overflow-y: auto;
}
.dmp-thread-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.dmp-thread-row:hover { background: rgba(124,156,255,.05); }
.dmp-thread-info { flex: 1; min-width: 0; }
.dmp-thread-name { font-size: 14px; font-weight: 600; }
.dmp-thread-preview {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.dmp-thread-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* Re-use dm-av from old CSS for avatars */
.dm-av {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface, var(--panel-2, #1e2738));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 14px; font-weight: 600;
  color: var(--muted); overflow: hidden;
}
.dm-av img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}

/* Messages view */
.dmp-messages {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.dm-msg {
  max-width: 82%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.45; word-wrap: break-word;
}
.dm-msg {
  position: relative;
  user-select: text;
  -webkit-user-select: text;
}
.dm-msg.sent {
  align-self: flex-end;
  background: linear-gradient(135deg, #e8627c 0%, #d4547a 50%, #c04e80 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.dm-msg.received {
  align-self: flex-start;
  background: var(--surface, var(--panel-2, #1e2738));
  color: var(--text); border-bottom-left-radius: 4px;
}
.dm-msg .dm-msg-time { font-size: 10px; opacity: .6; margin-top: 4px; }

/* Heart reaction */
.dm-msg-heart {
  position: absolute; bottom: -8px;
  width: 22px; height: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1;
  animation: heartPop .3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
.dm-msg.sent .dm-msg-heart { left: -6px; }
.dm-msg.received .dm-msg-heart { right: -6px; }
@keyframes heartPop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* Input bar */
.dmp-input-bar {
  display: flex; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.dmp-input-bar .dmp-msg-input {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text); padding: 10px 16px;
  font-size: 14px; outline: none; font-family: inherit;
}
.dmp-input-bar .dmp-msg-input:focus { border-color: var(--accent); }
.dmp-input-bar .dmp-send-btn {
  background: var(--accent); color: var(--bg); border: none;
  border-radius: 50%; width: 36px; height: 36px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: filter .15s;
}
.dmp-input-bar .dmp-send-btn:hover { filter: brightness(1.1); }

/* Empty state */
.dmp-empty {
  text-align: center; padding: 48px 24px; color: var(--muted);
}
.dmp-empty-icon { font-size: 36px; margin-bottom: 10px; }
.dmp-start-btn {
  background: var(--accent); color: var(--bg); border: none;
  border-radius: 10px; padding: 10px 24px; font-size: 14px;
  font-weight: 700; cursor: pointer; font-family: inherit;
}
.dmp-start-btn:hover { filter: brightness(1.1); }

/* Friend picker */
.dmp-friend-picker {
  padding: 12px 16px; flex: 1; overflow-y: auto;
}

/* Search input in friend picker */
.dmp-search-wrap {
  position: sticky; top: 0; z-index: 2;
  padding-bottom: 10px;
  background: var(--panel, var(--bg));
}
.dmp-search-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-size: 14px; outline: none; font-family: inherit;
  transition: border-color .15s;
}
.dmp-search-input:focus { border-color: var(--accent); }
.dmp-search-input::placeholder { color: var(--muted); }
.dmp-picker-hint {
  font-size: 11px; color: var(--muted);
  text-align: center; padding: 6px 0 2px;
}
.dmp-friend-row {
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; border-radius: 10px; padding: 10px 8px;
  transition: background .15s;
}
.dmp-friend-row:hover { background: rgba(124,156,255,.08); }
.dmp-friend-name { font-size: 14px; font-weight: 600; }

/* Nav bar messages icon */
.nav-icon-btn {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  padding: 6px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.nav-icon-btn:hover {
  color: var(--text); background: rgba(255,255,255,.06);
}

/* Group avatar */
.dm-av-group {
  background: linear-gradient(135deg, rgba(232,98,124,.2), rgba(167,139,250,.2)) !important;
  border: 1px solid rgba(232,98,124,.3);
}

/* Sender name in group chats */
.dm-msg-sender {
  font-size: 11px; font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  opacity: .8;
}

/* Multi-select in friend picker */
.dmp-friend-row.selected {
  background: rgba(124,156,255,.1);
}
.dmp-friend-check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0; margin-left: auto;
  transition: all .15s;
  position: relative;
}
.dmp-friend-row.selected .dmp-friend-check {
  background: var(--accent); border-color: var(--accent);
}
.dmp-friend-row.selected .dmp-friend-check::after {
  content: '';
  position: absolute; top: 3px; left: 6px;
  width: 5px; height: 9px;
  border: solid var(--bg); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Selected bar for group creation */
.dmp-selected-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.dmp-selected-chips {
  display: flex; gap: 4px; flex: 1; flex-wrap: wrap; min-width: 0;
}
.dmp-sel-chip {
  padding: 4px 10px;
  background: rgba(232,98,124,.15);
  border: 1px solid rgba(232,98,124,.25);
  border-radius: 100px;
  font-size: 12px; font-weight: 600;
  color: #e8627c;
}
.dmp-group-go {
  padding: 6px 14px;
  background: var(--accent); color: var(--bg);
  border: none; border-radius: 8px;
  font-size: 12px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
  font-family: inherit;
  transition: filter .15s;
}
.dmp-group-go:hover { filter: brightness(1.15); }

/* ─── Mobile ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .dmp-panel { width: 100vw; max-width: 100vw; }
  .dmp-backdrop { display: none; }
}
