/* ══════════════════════════════════════════════════════════════
   CAPACITAR — DM CHAT PANEL  v2.0
   Layout: 3 colunas | Conversas | Chat | Detalhes
   ══════════════════════════════════════════════════════════════ */

/* ── Overlay ─────────────────────────────────────────────────── */
.dm2-overlay {
    position: fixed; inset: 0;
    background: rgba(2, 6, 23, 0.7);
    backdrop-filter: blur(8px);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: dm2FadeIn .2s ease;
}
.dm2-overlay.open { display: flex; }
@keyframes dm2FadeIn { from { opacity:0 } to { opacity:1 } }

/* ── Container principal ─────────────────────────────────────── */
.dm2-container {
    width: 100%;
    max-width: 980px;
    height: 82vh;
    max-height: 720px;
    background: var(--card-bg, #fff);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0,0,0,.35), 0 0 0 1px rgba(13,138,188,.15);
    display: flex;
    overflow: hidden;
    animation: dm2SlideUp .3s cubic-bezier(.16,1,.3,1);
}
@keyframes dm2SlideUp {
    from { transform: translateY(30px) scale(.97); opacity:0; }
    to   { transform: translateY(0)    scale(1);   opacity:1; }
}

/* ═══════════════ COLUNA 1 — LISTA DE CONVERSAS ════════════════ */
.dm2-sidebar {
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid rgba(0,0,0,.07);
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
}
[data-theme="dark"] .dm2-sidebar { border-right-color: rgba(255,255,255,.07); }

.dm2-sidebar-head {
    padding: 1rem 1rem .75rem;
    border-bottom: 1px solid rgba(0,0,0,.06);
    flex-shrink: 0;
}
[data-theme="dark"] .dm2-sidebar-head { border-bottom-color: rgba(255,255,255,.06); }

.dm2-sidebar-title {
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-secondary);
    margin-bottom: .6rem;
}

.dm2-search {
    width: 100%;
    padding: 7px 12px 7px 32px;
    border-radius: 10px;
    border: 1.5px solid rgba(0,0,0,.08);
    background: rgba(0,0,0,.03);
    color: var(--text-main);
    font-size: .8rem;
    outline: none;
    transition: border-color .2s;
    font-family: inherit;
    box-sizing: border-box;
}
[data-theme="dark"] .dm2-search { border-color: rgba(255,255,255,.08); background: rgba(255,255,255,.04); }
.dm2-search:focus { border-color: #0D8ABC; }
.dm2-search-wrap { position: relative; }
.dm2-search-wrap .dm2-search-icon {
    position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
    color: var(--text-secondary); font-size: .7rem; pointer-events: none;
}

/* Lista de conversas */
.dm2-conv-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}

.dm2-conv-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .75rem 1rem;
    cursor: pointer;
    transition: background .15s;
    border-bottom: 1px solid rgba(0,0,0,.035);
    position: relative;
}
[data-theme="dark"] .dm2-conv-item { border-bottom-color: rgba(255,255,255,.04); }
.dm2-conv-item:hover  { background: rgba(13,138,188,.05); }
.dm2-conv-item.active { background: rgba(13,138,188,.1); }
[data-theme="dark"] .dm2-conv-item.active { background: rgba(13,138,188,.15); }

.dm2-conv-av {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(0,0,0,.06);
    position: relative;
}
.dm2-conv-av-wrap { position: relative; flex-shrink: 0; }
.dm2-conv-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 9px; height: 9px;
    border-radius: 50%; border: 2px solid var(--card-bg);
}
.dm2-conv-dot.online  { background: #10b981; }
.dm2-conv-dot.recente { background: #f59e0b; }
.dm2-conv-dot.offline { background: #94a3b8; }

.dm2-conv-info { flex: 1; min-width: 0; }
.dm2-conv-name {
    font-size: .82rem; font-weight: 700;
    color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dm2-conv-last {
    font-size: .72rem; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 1px;
}
.dm2-conv-meta {
    display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
    flex-shrink: 0;
}
.dm2-conv-time { font-size: .65rem; color: var(--text-secondary); }
.dm2-conv-badge {
    background: #ef4444; color: white;
    font-size: .6rem; font-weight: 800;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* ═══════════════ COLUNA 2 — CHAT PRINCIPAL ══════════════════ */
.dm2-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--card-bg);
}

/* Header do chat */
.dm2-chat-header {
    display: flex; align-items: center; gap: .8rem;
    padding: .85rem 1.2rem;
    border-bottom: 1px solid rgba(0,0,0,.07);
    flex-shrink: 0;
    background: var(--card-bg);
}
[data-theme="dark"] .dm2-chat-header { border-bottom-color: rgba(255,255,255,.07); }

.dm2-chat-av {
    width: 36px; height: 36px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
}
.dm2-chat-info { flex: 1; min-width: 0; }
.dm2-chat-name {
    font-size: .9rem; font-weight: 700; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dm2-chat-status { font-size: .72rem; color: var(--text-secondary); }

.dm2-header-actions { display: flex; gap: .25rem; }
.dm2-hbtn {
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); font-size: 1rem;
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.dm2-hbtn:hover { background: rgba(0,0,0,.06); color: var(--text-main); }
[data-theme="dark"] .dm2-hbtn:hover { background: rgba(255,255,255,.08); }
.dm2-hbtn.close:hover { color: #ef4444; }

/* Mensagens */
.dm2-messages {
    flex: 1; overflow-y: auto;
    padding: 1rem 1.2rem;
    display: flex; flex-direction: column; gap: .45rem;
    scrollbar-width: thin;
}

/* Date separator */
.dm2-date-sep {
    display: flex; align-items: center; gap: .75rem;
    margin: .6rem 0; color: var(--text-secondary); font-size: .7rem; font-weight: 600;
}
.dm2-date-sep::before, .dm2-date-sep::after {
    content: ''; flex: 1; height: 1px; background: rgba(0,0,0,.07);
}
[data-theme="dark"] .dm2-date-sep::before,
[data-theme="dark"] .dm2-date-sep::after { background: rgba(255,255,255,.07); }

/* Balão de mensagem */
.dm2-msg {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
}
.dm2-msg.mine  { align-self: flex-end; align-items: flex-end; }
.dm2-msg.theirs { align-self: flex-start; align-items: flex-start; }

.dm2-msg-bubble {
    padding: .55rem .9rem;
    border-radius: 16px;
    font-size: .84rem;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}
.dm2-msg.mine .dm2-msg-bubble {
    background: linear-gradient(135deg, #0D8ABC, #0a6e96);
    color: white;
    border-bottom-right-radius: 4px;
}
.dm2-msg.theirs .dm2-msg-bubble {
    background: rgba(0,0,0,.055);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}
[data-theme="dark"] .dm2-msg.theirs .dm2-msg-bubble {
    background: rgba(255,255,255,.08);
}

/* Attachment styles */
.dm2-msg-att {
    display: block;
    margin-top: 0.5rem;
    text-decoration: none;
    border-radius: 8px;
    overflow: hidden;
}

.dm2-msg-att img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
}

.dm2-msg-att-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    color: inherit;
}
.dm2-msg.mine .dm2-msg-att-file {
    background: rgba(0,0,0,0.1);
}
.dm2-msg-att-file span {
    font-size: 0.8rem;
    text-decoration: underline;
}

.dm2-msg-foot {
    display: flex; align-items: center; gap: 4px;
    font-size: .62rem; color: var(--text-secondary);
    padding: 0 3px;
}
/* Ticks de leitura */
.dm2-ticks { font-size: .7rem; }
.dm2-ticks.sent   { color: var(--text-secondary); }
.dm2-ticks.read   { color: #0D8ABC; }

/* ── Indicador "está digitando..." ───────────────────────────── */
.dm2-typing {
    display: none;
    align-self: flex-start;
    padding: .45rem .85rem;
    background: rgba(0,0,0,.055);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    margin-bottom: .2rem;
}
[data-theme="dark"] .dm2-typing { background: rgba(255,255,255,.08); }
.dm2-typing.show { display: flex; align-items: center; gap: 4px; }
.dm2-typing-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-secondary);
    animation: dm2Bounce 1.2s infinite;
}
.dm2-typing-dot:nth-child(2) { animation-delay: .2s; }
.dm2-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes dm2Bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Empty state ──────────────────────────────────────────────── */
.dm2-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-secondary);
    gap: .75rem;
}
.dm2-empty i { font-size: 2.5rem; opacity: .2; }
.dm2-empty p { font-size: .88rem; margin: 0; }

/* ── Input row ───────────────────────────────────────────────── */
.dm2-input-row {
    display: flex; align-items: center; gap: .5rem;
    padding: .8rem 1.2rem;
    border-top: 1px solid rgba(0,0,0,.07);
    flex-shrink: 0;
    position: relative;
}
[data-theme="dark"] .dm2-input-row { border-top-color: rgba(255,255,255,.07); }

.dm2-input-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); font-size: 1.05rem;
    width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s; flex-shrink: 0;
}
.dm2-input-btn:hover { background: rgba(0,0,0,.06); color: #0D8ABC; }
[data-theme="dark"] .dm2-input-btn:hover { background: rgba(255,255,255,.08); }

.dm2-input {
    flex: 1; padding: 9px 14px;
    border-radius: 12px;
    border: 1.5px solid rgba(0,0,0,.1);
    background: var(--card-bg);
    color: var(--text-main);
    font-size: .84rem; outline: none; resize: none;
    font-family: inherit;
    transition: border-color .2s;
    max-height: 90px;
    overflow-y: auto;
    line-height: 1.45;
}
[data-theme="dark"] .dm2-input { border-color: rgba(255,255,255,.1); }
.dm2-input:focus { border-color: #0D8ABC; box-shadow: 0 0 0 3px rgba(13,138,188,.1); }

.dm2-send {
    width: 36px; height: 36px; border-radius: 10px;
    background: #0D8ABC; color: white;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; flex-shrink: 0;
    transition: background .2s, transform .15s;
}
.dm2-send:hover { background: #0a6e96; transform: scale(1.08); }
.dm2-send:active { transform: scale(.95); }

/* ── Emoji Picker ─────────────────────────────────────────────── */
.dm2-emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 60px;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,.1);
    box-shadow: 0 12px 40px rgba(0,0,0,.2);
    padding: .75rem;
    display: none;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    z-index: 10;
    width: 272px;
    animation: dm2FadeIn .15s ease;
}
[data-theme="dark"] .dm2-emoji-picker { border-color: rgba(255,255,255,.1); }
.dm2-emoji-picker.open { display: grid; }

.dm2-emoji-btn {
    background: none; border: none; cursor: pointer;
    font-size: 1.3rem; width: 32px; height: 32px;
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    transition: background .1s, transform .1s;
    line-height: 1;
}
.dm2-emoji-btn:hover {
    background: rgba(0,0,0,.06);
    transform: scale(1.25);
}
[data-theme="dark"] .dm2-emoji-btn:hover { background: rgba(255,255,255,.08); }

/* ═══════════════ COLUNA 3 — DETALHES DO USUÁRIO ══════════════ */
.dm2-details {
    width: 220px;
    flex-shrink: 0;
    border-left: 1px solid rgba(0,0,0,.07);
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    overflow-y: auto;
}
[data-theme="dark"] .dm2-details { border-left-color: rgba(255,255,255,.07); }

.dm2-details-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .85rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,.06);
    font-size: .78rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-secondary); flex-shrink: 0;
}
[data-theme="dark"] .dm2-details-head { border-bottom-color: rgba(255,255,255,.06); }

.dm2-details-body { padding: 1rem; }

.dm2-det-avatar-wrap {
    display: flex; justify-content: center; margin-bottom: 1rem;
}
.dm2-det-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(13,138,188,.25);
    box-shadow: 0 6px 20px rgba(13,138,188,.15);
}

.dm2-det-name {
    text-align: center;
    font-size: .92rem; font-weight: 800; color: var(--text-main);
    margin-bottom: .2rem;
}
.dm2-det-status {
    text-align: center;
    font-size: .72rem; color: var(--text-secondary);
    margin-bottom: 1rem;
}
.dm2-det-info {
    background: rgba(0,0,0,.03);
    border-radius: 12px; padding: .75rem;
    font-size: .75rem; color: var(--text-secondary);
    display: flex; flex-direction: column; gap: .5rem;
    margin-bottom: 1rem;
}
[data-theme="dark"] .dm2-det-info { background: rgba(255,255,255,.04); }
.dm2-det-info-row {
    display: flex; align-items: flex-start; gap: 6px;
}
.dm2-det-info-row i { color: #0D8ABC; margin-top: 1px; flex-shrink: 0; }

/* XP bar */
.dm2-det-xp-bar {
    background: rgba(0,0,0,.06); border-radius: 100px;
    height: 4px; overflow: hidden; margin-top: 2px;
}
[data-theme="dark"] .dm2-det-xp-bar { background: rgba(255,255,255,.08); }
.dm2-det-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #10b981);
    border-radius: 100px;
    transition: width .5s cubic-bezier(.16,1,.3,1);
}

/* Ações */
.dm2-det-section-title {
    font-size: .68rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-secondary);
    margin-bottom: .5rem;
}
.dm2-det-actions { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.dm2-det-action {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .7rem; border-radius: 10px; cursor: pointer;
    font-size: .8rem; color: var(--text-main); font-weight: 500;
    background: none; border: none; text-align: left; width: 100%;
    transition: background .15s; font-family: inherit;
}
.dm2-det-action:hover { background: rgba(0,0,0,.05); }
[data-theme="dark"] .dm2-det-action:hover { background: rgba(255,255,255,.06); }
.dm2-det-action i { color: var(--text-secondary); font-size: .85rem; width: 14px; flex-shrink: 0; }
.dm2-det-action.danger { color: #ef4444; }
.dm2-det-action.danger i { color: #ef4444; }
.dm2-det-action.danger:hover { background: rgba(239,68,68,.07); }

.dm2-det-challenge {
    width: 100%; padding: .65rem; border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white; border: none; cursor: pointer;
    font-size: .82rem; font-weight: 700; font-family: inherit;
    transition: filter .2s, transform .15s;
    display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.dm2-det-challenge:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ══════════════ CLUSTER DE AVATARES NA NAVBAR ════════════════ */
.nav-online-cluster {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}
.nav-online-cluster:hover .noc-avatars { transform: translateX(-2px); }

.noc-avatars {
    display: flex;
    transition: transform .2s;
}
.noc-av {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--navbar-bg, #fff);
    object-fit: cover;
    margin-left: -8px;
    transition: transform .2s, z-index 0s;
    position: relative;
    background: #0D8ABC;
    display: flex; align-items: center; justify-content: center;
    font-size: .62rem; font-weight: 700; color: white;
    overflow: hidden;
}
.noc-av:first-child { margin-left: 0; }
.noc-av:hover { transform: translateY(-3px) scale(1.1); z-index: 10; }

.noc-badge {
    min-width: 22px; height: 22px;
    background: linear-gradient(135deg, #10b981, #0D8ABC);
    color: white; border-radius: 100px;
    font-size: .65rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    margin-left: 2px;
    padding: 0 5px;
    border: 2px solid var(--navbar-bg, #fff);
}

.noc-pulse {
    width: 7px; height: 7px; border-radius: 50%;
    background: #10b981; margin-left: 6px; flex-shrink: 0;
    animation: nocPulse 2s infinite;
}
@keyframes nocPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
    50%       { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}

/* Tooltip do cluster */
.noc-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid rgba(0,0,0,.1);
    border-radius: 14px;
    padding: .6rem .8rem;
    box-shadow: 0 8px 30px rgba(0,0,0,.18);
    min-width: 180px;
    display: none;
    z-index: 200;
    animation: dm2FadeIn .15s ease;
}
[data-theme="dark"] .noc-tooltip { border-color: rgba(255,255,255,.1); }
.nav-online-cluster:hover .noc-tooltip { display: block; }

.noc-tooltip-title {
    font-size: .68rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-secondary); margin-bottom: .5rem;
}
.noc-tooltip-user {
    display: flex; align-items: center; gap: .5rem;
    padding: .3rem 0; font-size: .78rem; color: var(--text-main);
}
.noc-tooltip-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.noc-tooltip-dot.online  { background: #10b981; }
.noc-tooltip-dot.recente { background: #f59e0b; }
.noc-tooltip-dot.offline { background: #94a3b8; }
.noc-tooltip-more {
    font-size: .72rem; color: #0D8ABC; font-weight: 700;
    margin-top: .3rem; text-align: center;
    cursor: pointer;
}

/* ══════════════ NEWS TICKER NA NAVBAR ════════════════════════ */
.news-ticker-bar {
    background: linear-gradient(90deg, #0D8ABC 0%, #302b63 100%);
    color: white;
    height: 32px;
    display: flex;
    align-items: center;
    overflow: hidden;
    flex-shrink: 0;
}
.news-ticker-label {
    background: rgba(0,0,0,.25);
    padding: 0 12px;
    height: 100%;
    display: flex; align-items: center;
    font-size: .68rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .5px;
    white-space: nowrap;
    flex-shrink: 0;
    gap: 5px;
}
.news-ticker-label i { font-size: .7rem; animation: tickerPulse 1.5s infinite; }
@keyframes tickerPulse { 0%,100%{opacity:1} 50%{opacity:.5} }

.news-ticker-track {
    flex: 1; overflow: hidden;
    position: relative;
}
.news-ticker-inner {
    display: flex;
    white-space: nowrap;
    animation: tickerScroll 35s linear infinite;
    font-size: .75rem;
    gap: 0;
}
.news-ticker-inner:hover { animation-play-state: paused; }
@keyframes tickerScroll {
    from { transform: translateX(100%); }
    to   { transform: translateX(-100%); }
}
.news-ticker-item {
    padding: 0 2rem;
    display: inline-flex; align-items: center; gap: .5rem;
    opacity: .92;
}
.news-ticker-item::before {
    content: '●'; font-size: .4rem; opacity: .6;
}

/* ══════════════ RESPONSIVO ═════════════════════════════════ */
@media (max-width: 768px) {
    .dm2-container {
        height: 100%; max-height: 100%;
        border-radius: 0;
        max-width: 100%;
    }
    .dm2-sidebar { width: 200px; }
    .dm2-details { display: none; }
    .dm2-overlay { padding: 0; }
}
@media (max-width: 560px) {
    .dm2-sidebar { display: none; }
}
