/* Khung Chat */
/* ----- Chat: danh sách cuộc trò chuyện -> bấm vào mở khung nhắn ----- */
.chat { width:min(420px, calc(100vw - 24px)); border-radius:14px; }
.chat-head { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:16px 18px 10px; }
.chat-head h3 { font-size:22px; font-weight:700; padding:0; border:0; }
.chat-head .tools { display:flex; gap:2px; }
.chat-ic { width:36px; height:36px; display:grid; place-items:center; border:0; border-radius:8px; background:none; color:var(--icon); }
.chat-ic:hover { background:var(--surface-2); color:var(--text); }
.chat-ic svg { width:22px; height:22px; }
.chat-search { position:relative; margin:0 18px 6px; }
.chat-search svg { position:absolute; left:12px; top:50%; width:18px; height:18px; transform:translateY(-50%); color:var(--text-3); pointer-events:none; }
.chat .chat-search input { width:100%; min-height:40px; padding:0 12px 0 38px; background:var(--surface-2); border-color:transparent; }
.chat-sec { display:flex; align-items:center; gap:10px; padding:12px 18px 6px; color:var(--text-2); font-size:14px; }
.chat-sec svg { width:18px; height:18px; color:var(--text-3); }
.chat-rooms { max-height:min(330px, 46vh); overflow-y:auto; padding:0 8px 6px; }
.room { display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:2px 12px; align-items:center; width:100%; padding:9px 10px; border:0; border-radius:10px; background:none; text-align:left; }
.room:hover { background:var(--surface-2); }
.room-av { grid-row:span 2; width:46px; height:46px; border-radius:50%; display:grid; place-items:center; overflow:hidden; color:#fff; font-size:20px; font-weight:500; background:var(--c, var(--avatar)); }
.room-av img { width:100%; height:100%; object-fit:cover; }
.room .t { font-size:14.5px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.room .d { font-size:12.5px; color:var(--text-3); white-space:nowrap; }
.room .l { grid-column:2; font-size:13px; color:var(--text-3); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.room .u { min-width:18px; height:18px; padding:0 5px; border-radius:99px; background:var(--danger); color:#fff; font-size:11px; font-weight:600; line-height:18px; text-align:center; justify-self:end; }
.chat-all { display:block; width:100%; padding:14px; border:0; border-top:1px solid var(--border); background:none; color:var(--primary); font-weight:600; letter-spacing:.03em; }
.chat-all:hover { background:var(--surface-2); }
.thread-head { display:flex; align-items:center; gap:10px; padding:10px 12px; border-bottom:1px solid var(--border); }
.thread-head > div:last-child { min-width:0; }
.thread-head b { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.thread-head .room-av { width:36px; height:36px; font-size:16px; flex:none; }
.chat-list { height:min(400px, 52vh); overflow-y:auto; padding:12px 14px; display:flex; flex-direction:column; gap:10px; background:var(--surface-2); }
.msg { max-width:82%; align-self:flex-start; }
.msg.mine { align-self:flex-end; }
.msg .who { font-size:12px; color:var(--text-3); margin:0 4px 3px; }
.msg.mine .who { text-align:right; }
.msg .bub { padding:8px 12px; border-radius:14px; background:var(--surface); border:1px solid var(--border); white-space:pre-wrap; overflow-wrap:anywhere; font-size:14px; }
.msg.mine .bub { background:var(--primary-050); border-color:var(--primary-050); }
.chat-form { display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--border); }
.chat .chat-form input { border-radius:99px; min-height:38px; padding:0 16px; }
.chat-form button { width:38px; height:38px; flex:none; border:0; border-radius:50%; background:var(--primary); color:#fff; display:grid; place-items:center; }
.chat-form button:hover { background:var(--primary-600); }
.chat-form button svg { width:18px; height:18px; }
.new-room { display:grid; grid-template-columns:auto minmax(0,1fr); gap:18px; align-items:center; }
.room-pick { width:112px; height:112px; border-radius:50%; display:grid; place-items:center; overflow:hidden; cursor:pointer; background:var(--primary-050); color:var(--primary); }
.room-pick svg { width:42px; height:42px; }
.room-pick img { width:100%; height:100%; object-fit:cover; }
.switch { appearance:none; -webkit-appearance:none; position:relative; width:42px; height:24px; flex:none; border-radius:99px; background:var(--border-2); cursor:pointer; transition:background .15s; }
.switch::after { content:""; position:absolute; top:3px; left:3px; width:18px; height:18px; border-radius:50%; background:#fff; box-shadow:0 1px 2px rgba(20,24,33,.25); transition:left .15s; }
.switch:checked { background:var(--primary); }
.switch:checked::after { left:21px; }
@media (max-width:480px) { .new-room { grid-template-columns:minmax(0,1fr); justify-items:center; } .new-room > div { width:100%; } }
