/* ============================================================
   ChatBase — Messages tab (DMs)
   Full-screen two-pane layout. Uses liquid-glass.css tokens.
   ============================================================ */

#messages.tab-content.active { display: block; }

.dm-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    height: calc(100dvh - 150px);
    min-height: 460px;
    border-radius: var(--lg-r-lg, 22px);
    border: 1px solid var(--lg-rim, rgba(255,255,255,0.12));
    background: var(--lg-glass-1, rgba(255,255,255,0.04));
    box-shadow: var(--lg-specular, none), var(--lg-lift-2, 0 12px 36px rgba(0,0,0,0.45));
    -webkit-backdrop-filter: var(--lg-blur, blur(24px));
    backdrop-filter: var(--lg-blur, blur(24px));
    overflow: hidden;
}

/* ---------- Left: conversation list ---------- */
.dm-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--lg-rim-soft, rgba(255,255,255,0.08));
    background: rgba(0,0,0,0.12);
}
.dm-side-head { padding: 20px 20px 12px; }
.dm-side-head h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.dm-search {
    margin: 0 14px 10px;
    padding: 11px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06);
    color: #fff;
    font: inherit;
    font-size: 14px;
    outline: none;
}
.dm-search:focus { border-color: rgba(160,107,255,0.6); background: rgba(255,255,255,0.09); }
.dm-search::placeholder { color: var(--text-secondary, #a0a0b0); }

.dm-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.dm-list-label {
    padding: 14px 12px 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary, #a0a0b0);
}
.dm-list-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-secondary, #a0a0b0);
    font-size: 14px;
    line-height: 1.6;
}

.dm-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.dm-item:hover { background: rgba(255,255,255,0.06); }
.dm-item.active { background: rgba(160,107,255,0.18); }
.dm-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dm-item-top { display: flex; align-items: baseline; gap: 8px; }
.dm-item-name {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dm-item-time { font-size: 11px; color: var(--text-secondary, #a0a0b0); flex: 0 0 auto; }
.dm-item-preview {
    font-size: 13px;
    color: var(--text-secondary, #a0a0b0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dm-item.unread .dm-item-name { color: #fff; }
.dm-item.unread .dm-item-preview { color: #e6e6f0; font-weight: 600; }
.dm-unread-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #a06bff;
    box-shadow: 0 0 10px rgba(160,107,255,0.8);
}

/* ---------- Avatars ---------- */
.dm-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.dm-avatar > img,
.dm-avatar > span {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.dm-avatar.small { width: 30px; height: 30px; font-size: 15px; background: none; }
.dm-avatar.small:empty { visibility: hidden; }
.dm-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--lg-abyss, #080a18);
    background: #64748b;
}
.dm-dot.online { background: #34e8b0; }
.dm-dot.inactive { background: #ffb443; }

/* ---------- Right: open chat ---------- */
.dm-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.dm-empty {
    margin: auto;
    padding: 24px;
    text-align: center;
    color: var(--text-secondary, #a0a0b0);
}
.dm-empty-icon { font-size: 56px; margin-bottom: 8px; }
.dm-empty h2 { margin: 0 0 6px; color: #fff; font-size: 22px; }
.dm-empty p { margin: 0; }

.dm-convo { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.dm-convo[hidden], .dm-empty[hidden] { display: none; }

.dm-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--lg-rim-soft, rgba(255,255,255,0.08));
    background: rgba(0,0,0,0.1);
}
.dm-back {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}
.dm-head-person {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 4px 4px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.dm-head-person:hover { background: rgba(255,255,255,0.05); }
.dm-head-text { display: flex; flex-direction: column; min-width: 0; }
.dm-head-name { font-weight: 800; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-head-status { font-size: 12px; color: var(--text-secondary, #a0a0b0); }
.dm-head-btn {
    flex: 0 0 auto;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid rgba(52,232,176,0.4);
    background: rgba(52,232,176,0.12);
    color: #34e8b0;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.dm-head-btn:hover { background: rgba(52,232,176,0.2); }

.dm-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dm-hello {
    align-self: center;
    margin: 10px 0 14px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    font-size: 12px;
    color: var(--text-secondary, #a0a0b0);
}
.dm-day {
    align-self: center;
    margin: 14px 0 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary, #a0a0b0);
}

.dm-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; max-width: 100%; }
.dm-row.grouped { margin-top: 2px; }
.dm-row.self { justify-content: flex-end; }

.dm-bubble {
    max-width: min(560px, 75%);
    padding: 9px 14px 6px;
    border-radius: 20px;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.06);
}
.dm-row.other .dm-bubble { border-bottom-left-radius: 6px; }
.dm-row.self .dm-bubble {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border-color: rgba(255,255,255,0.15);
    border-bottom-right-radius: 6px;
}
.dm-row.grouped.other .dm-bubble { border-top-left-radius: 6px; }
.dm-row.grouped.self .dm-bubble { border-top-right-radius: 6px; }
.dm-bubble p {
    margin: 0;
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.dm-time {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    text-align: right;
    color: rgba(255,255,255,0.55);
}

.dm-compose {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--lg-rim-soft, rgba(255,255,255,0.08));
}
.dm-compose .dm-input {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: #fff;
    font: inherit;
    font-size: 15px;
    box-sizing: border-box;
}
.dm-compose .dm-input:focus { outline: none; border-color: rgba(160,107,255,0.6); }
.dm-compose .dm-send {
    flex: 0 0 auto;
    width: auto;
    height: 46px;
    padding: 0 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
}

/* ---------- Phones: one pane at a time ---------- */
@media (max-width: 760px) {
    .dm-layout {
        grid-template-columns: minmax(0, 1fr);
        height: calc(100dvh - 120px);
        border-radius: 18px;
    }
    .dm-pane { display: none; }
    .dm-layout.show-convo .dm-side { display: none; }
    .dm-layout.show-convo .dm-pane { display: flex; }
    .dm-back { display: inline-flex; align-items: center; justify-content: center; }
    .dm-bubble { max-width: 82%; }
    .dm-head-btn { padding: 8px 12px; }
    .dm-messages { padding: 14px 12px 8px; }
}

/* ---------- Group chats (groupdms.js) ---------- */
.dm-side-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gd-new-btn {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(160,107,255,0.45);
    background: rgba(160,107,255,0.14);
    color: #e2d4ff;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.gd-new-btn:hover { background: rgba(160,107,255,0.24); }
.gd-avatar > span { background: linear-gradient(135deg, rgba(160,107,255,0.4), rgba(34,211,238,0.3)); }
.gd-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: #a06bff;
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    letter-spacing: 0;
}
.gd-head { cursor: default; }
.gd-head:hover { background: transparent; }
.gd-menu-btn { border-color: rgba(255,255,255,0.18); background: rgba(255,255,255,0.06); color: #fff; padding: 9px 14px; }
.gd-sender { display: block; font-size: 11.5px; font-weight: 700; color: #b69cff; margin-bottom: 2px; }
.gd-box { max-width: 420px; width: calc(100vw - 32px); }
.gd-pick { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 4px 0; }
.gd-person {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 7px 10px;
    border: 0; border-radius: 10px;
    background: transparent; color: inherit; font: inherit; font-size: 14px; text-align: left;
    cursor: pointer;
}
.gd-person:hover { background: rgba(255,255,255,0.06); }
.gd-person span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-person i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.08); font-size: 13px; }
.gd-person.on i { background: #a06bff; }
.gd-person.fixed { opacity: 0.55; cursor: default; }
.gd-pick-count { font-size: 12px; color: var(--text-secondary, #a0a0b0); }
.gd-cancel { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; color: #fff; cursor: pointer; font-family: inherit; }
