/* Chat (030 Functionaliteit, Chat). */

/* Top bar: chat icon with the unread counter */
.chat-top { position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: inherit; text-decoration: none; }
.chat-top:hover { background: rgba(255, 255, 255, .12); }
.chat-top .badge { position: absolute; top: -2px; right: -4px; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.badge[hidden] { display: none; }

/* Page */
.chat-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 10px; height: calc(100vh - 150px); min-height: 420px; }
.chat-list { overflow: auto; }
.chat-items { list-style: none; margin: 0; padding: 4px; }
.chat-items a { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: var(--r-s); color: inherit; text-decoration: none; }
.chat-items a:hover { background: var(--surface-2); }
.chat-items a.on { background: var(--accent-soft); }
.chat-items .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad-d); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.chat-items .avatar.grp { border-radius: 10px; }
.chat-items .grow { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.chat-items .grow b, .chat-items .grow small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-items .grow small { color: var(--fg-2); }
.chat-items a.unread .grow b { font-weight: 800; }
.chat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: var(--fg-2); }
.chat-noconv { padding: 12px; }

.chat-conv { display: flex; flex-direction: column; min-height: 0; }
.chat-none { display: grid; place-items: center; }
.chat-head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.chat-head .grow { display: flex; flex-direction: column; min-width: 0; }
.chat-head small { color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-back { display: none; font-size: 22px; text-decoration: none; color: inherit; }
.chat-msgs { flex: 1; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.chat-older, .chat-empty { text-align: center; margin: 0; }
.chat-msg { max-width: 72%; align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 6px 10px; }
.chat-msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-radius: 12px 12px 4px 12px; }
.chat-msg.deleted { opacity: .7; }
.chat-from { display: block; font-size: 12px; color: var(--accent); }
.chat-text { margin: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-entity, .chat-file { margin: 4px 0; font-size: 13px; }
.chat-entity a, .chat-entity span { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.chat-file a { display: inline-flex; gap: 4px; align-items: center; }
.chat-file .i { width: 14px; height: 14px; }
.chat-msg footer { display: flex; gap: 8px; align-items: center; justify-content: flex-end; font-size: 11px; color: var(--fg-2); flex-wrap: wrap; }
.chat-msg footer form { display: inline; }
.chat-receipt { color: var(--accent); text-decoration: none; }
.chat-act { background: none; border: 0; padding: 0; color: var(--fg-2); font: inherit; cursor: pointer; text-decoration: underline; }

.chat-compose { border-top: 1px solid var(--line-2); padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.chat-compose textarea { resize: vertical; min-height: 44px; }
.chat-tools { display: flex; gap: 8px; align-items: center; }
.chat-tools .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attach { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }

.chat-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; align-items: start; }
.chat-cols form { display: inline; }
.chat-cols .chat-add, .chat-cols .body > form { display: block; margin-top: 10px; }
.chat-pick { display: flex; flex-direction: column; gap: 4px; border: 0; padding: 0; }

@media (max-width: 760px) {
  .chat-grid { grid-template-columns: 1fr; height: auto; }
  .chat.chat-open .chat-list { display: none; }
  .chat:not(.chat-open) .chat-conv { display: none; }
  .chat-back { display: inline; }
  .chat-conv { height: calc(100vh - 150px); }
  .chat-msg { max-width: 88%; }
}
