/* CollHub - chat view. */
.view.view-chat { overflow: hidden; display: flex; }
.chat { flex: 1; display: flex; min-height: 0; min-width: 0; background: var(--surface); }

/* ---- conversation list ---- */
.chat-list { width: 320px; flex: 0 0 320px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--surface-2); min-height: 0; }
.chat-search { position: relative; padding: 12px; border-bottom: 1px solid var(--line); }
.chat-search i { position: absolute; left: 24px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.chat-search .input { padding-left: 32px; background: var(--surface); }
.chat-list-scroll { flex: 1; overflow: auto; padding: 4px 8px 16px; }
.chat-sec { display: flex; align-items: center; justify-content: space-between; padding: 14px 6px 4px 8px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.chat-sec .btn { width: 26px; height: 26px; padding: 0; color: var(--muted); }
.chat-sec .btn:hover { color: var(--primary); background: var(--primary-50); }
.chat-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 8px; color: var(--ink-2); min-width: 0; }
.chat-item:hover { background: rgba(28, 39, 51, .05); }
.chat-item.is-active { background: var(--primary-50); color: var(--primary-600); }
.chat-item.is-unread .chat-item-name { font-weight: 800; color: var(--ink); }
.chat-hash { width: 22px; text-align: center; color: var(--muted); font-size: 13px; }
.chat-item.is-active .chat-hash { color: var(--primary); }
.chat-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-item-row { display: flex; align-items: baseline; gap: 6px; }
.chat-item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.chat-item-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chat-item-preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.is-unread .chat-item-preview { color: var(--ink-2); font-weight: 600; }
.chat-unread { background: var(--accent); color: #fff; font-size: 11px; min-width: 20px; height: 20px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.chat-list-empty { color: var(--muted); font-size: 12.5px; padding: 6px 10px; }

/* ---- conversation ---- */
.chat-conv { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); min-height: 62px; }
.chat-back { display: none; }
.chat-head-hash { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.chat-head-text { flex: 1; min-width: 0; }
.chat-head-text h3 { margin: 0; font-size: 16px; }
.chat-head-text div { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status.is-on { color: var(--success); font-weight: 700; }
.chat-members { display: flex; align-items: center; background: none; border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px 3px 4px; }
.chat-members:hover { border-color: var(--primary); }
.chat-members .avatar { margin-left: -5px; border: 2px solid var(--surface); }
.chat-members .avatar:first-child { margin-left: 0; }
.chat-members span { margin-left: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }

.chat-body { flex: 1; min-height: 0; position: relative; display: flex; }
.chat-messages { flex: 1; overflow: auto; padding: 10px 0 14px; }
.chat-newpill { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: var(--primary); color: #fff; border: 0; border-radius: 20px; padding: 7px 14px; font-weight: 700; box-shadow: var(--shadow); z-index: 3; }
.chat-drop { position: absolute; inset: 8px; border: 2px dashed var(--primary); border-radius: var(--radius-lg); background: rgba(232, 242, 245, .92); color: var(--primary); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-weight: 700; z-index: 5; pointer-events: none; }
.chat-drop i { font-size: 40px; }

.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 40px 20px; max-width: 380px; }
.chat-empty i { font-size: 46px; color: var(--primary); --fa-secondary-opacity: .3; margin-bottom: 10px; }
.chat-empty h3 { color: var(--ink); margin: 6px 0; }
.chat-empty p { margin: 0 0 16px; }
.chat-empty-inline { padding: 60px 20px 20px; }

.msg-older { text-align: center; padding: 6px 0 12px; }
.msg-day { display: flex; align-items: center; gap: 12px; margin: 14px 18px 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.msg-day::before, .msg-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg-day span { text-transform: capitalize; }
.msg-unread-divider { display: flex; align-items: center; gap: 10px; margin: 8px 18px; color: var(--danger); font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.msg-unread-divider::before, .msg-unread-divider::after { content: ""; flex: 1; height: 1px; background: var(--danger); opacity: .5; }

.msg { position: relative; display: flex; gap: 10px; padding: 5px 18px 3px; }
.msg.is-cont { padding-top: 1px; }
.msg:hover { background: rgba(28, 39, 51, .025); }
.msg.is-mentioned { background: var(--warning-50); box-shadow: inset 3px 0 0 var(--warning); }
.msg-gutter { width: 38px; flex: 0 0 38px; display: flex; justify-content: center; }
.msg-hover-time { font-size: 10.5px; color: var(--muted); opacity: 0; padding-top: 7px; }
.msg:hover .msg-hover-time { opacity: 1; }
.msg-main { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-head b { font-size: 13.5px; }
.msg-head time { font-size: 11.5px; color: var(--muted); }
.msg-bubble { display: flex; flex-direction: column; align-items: flex-start; max-width: min(720px, 100%); }
.msg.is-mine .msg-bubble .msg-text { background: var(--primary-50); border-radius: 4px 12px 12px 12px; padding: 6px 11px; }
.msg.is-mine.is-cont .msg-bubble .msg-text { border-radius: 12px; }
.msg-text { color: var(--ink); white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.msg-text a { color: var(--primary); text-decoration: underline; }
.msg-edited { font-size: 11.5px; color: var(--muted); }
.msg-deleted { color: var(--muted); font-style: italic; background: none !important; padding-left: 0 !important; }
.mention { background: rgba(31, 111, 139, .12); color: var(--primary-600); font-weight: 700; border-radius: 4px; padding: 0 3px; }
.mention.is-me { background: rgba(217, 142, 4, .2); color: #8a5a02; }
.msg-files { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; margin-top: 5px; }
.msg-img { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); padding: 0; max-width: 300px; text-align: left; }
.msg-img img { display: block; max-width: 300px; max-height: 220px; object-fit: cover; background: #efece6; }
.msg-img span { font-size: 12px; color: var(--muted); padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-img:hover { border-color: var(--primary); }
.msg-seen { font-size: 11.5px; color: var(--primary); margin-top: 3px; font-weight: 600; }
.msg-actions { position: absolute; right: 16px; top: -12px; display: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); padding: 2px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions .btn { width: 28px; height: 28px; padding: 0; color: var(--ink-2); }
.msg-actions .btn:hover { color: var(--primary); }
.msg-actions .msg-del:hover { color: var(--danger); background: var(--danger-50); }
.msg-edit { width: min(720px, 100%); }
.msg-edit-input { min-height: 38px; resize: none; }
.msg-edit-actions { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.msg-edit-actions span { flex: 1; font-size: 11.5px; color: var(--muted); }
.msg.is-cont .msg-edit { margin-top: 2px; }

/* ---- typing and composer ---- */
.chat-typing { height: 22px; padding: 0 22px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-3px); opacity: 1; } }
.chat-composer { padding: 0 18px 12px; }
.chat-compose-row { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 6px; background: var(--surface); }
.chat-compose-row:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 139, .15); }
.chat-input-wrap { flex: 1; position: relative; min-width: 0; }
.chat-input { width: 100%; border: 0; outline: none; resize: none; padding: 7px 4px; max-height: 180px; line-height: 1.45; background: transparent; }
.chat-send { flex: 0 0 auto; }
.chat-hint { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); padding: 6px 4px 0; }
.chat-hint i { color: var(--primary); }
.chat-hint kbd { font-family: inherit; font-size: 10.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.chat-staged { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.staged-file { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 4px 6px 4px 9px; max-width: 280px; }
.staged-file i { color: var(--primary); }
.staged-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 12.5px; }
.staged-file small { color: var(--muted); white-space: nowrap; }
.staged-file button { background: none; border: 0; color: var(--muted); padding: 0 4px; }
.staged-file button:hover { color: var(--danger); }
.chat-mention-menu { position: absolute; left: 0; bottom: calc(100% + 10px); width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px; z-index: 10; }
.mention-opt { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 6px 8px; border-radius: 6px; text-align: left; }
.mention-opt small { color: var(--muted); margin-left: auto; }
.mention-opt.is-active, .mention-opt:hover { background: var(--primary-50); }

/* ---- modals ---- */
.dm-search { margin-bottom: 10px; }
.dm-people { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
.dm-person { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 1px solid transparent; border-radius: var(--radius); padding: 8px; text-align: left; }
.dm-person:hover { background: var(--primary-50); border-color: var(--primary-50); }
.dm-person span { flex: 1; display: flex; flex-direction: column; }
.dm-person small { color: var(--muted); }
.dm-person em.is-on { color: var(--success); font-style: normal; font-weight: 700; }
.dm-person > i { color: var(--primary); }
.chat-member-list { display: flex; flex-direction: column; gap: 8px; }
.chat-member { display: flex; align-items: center; gap: 10px; }
.chat-member span { display: flex; flex-direction: column; }
.chat-member small { color: var(--muted); }

/* ---- phone: list and conversation are separate screens ---- */
@media (max-width: 760px) {
    .chat-list { width: 100%; flex: 1 1 auto; border-right: 0; }
    .chat-conv { display: none; }
    .chat.is-conv-open .chat-list { display: none; }
    .chat.is-conv-open .chat-conv { display: flex; }
    .chat-back { display: inline-flex; }
    .chat-head { padding: 8px 10px; gap: 8px; }
    .chat-head .btn-sm span { display: none; }
    .msg { padding-left: 10px; padding-right: 10px; }
    .chat-composer { padding: 0 8px 8px; }
    .chat-hint span:first-child { display: none; }
    .msg-img img { max-width: 220px; }
}
