/* v9 – Bố cục kiểu "thanh ngang trên + cột lọc trái" */
:root { --top: #ffffff; --top-ink: #2b2f3f; --top-2: #f6f6f8; --rail-ink: #6b7088; --chat-bg: #f3f1ee; }
@media (prefers-color-scheme: dark) { :root { --top: #181b29; --top-ink: #e7e9f3; --top-2: #141622; --rail-ink: #9096b0; --chat-bg: #11131d; } }

.app.v9 { flex-direction: column; }
.app-main { flex: 1; min-height: 0; display: flex; }

/* Thanh ngang trên */
.topbar { height: 48px; flex: 0 0 48px; background: var(--top); color: var(--top-ink); border-bottom: 1px solid var(--line); box-shadow: 0 1px 4px #0000000d; display: flex; align-items: center; padding: 0 14px; gap: 18px; position: relative; z-index: 10; }
.tb-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; min-width: 180px; }
.tb-brand .logo { width: 30px; height: 30px; }
.tb-tabs { flex: 1; display: flex; justify-content: center; gap: 4px; }
.topbar .rail-btn { width: auto; height: 48px; padding: 0 16px; border-radius: 0; color: var(--top-ink); font-size: 13.5px; font-weight: 500; filter: none; opacity: .75; display: inline-flex; align-items: center; gap: 6px; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.topbar .rail-btn .ic { display: none; }
.topbar .rail-btn:hover { background: transparent; opacity: 1; color: var(--accent); }
.topbar .rail-btn.active { background: transparent; opacity: 1; font-weight: 700; color: var(--accent); border-bottom-color: var(--accent); }
.tb-right { display: flex; align-items: center; gap: 10px; min-width: 180px; justify-content: flex-end; }
.tb-me { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tb-me .avatar-btn { width: 30px; height: 30px; font-size: 12px; box-shadow: 0 0 0 2px var(--line); }
.topbar #bellBtn { width: 34px; height: 34px; padding: 0; border-radius: 50%; background: var(--bg); font-size: 16px; justify-content: center; border: 0; }
.topbar .notif-panel { left: auto; right: 0; top: 42px; bottom: auto; color: var(--text); }

/* Cột lọc bên trái */
.app.v9 .rail { width: 48px; background: var(--top-2); border-right: 1px solid var(--line); padding: 8px 0; gap: 4px; }
.frail-btn { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--rail-ink); cursor: pointer; display: grid; place-items: center; position: relative; }
.frail-btn svg { width: 18px; height: 18px; fill: currentColor; }
.frail-btn:hover { background: var(--accent-soft, #e3141b14); color: var(--accent); }
.frail-btn.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.frail-btn[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 42px; top: 50%; transform: translateY(-50%); background: #1d2033; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 30; }

/* Danh sách hội thoại */
.app.v9 .list-col { width: 330px; }
.app.v9 .list-head { padding: 8px; gap: 6px; }
.app.v9 #filterChips { display: none; }
.app.v9 .conv { padding: 9px 10px 9px 9px; border-left: 3px solid var(--pc, transparent); gap: 10px; }
.app.v9 .conv.active { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.app.v9 .conv .avatar { width: 44px; height: 44px; flex-basis: 44px; }
.app.v9 .conv .name { font-weight: 500; }
.app.v9 .conv.unread .name { font-weight: 700; }
.app.v9 .conv .snippet { color: var(--text); opacity: .8; font-size: 12.5px; }
.app.v9 .conv .meta { justify-content: space-between; }
.app.v9 .conv .meta .pname { display: none; }
.ctype { color: #9aa1b5; display: inline-flex; }
.ctype svg { width: 15px; height: 15px; fill: currentColor; }
.app.v9 .conv .kind.cmt { display: none; }

/* Khung chat */
.app.v9 .chat-col { background: var(--chat-bg); }
.app.v9 .messages { background: var(--chat-bg); }
.app.v9 .empty { color: #8a8f9e; font-size: 16px; }
.app.v9 .chat-head { min-height: 56px; }

/* Thông tin khách luôn hiện trên màn hình rộng */
.info-empty { color: var(--muted); text-align: center; margin-top: 24px; }
@media (min-width: 1280px) {
  .app.v9 .info-col { width: 320px; }
  .app.v9 #infoClose { display: none; }
}

/* Điện thoại: thanh ngang chuyển xuống dưới thành thanh tab */
@media (max-width: 760px) {
  .app.v9 { flex-direction: column-reverse; }
  .app.v9 .rail { display: none; }
  .app.v9 .list-col { width: 100%; }
  .app.v9 #filterChips { display: flex; }
  .topbar { height: auto; flex: 0 0 auto; padding: 2px 4px calc(2px + env(safe-area-inset-bottom)); gap: 0; border-bottom: 0; border-top: 1px solid var(--line); box-shadow: 0 -1px 4px #0000000d; }
  .tb-brand, .tb-me .nm { display: none; }
  .tb-tabs { justify-content: space-around; gap: 0; }
  .tb-right { min-width: 0; gap: 4px; }
  .topbar .rail-btn { flex-direction: column; justify-content: center; gap: 1px; height: 50px; padding: 0 4px; font-size: 10px; border-bottom: 0; border-top: 3px solid transparent; }
  .topbar .rail-btn.active { border-top-color: var(--accent); }
  .topbar .rail-btn .ic { display: block; font-size: 18px; }
  .topbar .notif-panel { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(64px + env(safe-area-inset-bottom)); }
  .app.v9 .conv { padding-left: 9px; }
}
