/* BuenosAiresYa - Mensajes privados (bandeja + chat). Usa los tokens del tema: claro y oscuro. */

.dm {
  display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  height: calc(100vh - var(--topbar-h)); min-height: 520px; background: var(--card);
}

/* ---- Bandeja ---- */
.dm-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.dm-list-head { padding: 1rem 1.1rem .4rem; }
.dm-list-head h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
.dm-boxes { display: flex; gap: .35rem; padding: .4rem 1.1rem .7rem; border-bottom: 1px solid var(--line); }
.dm-box { padding: .4rem .85rem; border-radius: 999px; font-size: .88rem; font-weight: 650; color: var(--muted); }
.dm-box:hover { background: var(--hover); text-decoration: none; color: var(--heading); }
.dm-box.is-on { background: var(--heading); color: var(--bg); }
.dm-pill { display: inline-grid; place-items: center; min-width: 1.2rem; height: 1.2rem; padding: 0 .3rem; margin-left: .15rem; border-radius: 999px; background: var(--blue); color: #fff; font-size: .7rem; font-weight: 800; }
.dm-note { margin: .7rem 1.1rem 0; font-size: .8rem; color: var(--muted); }
.dm-empty-list { padding: 2rem 1.3rem; text-align: center; }
.dm-convs { list-style: none; margin: 0; padding: .3rem 0; overflow-y: auto; flex: 1; }
.dm-conv { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem; color: var(--text); position: relative; }
.dm-conv:hover { background: var(--hover); text-decoration: none; }
.dm-conv.is-on { background: var(--blue-50); }
.dm-conv.is-on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--blue); }
.dm-conv .avatar { flex: none; }
.dm-conv-main { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: .1rem; }
.dm-conv-top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.dm-conv-name { font-weight: 650; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-conv-time { flex: none; font-size: .75rem; color: var(--muted); }
.dm-conv-last { font-size: .86rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-conv.is-unread .dm-conv-name, .dm-conv.is-unread .dm-conv-last { font-weight: 750; color: var(--heading); }
.dm-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }

/* ---- Conversacion ---- */
.dm-thread-wrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.dm-placeholder { margin: auto; max-width: 360px; padding: 2rem; text-align: center; }
.dm-placeholder h2 { margin: .8rem 0 .3rem; }
.dm-placeholder-ic { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; border: 2px solid var(--heading); color: var(--heading); }
.dm-thread-head { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; border-bottom: 1px solid var(--line); background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.dm-back { display: none; font-size: 1.3rem; padding: .2rem .5rem; border-radius: 50%; color: var(--heading); }
.dm-back:hover { background: var(--hover); text-decoration: none; }
.dm-peer { display: flex; align-items: center; gap: .6rem; color: var(--text); min-width: 0; flex: 1; }
.dm-peer:hover { text-decoration: none; }
.dm-peer > span { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.dm-peer strong { color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-menu .menu-panel { right: 0; left: auto; }
.dm-menu .menu-panel form button { width: 100%; }

.dm-thread { flex: 1; overflow-y: auto; padding: 1rem 1.1rem .6rem; display: flex; flex-direction: column; gap: .2rem; overscroll-behavior: contain; }
.dm-intro { text-align: center; padding: 2rem 1rem 1rem; }
.dm-intro .avatar { margin: 0 auto .5rem; }
.dm-day { display: flex; justify-content: center; margin: .9rem 0 .5rem; }
.dm-day span { font-size: .72rem; font-weight: 700; color: var(--muted); background: var(--card-2); padding: .2rem .7rem; border-radius: 999px; }
.dm-msg { display: flex; flex-direction: column; max-width: min(75%, 520px); }
.dm-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.dm-msg.is-theirs { align-self: flex-start; align-items: flex-start; }
.dm-bubble { border-radius: 20px; overflow: hidden; word-wrap: break-word; overflow-wrap: anywhere; }
.dm-msg.is-mine .dm-bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 6px; }
.dm-msg.is-theirs .dm-bubble { background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.dm-msg.is-mine .dm-bubble a { color: #fff; text-decoration: underline; }
.dm-text { padding: .55rem .9rem; line-height: 1.4; font-size: .95rem; }
.dm-photo { display: block; }
.dm-photo img { display: block; max-width: 100%; width: 320px; max-height: 360px; object-fit: cover; background: var(--card-2); }
.dm-time { font-size: .68rem; color: var(--muted); margin: .15rem .35rem .45rem; }

.dm-request, .dm-status { margin: 0 1rem .6rem; padding: .8rem 1rem; border-radius: var(--radius-sm); background: var(--card-2); border: 1px solid var(--line); font-size: .9rem; }
.dm-request p { margin: 0 0 .6rem; }
.dm-request-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.dm-status { color: var(--muted); text-align: center; }
.dm-status-off { color: var(--red); }

.dm-composer { display: flex; align-items: flex-end; gap: .5rem; padding: .6rem .9rem .8rem; border-top: 1px solid var(--line); background: var(--card); }
.dm-attach { position: relative; display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%; color: var(--blue); cursor: pointer; transition: background .15s; }
.dm-attach:hover { background: var(--blue-50); }
.dm-attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dm-attach:focus-within { box-shadow: var(--ring); }
.dm-input { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--card-2); border: 1px solid var(--line-strong); border-radius: 22px; padding: .15rem .9rem; transition: border-color .15s, box-shadow .15s; }
.dm-input:focus-within { border-color: var(--sky); box-shadow: var(--ring); background: var(--card); }
.dm-input textarea { border: 0; background: transparent; resize: none; font: inherit; color: var(--text); padding: .5rem 0; max-height: 160px; outline: none; width: 100%; }
.dm-file-name { font-size: .78rem; color: var(--blue); padding-top: .35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-send { width: 44px; height: 44px; padding: 0; flex: none; border-radius: 50%; }
.dm-error { margin: 0 1rem .6rem; color: var(--red); font-size: .85rem; }

/* Badge del icono de mensajes */
.badge-count[hidden] { display: none; }

@media (max-width: 759px) {
  .dm { grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 64px); }
  .dm.has-thread .dm-list { display: none; }
  .dm:not(.has-thread) .dm-thread-wrap { display: none; }
  .dm-back { display: inline-block; }
  .dm-msg { max-width: 85%; }
}
