/* ═══ chat.css — Hộp thư kiểu ứng dụng nhắn tin (danh sách trái · khung trò chuyện phải) ═══ */
:root{--bub-me:linear-gradient(135deg,#a99cff,#66d6ff);--bub-me-fg:#0a0a0a;--bub-them:var(--surface-3);--bub-them-fg:var(--text)}
:root[data-theme="light"]{--bub-me:linear-gradient(135deg,#5b49e0,#1976c9);--bub-me-fg:#fff;--bub-them:#ececec}

.mbx{display:grid;grid-template-columns:minmax(290px,370px) minmax(0,1fr);height:clamp(480px,calc(100dvh - var(--head-h) - var(--mn-h) - 200px),820px);
  border:1px solid var(--line);border-radius:28px;background:var(--surface);overflow:hidden;box-shadow:var(--shadow-1)}
.mbx-side{display:flex;flex-direction:column;min-height:0;min-width:0;border-right:1px solid var(--line);background:var(--bg-soft)}
.mbx-top{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:18px 16px 8px}
.mbx-top h2{font-size:22px;font-weight:800;letter-spacing:-.03em;margin:0}
.mbx-search{position:relative;margin:4px 14px 10px}
.mbx-search>span{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:var(--text-3);display:grid;pointer-events:none}.mbx-search svg{width:17px;height:17px}
.mbx-search input{width:100%;height:42px;padding:0 14px 0 40px;border-radius:99px;background:var(--field);border:1px solid var(--line);font-size:14px;transition:border-color .2s,box-shadow .2s}
.mbx-search input:focus{outline:0;border-color:var(--acc);box-shadow:0 0 0 4px color-mix(in srgb,var(--acc) 15%,transparent)}
.mbx .chips{display:flex;gap:6px;overflow-x:auto;padding:0 14px 10px;scrollbar-width:none;margin:0}.mbx .chips::-webkit-scrollbar{display:none}
.mbx .chips button{flex:none;height:30px;padding:0 13px;border-radius:99px;font-size:12.5px;font-weight:700;color:var(--text-2);background:var(--surface-2);border:1px solid transparent;transition:background .2s,color .2s}
.mbx .chips button:hover{color:var(--text)}.mbx .chips button.on{background:var(--text);color:var(--bg)}
.mbx-list{overflow-y:auto;overscroll-behavior:contain;flex:1;min-height:0;padding:0 8px 12px;display:flex;flex-direction:column;gap:2px}
.mbx .mbx-row{all:unset;box-sizing:border-box;display:grid;grid-template-columns:auto minmax(0,1fr);gap:12px;align-items:center;padding:11px 10px;border-radius:18px;width:100%;cursor:pointer;
  transition:background .15s,transform .2s var(--ez);-webkit-tap-highlight-color:transparent}
.mbx .mbx-row:hover{background:var(--surface-2)}
.mbx .mbx-row:active{transform:scale(.985)}
.mbx .mbx-row:focus-visible{outline:2px solid var(--acc);outline-offset:-2px}
.mbx .mbx-row.on{background:var(--surface-3)}
.mbx .mbx-row.closed{opacity:.62}
.mbx-meta{min-width:0;display:grid;gap:2px}
.mbx-l1{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
.mbx-l1 .nm{font-size:14.5px;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--text)}
.mbx-row.unread .nm{font-weight:800}
.mbx-l1 time{font-size:11.5px;color:var(--text-3);flex:none}
.mbx-row.unread .mbx-l1 time{color:var(--acc);font-weight:700}
.mbx-l2{display:flex;gap:8px;align-items:center;min-width:0}
.mbx-pv{flex:1;min-width:0;font-size:13px;color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mbx-pv em{font-style:normal;color:var(--text-3)}
.mbx-row.unread .mbx-pv{color:var(--text);font-weight:600}
.mbx-dot{width:10px;height:10px;border-radius:50%;background:var(--acc-grad);flex:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--acc) 22%,transparent)}
.mbx-l3{display:flex;gap:5px;flex-wrap:wrap;margin-top:2px}.mbx-l3:empty{display:none}
.mbx-l3 .badge{height:20px;padding:0 8px;font-size:10.5px}

/* Ảnh đại diện */
.cv-av{width:46px;height:46px;border-radius:50%;flex:none;display:grid;place-items:center;font-weight:800;font-size:17px;color:#0a0a0a;
  background:linear-gradient(135deg,hsl(var(--h,220) 80% 70%),hsl(calc(var(--h,220) + 45) 75% 58%));box-shadow:inset 0 0 0 1px rgba(255,255,255,.25)}
.cv-av svg{width:21px;height:21px}
.cv-av.sm{width:30px;height:30px;font-size:12.5px}
.cv-av.dev{background:var(--acc-grad)}
.cv-av.ghost{background:transparent;box-shadow:none}
.cv-av.t-report{background:linear-gradient(135deg,#ff9aa8,#ff6aa8)}.cv-av.t-chat{background:linear-gradient(135deg,#9b8cff,#6fd8ff)}.cv-av.t-support{background:linear-gradient(135deg,#ffd27a,#ff9d6e)}

/* Khung chính */
.mbx-main{min-width:0;min-height:0;display:flex;flex-direction:column;background:var(--surface)}
.mbx-main>.chat{flex:1}
.mbx-empty{margin:auto;text-align:center;padding:40px 24px;display:grid;gap:10px;justify-items:center}
.mbx-empty h3{font-size:19px;margin:6px 0 0}.mbx-empty p{color:var(--text-2);max-width:34ch;font-size:14px}
.mbx-art{width:88px;height:88px;border-radius:30px;display:grid;place-items:center;background:var(--acc-grad);color:#0a0a0a;box-shadow:0 26px 54px -22px var(--acc);transform:rotate(-6deg)}
.mbx-art svg{width:40px;height:40px}.mbx-art.sm{width:58px;height:58px;border-radius:20px}.mbx-art.sm svg{width:27px;height:27px}
.mbx-start{margin:auto;width:min(480px,100%);padding:28px 22px;display:grid;gap:14px;justify-items:center;text-align:center}
.mbx-start h3{margin:0;font-size:20px}.mbx-start p{margin:0;color:var(--text-2);font-size:14px}.mbx-start .field{width:100%;text-align:left}.mbx-start .form-acts{width:100%;display:flex;justify-content:center}

/* Cuộc trò chuyện */
.chat.cv{display:flex;flex-direction:column;height:100%;min-height:0;gap:0;grid-template-rows:none}
.cv-head{display:flex;align-items:center;gap:12px;padding:12px 14px;border-bottom:1px solid var(--line);flex:none;min-height:68px;background:color-mix(in srgb,var(--surface) 88%,transparent)}
.cv-skel{height:44px;width:60%;border-radius:14px;background:linear-gradient(90deg,var(--surface-2),var(--surface-3),var(--surface-2));background-size:200% 100%;animation:shimmer 1.3s linear infinite}
@keyframes shimmer{to{background-position:-200% 0}}
.cv-back{display:none;width:38px;height:38px;border-radius:50%;place-items:center;flex:none;color:var(--text);margin-left:-6px}.cv-back:hover{background:var(--surface-2)}.cv-back svg{width:20px;height:20px}
.cv-who{display:grid;gap:1px;min-width:0;flex:1;justify-content:stretch}
.cv-who b{font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cv-who small{font-size:12px;color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cv-live{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--ok);margin-right:5px;vertical-align:1px;box-shadow:0 0 0 3px color-mix(in srgb,var(--ok) 25%,transparent)}
.cv-tools{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end;align-items:center}
.cv-mail{display:none;font-size:11.5px;color:var(--text-3)}
@media(min-width:1180px){.cv-mail{display:block}}
.cv-logwrap{position:relative;flex:1;min-height:0;display:flex}
.cv-log{flex:1;min-width:0;overflow-y:auto;overscroll-behavior:contain;padding:14px 16px 10px;display:flex;flex-direction:column;gap:2px;border:0;border-radius:0;
  background:radial-gradient(70% 50% at 100% 0,color-mix(in srgb,var(--acc) 6%,transparent),transparent),radial-gradient(60% 40% at 0 100%,color-mix(in srgb,var(--acc-2) 5%,transparent),transparent)}
.cv-day{align-self:center;margin:14px 0 8px}.cv-day span{font-size:11.5px;font-weight:700;color:var(--text-3);padding:4px 12px;border-radius:99px;background:var(--surface-2)}
.cv .msg{display:flex;flex-direction:row;align-items:flex-start;gap:8px;max-width:80%;margin-top:2px}
.cv .msg.first{margin-top:12px}
.cv .msg.me{align-self:flex-end;justify-content:flex-end}.cv .msg.them{align-self:flex-start}
.msg-col{display:flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}
.cv .msg.me .msg-col{align-items:flex-end}
.cv .who{font-size:11.5px;font-weight:700;color:var(--text-3);margin-left:6px}
.cv .bub{padding:9px 14px;line-height:1.5;font-size:14.5px;white-space:pre-wrap;overflow-wrap:anywhere;border:0;background:var(--bub-them);color:var(--bub-them-fg);border-radius:6px 20px 20px 6px;max-width:100%}
.cv .msg.them.first .bub{border-top-left-radius:20px}.cv .msg.them.last .bub{border-bottom-left-radius:20px}
.cv .msg.me .bub{background:var(--bub-me);color:var(--bub-me-fg);border-radius:20px 6px 6px 20px;box-shadow:0 10px 24px -16px var(--acc)}
.cv .msg.me.first .bub{border-top-right-radius:20px}.cv .msg.me.last .bub{border-bottom-right-radius:20px}
.cv .bub a{color:inherit;text-decoration:underline;text-underline-offset:2px;font-weight:600}
.cv .msg time{font-size:11px;color:var(--text-3);padding:0 6px;display:flex;align-items:center;gap:3px}
.cv .seen{display:inline-flex;align-items:center;gap:3px;color:var(--acc)}.cv .seen svg{width:11px;height:11px}
.cv .msg.pop .bub{animation:bubIn .38s var(--spring)}.cv .msg.me.pop .bub{transform-origin:100% 100%}.cv .msg.them.pop .bub{transform-origin:0 100%}
@keyframes bubIn{from{opacity:0;transform:translateY(8px) scale(.9)}}
.cv-down{position:absolute;right:16px;bottom:10px;width:42px;height:42px;border-radius:50%;display:grid;place-items:center;background:var(--surface);border:1px solid var(--line-strong);box-shadow:var(--shadow-1);animation:bubIn .3s var(--spring)}
.cv-down[hidden]{display:none}.cv-down svg{width:19px;height:19px}
.cv-down i{position:absolute;top:-6px;right:-4px;min-width:18px;height:18px;padding:0 5px;border-radius:99px;background:var(--acc-grad);color:#0a0a0a;font:800 10.5px/18px var(--font);font-style:normal;text-align:center}.cv-down i[hidden]{display:none}
.cv-quick{display:flex;gap:8px;overflow-x:auto;padding:8px 14px 0;scrollbar-width:none;flex:none}.cv-quick::-webkit-scrollbar{display:none}.cv-quick[hidden]{display:none}
.cv-quick button{flex:none;max-width:260px;height:32px;padding:0 13px;border-radius:99px;font-size:12.5px;font-weight:600;color:var(--text-2);background:var(--surface-2);border:1px solid var(--line);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:color .2s,border-color .2s,transform .25s var(--spring)}
.cv-quick button:hover{color:var(--text);border-color:var(--line-strong)}.cv-quick button:active{transform:scale(.96)}
.chat-form.cv-form{display:flex;align-items:flex-end;gap:10px;padding:12px 14px calc(12px + var(--safe-b));grid-template-columns:none;flex:none}
.cv-form[hidden]{display:none}
.cv-input{flex:1;min-width:0;display:flex;background:var(--field);border:1px solid var(--line);border-radius:23px;padding:3px 8px 3px 16px;transition:border-color .2s,box-shadow .2s}
.cv-input:focus-within{border-color:var(--acc);box-shadow:0 0 0 4px color-mix(in srgb,var(--acc) 15%,transparent)}
.cv-input textarea{width:100%;min-height:38px;max-height:140px;padding:9px 0;border:0!important;outline:0!important;box-shadow:none!important;background:transparent!important;resize:none;line-height:1.45;font-size:15px;border-radius:0}
.cv-send{width:46px;height:46px;border-radius:50%;flex:none;display:grid;place-items:center;background:var(--surface-3);color:var(--text-3);transition:background .25s,color .25s,transform .3s var(--spring)}
.cv-send svg{width:19px;height:19px;transform:translateX(1px)}
.cv-form.has .cv-send{background:var(--acc-grad);color:#0a0a0a;box-shadow:0 12px 26px -12px var(--acc)}
.cv-form.has .cv-send:hover{transform:scale(1.08)}.cv-send:active{transform:scale(.9)}
.cv-form.busy{opacity:.7;pointer-events:none}
.form-error.cv-err{margin:0;padding:0 18px 10px;font-size:12.5px}.form-error.cv-err:empty{display:none}

@media(max-width:820px){
  .mbx{grid-template-columns:minmax(0,1fr);height:calc(100dvh - var(--head-h) - var(--mn-h) - var(--bar-h) - var(--safe-b) - 150px);min-height:440px;border-radius:24px}
  .mbx-main{display:none}.mbx.has-sel .mbx-side{display:none}.mbx.has-sel .mbx-main{display:flex}
  .cv-back{display:grid}
  .cv .msg{max-width:90%}
  .cv-tools .btn{height:32px;padding:0 11px;font-size:12px}
}
@media(max-width:820px){.mbx.has-sel{height:calc(100dvh - var(--head-h) - var(--mn-h) - var(--bar-h) - var(--safe-b) - 110px)}}
@media(prefers-reduced-motion:reduce){.cv .msg.pop .bub,.cv-down,.cv-skel{animation:none}}
