/* ── DM — Telegram-style Split Layout + Dark Cinematic ─────────────────── */
.btn-dm { position: relative; }
.dm-badge {
  position: absolute; top: -4px; right: -4px;
  background: #e53935; color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 2px 5px; border-radius: 999px;
  min-width: 16px; text-align: center;
  animation: pulse-dot 1.5s infinite;
}

/* ── Split Shell ───────────────────────────────────────────────────────── */
.dm-split {
  display: flex; height: calc(100vh - 67px);
  max-width: 1200px; margin: 0 auto;
  background: #141724;
}
.dm-sidebar {
  width: 100%; flex-shrink: 0;
  background: #1a1e30; display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}
.dm-main {
  flex: 1; display: none;
  flex-direction: column; min-width: 0;
}
/* Mobile: show sidebar by default, chat when .show-chat */
.dm-split.show-chat .dm-sidebar { display: none; }
.dm-split.show-chat .dm-main { display: flex; }

/* ── Sidebar Header ───────────────────────────────────────────────────── */
.dm-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px; flex-shrink: 0;
}
.dm-sidebar-title { font-size: 20px; font-weight: 700; color: #e8e8e8; }
.dm-sidebar-new-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(38,166,154,0.12); border: none;
  color: #26a69a; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.dm-sidebar-new-btn:hover { background: rgba(38,166,154,0.2); }

/* ── Online Users Bar ──────────────────────────────────────────────────── */
.dm-online-bar {
  padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.dm-online-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
  color: #6b7280; font-weight: 600; display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.dm-online-count {
  background: #4caf50; color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 8px; letter-spacing: 0;
}
.dm-online-none { color: #4a4f64; font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.dm-online-users {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
}
.dm-online-users::-webkit-scrollbar { height: 0; }
.dm-online-user {
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer; flex-shrink: 0; gap: 3px;
}
.dm-online-user img {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  border: 2px solid #4caf50; box-shadow: 0 0 8px rgba(76,175,80,0.3);
}
.dm-online-initials {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid #4caf50;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
  background: linear-gradient(135deg, #26a69a, #1a8a7e);
  box-shadow: 0 0 8px rgba(76,175,80,0.3);
}
.dm-online-more { border-color: #3a3f5a; background: #252a3e; box-shadow: none; }
.dm-online-name {
  font-size: 10px; color: #8890a4; max-width: 48px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-online-user:hover .dm-online-name { color: #26a69a; }

/* ── Search ────────────────────────────────────────────────────────────── */
.dm-search { padding: 8px 12px; flex-shrink: 0; }
.dm-search-input {
  width: 100%; background: #252a3e; border: 1px solid rgba(255,255,255,0.06); border-radius: 24px;
  padding: 9px 16px; font-size: 13px; color: #e0e0e0;
  font-family: var(--font); outline: none;
}
.dm-search-input::placeholder { color: #6b7280; }
.dm-search-input:focus { border-color: #26a69a; background: #2a2f45; }

/* ── Conversation List ─────────────────────────────────────────────────── */
.dm-conv-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; }
.dm-conv-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.03);
  cursor: pointer; background: transparent; transition: background .15s;
}
.dm-conv-item:hover { background: #1f2438; }
.dm-conv-item:active { background: #252a3e; }
.dm-conv-item.active { background: rgba(38,166,154,0.1); border-left: 3px solid #26a69a; }
.dm-conv-item.unread { background: rgba(38,166,154,0.06); }
.dm-conv-avatar { position: relative; flex-shrink: 0; }
.dm-conv-avatar-circle {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #26a69a, #1a8a7e); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.dm-conv-avatar-circle img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.dm-online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #4caf50; border: 2.5px solid #1a1e30;
  box-shadow: 0 0 6px rgba(76,175,80,0.4);
}
.dm-conv-body { flex: 1; min-width: 0; }
.dm-conv-top { display: flex; justify-content: space-between; align-items: center; }
.dm-conv-name { font-weight: 600; font-size: 14px; color: #e0e0e0; }
.dm-conv-name.unread { font-weight: 700; color: #fff; }
.dm-conv-time { font-size: 11px; color: #6b7280; }
.dm-conv-time.unread { color: #26a69a; font-weight: 600; }
.dm-conv-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.dm-conv-preview {
  font-size: 13px; color: #6b7280;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.dm-conv-preview.unread { color: #b0b8c8; font-weight: 600; }
.dm-conv-preview .dm-read-check { color: #26a69a; font-size: 12px; margin-right: 4px; }
.dm-conv-preview .dm-unread-check { color: #6b7280; font-size: 12px; margin-right: 4px; }
.dm-unread-badge {
  background: #26a69a; color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.dm-empty { text-align: center; padding: 40px 20px; color: #6b7280; font-size: 14px; }

/* ── Main Empty State ──────────────────────────────────────────────────── */
.dm-main-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #3a3f5a; gap: 12px;
}
.dm-main-empty i { font-size: 48px; }
.dm-main-empty div { font-size: 15px; color: #6b7280; }

/* ── Search Modal ──────────────────────────────────────────────────────── */
.dm-search-modal {
  position: fixed; z-index: 1000;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 32px); max-width: 420px; max-height: 70vh;
  background: #1e2235; display: flex; flex-direction: column;
  border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,0.08);
}
.dm-search-modal-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
}
.dm-search-modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.dm-search-modal-close {
  background: none; border: none; font-size: 24px;
  cursor: pointer; color: #8890a4; padding: 4px 8px;
}
.dm-search-modal-close:hover { color: #fff; }
.dm-search-modal-title { flex: 1; font-weight: 600; font-size: 16px; color: #e8e8e8; }
.dm-search-modal-input {
  margin: 12px 16px; background: #252a3e; border: 1px solid rgba(255,255,255,0.08); border-radius: 24px;
  padding: 10px 16px; font-size: 14px; color: #e0e0e0;
  font-family: var(--font); outline: none;
}
.dm-search-modal-input::placeholder { color: #6b7280; }
.dm-search-modal-input:focus { border-color: #26a69a; }
.dm-search-results { flex: 1; overflow-y: auto; padding: 0; }
.dm-search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer; transition: background .15s;
}
.dm-search-result-item:hover { background: rgba(38,166,154,0.08); }
.dm-search-result-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #26a69a, #1a8a7e); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.dm-search-result-avatar img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.dm-search-result-name { font-size: 14px; font-weight: 600; color: #e0e0e0; }

/* ── Chat ──────────────────────────────────────────────────────────────── */
.dm-chat { display: flex; flex-direction: column; height: 100%; background: #141724; }
.dm-chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: #1a1e30;
  border-bottom: 1px solid rgba(255,255,255,0.06); flex-shrink: 0;
}
.dm-chat-back {
  font-size: 16px; cursor: pointer; color: #8890a4;
  background: none; border: none; padding: 6px 10px;
  border-radius: 8px; transition: all .15s;
}
.dm-chat-back:hover { color: #26a69a; background: rgba(38,166,154,0.1); }
.dm-chat-avatar { position: relative; }
.dm-chat-avatar-circle {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #26a69a, #1a8a7e); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.dm-chat-avatar-circle img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.dm-chat-online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: #4caf50; border: 2px solid #1a1e30;
  box-shadow: 0 0 6px rgba(76,175,80,0.4);
}
.dm-chat-info { flex: 1; }
.dm-chat-name { font-weight: 600; font-size: 14px; color: #e8e8e8; }
.dm-chat-status { font-size: 11px; color: #4caf50; font-weight: 500; }
.dm-chat-status.offline { color: #6b7280; }

/* ── Messages ──────────────────────────────────────────────────────────── */
.dm-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column;
}
.dm-msg { display: flex; margin-bottom: 4px; max-width: 75%; }
.dm-msg.sent { align-self: flex-end; }
.dm-msg.received { align-self: flex-start; }
.dm-msg-bubble { padding: 10px 14px; max-width: 100%; word-break: break-word; }
.dm-msg.received .dm-msg-bubble {
  background: #1e2235; border-radius: 4px 18px 18px 18px;
  border: 1px solid rgba(255,255,255,0.06); color: #e0e0e0;
}
.dm-msg.sent .dm-msg-bubble {
  background: linear-gradient(135deg, #26a69a, #1f9688);
  border-radius: 18px 4px 18px 18px; color: #fff;
  box-shadow: 0 2px 8px rgba(38,166,154,0.25);
}
.dm-msg-text { font-size: 14px; line-height: 1.5; }
.dm-msg-image {
  max-width: 240px; max-height: 300px; border-radius: 12px;
  object-fit: cover; display: block; margin-bottom: 4px;
}
.dm-msg-meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 3px;
}
.dm-msg-time { font-size: 10px; }
.dm-msg.received .dm-msg-time { color: #6b7280; }
.dm-msg.sent .dm-msg-time { color: rgba(255,255,255,.6); }
.dm-msg-read { font-size: 11px; }
.dm-msg.sent .dm-msg-read { color: rgba(255,255,255,.7); }
.dm-msg.sent .dm-msg-read.read { color: #b2dfdb; }
.dm-msg-delete {
  background: none; border: none; font-size: 12px;
  color: rgba(255,255,255,.3); cursor: pointer; padding: 2px 4px; display: none;
}
.dm-msg.sent:hover .dm-msg-delete,
.dm-msg.sent:active .dm-msg-delete { display: inline; }
.dm-msg.sent .dm-msg-delete:hover { color: #fff; }
.dm-date-sep {
  text-align: center; font-size: 11px; color: #6b7280;
  margin: 16px 0 8px; font-weight: 500;
  display: flex; align-items: center; gap: 12px;
}
.dm-date-sep::before, .dm-date-sep::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.06);
}

/* ── Typing ────────────────────────────────────────────────────────────── */
.dm-typing {
  align-self: flex-start; padding: 10px 16px;
  background: #1e2235; border-radius: 4px 18px 18px 18px;
  border: 1px solid rgba(255,255,255,0.06);
  display: none; margin: 0 16px 8px;
}
.dm-typing.visible { display: flex; gap: 5px; align-items: center; }
.dm-typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #26a69a;
  animation: dm-bounce 1.4s infinite;
}
.dm-typing-dot:nth-child(2) { animation-delay: .2s; }
.dm-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes dm-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input Bar ─────────────────────────────────────────────────────────── */
.dm-input-bar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px; background: #1a1e30;
  border-top: 1px solid rgba(255,255,255,0.06); flex-shrink: 0;
}
.dm-input-camera {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(38,166,154,0.12); border: none;
  font-size: 18px; color: #26a69a;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.dm-input-camera:hover { background: rgba(38,166,154,0.2); }
.dm-input-text {
  flex: 1; border: 1px solid rgba(255,255,255,0.1); border-radius: 22px;
  padding: 10px 16px; font-size: 14px; font-family: var(--font);
  background: #252a3e; color: #e0e0e0; outline: none;
  min-height: 38px; max-height: 100px; resize: none;
}
.dm-input-text::placeholder { color: #6b7280; }
.dm-input-text:focus { border-color: #26a69a; background: #2a2f45; }
.dm-input-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #26a69a, #1a8a7e); color: #fff; border: none;
  font-size: 16px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(38,166,154,0.3);
  transition: transform .15s;
}
.dm-input-send:active { transform: scale(0.9); }
.dm-input-send:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.dm-image-preview {
  position: relative; padding: 8px 12px;
  background: #1a1e30; border-top: 1px solid rgba(255,255,255,0.06); display: none;
}
.dm-image-preview.visible { display: block; }
.dm-image-preview img { max-height: 120px; border-radius: 10px; object-fit: cover; }
.dm-image-preview-remove {
  position: absolute; top: 12px; right: 16px;
  background: rgba(0,0,0,.7); color: #fff;
  border: none; border-radius: 50%;
  width: 26px; height: 26px; font-size: 13px;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}

/* ── Desktop: Split Layout ─────────────────────────────────────────────── */
@media (min-width: 768px) {
  .dm-split { height: calc(100vh - 74px); }
  .dm-sidebar { width: 340px; }
  .dm-main { display: flex; }
  /* On desktop, always show both panels */
  .dm-split.show-chat .dm-sidebar { display: flex; }
  .dm-split.show-chat .dm-main { display: flex; }
  .dm-chat-back { display: none; }
}

@media (min-width: 1024px) {
  .dm-sidebar { width: 380px; }
}
