/* man_gap.css — giao dien cho man hinh gap / man trung (khoang 431–1100 px).
 *
 * Muc dich: may gap 2 man (man ngoai 466x678, man trong 951x669) roi vao khoang giua
 * ma truoc day chi co 2 bo cuc: dien thoai (<=760) va desktop (>=761, sidebar 236-262px
 * an mat be rong). File nay chi them luat theo BE RONG / CHIEU CAO / safe-area, KHONG do ten may.
 *
 * Gia dinh (chua do tren may that): man ngoai 466x678, man trong 951x669 (uoc thap 890x626),
 * safe-area phai 84px, duoi 34px. Xem docs/memory/2026-11-20-giao-dien-iphone-duo.md.
 *
 * Safe-area: MOI luat dung bien --sai-t/r/b/l (khai o :root, mac dinh = env(safe-area-inset-*)).
 * Harness chup anh ghi de 4 bien nay theo tung co (Chrome headless khong co safe-area that).
 *
 * Pham vi: moi luat nam trong @media 431–1100 px. KHONG doi <=430 (iPhone thuong) va >=1101 (desktop).
 * Chi CSS: xoay / gap / mo may tu doi bo cuc, khong dung lai DOM, khong mat vi tri cuon.
 * Nap SAU mobile_compact.css. mobile_v1/mobile_compact dat padding .uvx-content va bottom-nav bang
 * !important (<=768px) nen cac padding safe-area o day cung phai !important va chon "html body .uvx-app ..."
 * de thang ca ban co lop JS (html.uv-ios-shell) lan cac <style> nhung trong template.
 */

:root { --sai-t: env(safe-area-inset-top, 0px); --sai-r: env(safe-area-inset-right, 0px);
        --sai-b: env(safe-area-inset-bottom, 0px); --sai-l: env(safe-area-inset-left, 0px);
        --mg-nav: 56px; }

/* ===== 1. VO APP: an sidebar, dung bottom-nav (761–1100, vi <=760 da co san) ===== */
@media (min-width: 761px) and (max-width: 1100px) {
  html body .uvx-app .uvx-sidebar:not(.is-open) { display: none; }
  html body .uvx-app .uvx-sidebar.is-open { display: flex; position: fixed; top: 0; left: var(--sai-l); bottom: 0;
    width: 264px; max-width: 84vw; z-index: 70; box-shadow: 0 12px 40px rgba(20,20,40,.3); }
  html body .uvx-app .uvx-main { margin-left: 0 !important; }
  html body .uvx-hamburger, html body .uvx-back { display: inline-block; }
  html body .uvx-backdrop.is-open { display: block; }
  html body .uvx-app .uvx-bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    background: #fff; border-top: 1px solid var(--uvx-border, #E5E7EB); padding-top: 6px; }
  html body .uvx-app .uvx-bottomnav a { flex: 1; text-align: center; text-decoration: none; font-size: 10px; color: var(--uvx-muted, #6B7180); }
  html body .uvx-app .uvx-bottomnav a.is-active { color: var(--uvx-fc, #1A5FA8); }
}

/* ===== 2. SAFE-AREA + CHIEU CAO THAP (431–1100) ===== */
@media (min-width: 431px) and (max-width: 1100px) {
  /* 100vh khong tru thanh dia chi iOS: dung dvh, file goc giu vh lam du phong */
  html body .uvx-app { height: 100dvh; }
  html body .uvx-app .uvx-topbar { height: auto; min-height: 48px; flex-basis: auto; gap: 10px;
    padding-top: max(6px, var(--sai-t)); padding-right: calc(14px + var(--sai-r)) !important; padding-left: calc(14px + var(--sai-l)) !important; }
  html body .uvx-app .uvx-content { padding-top: 14px;
    padding-right: calc(16px + var(--sai-r)) !important; padding-left: calc(16px + var(--sai-l)) !important;
    padding-bottom: calc(var(--mg-nav) + 18px + var(--sai-b)) !important;
    scroll-padding-bottom: calc(var(--mg-nav) + var(--sai-b)); }
  html body .uvx-app .uvx-bottomnav { padding-left: var(--sai-l) !important; padding-right: var(--sai-r) !important;
    padding-bottom: calc(8px + var(--sai-b)) !important; box-sizing: border-box; }
  html body .uvx-bell-panel { right: calc(12px + var(--sai-r)); max-height: calc(100dvh - 140px - var(--sai-b)); }
  html body .uvx-toast { bottom: calc(var(--mg-nav) + 16px + var(--sai-b)); }
  /* o nhap chat web (hop-thu-web): dinh day nhung nam TREN bottom-nav, tranh cot phai 84px */
  html body .cuo .go { bottom: calc(var(--mg-nav) + var(--sai-b)); right: var(--sai-r); left: var(--sai-l); }
  html body .cuo { padding-bottom: calc(190px + var(--sai-b)); }
}

/* man ngoai xoay ngang (678x466) va moi man cao < 520px: thanh tren/duoi gon */
@media (min-width: 431px) and (max-width: 1100px) and (max-height: 520px) {
  :root { --mg-nav: 44px; }
  html body .uvx-app .uvx-topbar { min-height: 40px; }
  html body .uvx-app .uvx-bottomnav { padding-top: 2px; padding-bottom: calc(2px + var(--sai-b)) !important; }
  html body .uvx-app .uvx-bottomnav a { font-size: 9px; }
  html body .uvx-app .uvx-content { padding-top: 8px; }
}

/* ===== 3. HAI COT danh sach + chi tiet (840–1100: 951x669 va 890x626; 669x951 chi 669 nen 1 cot) ===== */
@media (min-width: 840px) and (max-width: 1100px) {

  /* --- 3a. Tin nhan (/tin-nhan): san co 2 vung, template an 1 vung o <=1100; mo lai ca hai --- */
  /* template dat "#tn.mo-chat #tn-trai{display:none}" va "#tn:not(.mo-chat) #tn-phai{display:none}" (2 id + 1 class):
     bo chon cua ta phai co class tuong duong thi moi thang, nen liet ke ca hai trang thai mo-chat */
  html body #tn #tn-trai, html body #tn.mo-chat #tn-trai { display: flex; width: 300px; min-width: 260px; flex: none; }
  html body #tn #tn-phai, html body #tn:not(.mo-chat) #tn-phai { display: flex; min-width: 0; }
  html body #tn #tn-quaylai { display: none !important; }
  html body #tn { border-radius: 14px; }

  /* --- 3b. Giao viec (/viec21/ -> gv2/console): trai = danh sach viec (.g2col.m, 1fr), phai = buoc + lich su (.g2col.l tren, .g2col.r duoi, 320px) --- */
  html body .g2ws .g2body, html body .g2ws .g2body.rong { grid-template-columns: minmax(0, 1fr) 320px; }
  html body .g2ws .g2body .g2col.m { grid-column: 1; grid-row: 1 / span 2; }
  html body .g2ws .g2body .g2col.l { grid-column: 2; grid-row: 1; border-right: 0; border-left: 1px solid var(--g2b, #E5E7EB); border-bottom: 1px solid var(--g2b, #E5E7EB); }
  html body .g2ws .g2body .g2col.r { grid-column: 2; grid-row: 2; border: 0; border-left: 1px solid var(--g2b, #E5E7EB); }

  /* --- 3c. Tro ly (/hoi): cot trai 300px = goi y / lenh nhanh xep doc (luon mo), cot phai = khung chat + o nhap --- */
  html body .hb { max-width: none; }
  html body .hb .hb-scroll { display: grid; grid-template-columns: 300px minmax(0, 1fr); column-gap: 16px; align-content: start; }
  html body .hb .hb-scroll > * { grid-column: 2; min-width: 0; }
  html body .hb .hb-scroll > #hb-dau { grid-column: 1; grid-row: 1 / span 12; display: block;
    position: sticky; top: 0; align-self: start; max-height: calc(100dvh - 190px); overflow: auto; }
  html body .hb #hb-dau .hb-goi { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  html body .hb #hb-dau .hb-goi > * { text-align: left; width: 100%; box-sizing: border-box; }
  html body .hb .hb-dock { margin-left: 316px; }
  html body .hb #hb-mo-goi { display: none; }
}

/* ===== 4. MUOT: transition nhe, tat khi nguoi dung chon giam chuyen dong ===== */
@media (min-width: 431px) and (max-width: 1100px) {
  html body .uvx-content, html body .uvx-topbar, html body .g2ws .g2body { transition: padding .18s ease, grid-template-columns .18s ease; }
}
@media (prefers-reduced-motion: reduce) {
  html body .uvx-content, html body .uvx-topbar, html body .g2ws .g2body { transition: none; }
}
