/* K-Bao shop: base + float nav panel + chat widget + welcome window + video gallery */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f6f9fc; --card: #ffffff; --text: #1e293b; --muted: #64748b; --line: #e2eaf2;
  --navy: #0b2b4a; --brand: #3182ce; --brand2: #1a73e8;
}
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif; line-height: 1.6; }
a { color: #1a73e8; text-decoration: none; }
img { max-width: 100%; height: auto; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* header */
header.site { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 500; }
.bar { display: flex; align-items: center; gap: 18px; height: 58px; }
.logo { font-size: 20px; color: var(--navy); font-weight: 300; }
.logo b { color: #f09b8c; }
nav.main { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
nav.main a { color: #475569; padding: 6px 10px; border-radius: 8px; font-size: 15px; }
nav.main a.on { color: #1a73e8; background: #eef4ff; }
.langbox { position: relative; }
.langbox > button { border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.langbox .menu { display: none; position: absolute; inset-inline-end: 0; top: 110%; background: #fff; border: 1px solid var(--line); border-radius: 10px; min-width: 160px; box-shadow: 0 8px 24px rgba(16,42,67,.12); z-index: 600; }
.langbox.open .menu { display: block; }
.langbox .menu a { display: block; padding: 8px 12px; color: #334155; }
.langbox .menu a.cur { color: #1a73e8; font-weight: 600; }

main { padding: 18px 0 46px; }
.hero { padding: 16px 0; }
.hero h1 { color: var(--navy); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.card .thumb img { width: 100%; height: 200px; object-fit: cover; }
.card .body { padding: 12px 14px 14px; }
.card h3 { font-size: 16px; margin-bottom: 6px; }
.card .desc { color: var(--muted); font-size: 13px; min-height: 34px; }
.cta { display: flex; gap: 8px; margin-top: 10px; }
.btn { display: inline-block; background: var(--brand); color: #fff !important; border: 0; border-radius: 9px; padding: 8px 14px; cursor: pointer; font-size: 14px; }
.btn.ghost { background: #fff; color: var(--brand) !important; border: 1px solid var(--brand); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 22px 0; }
.empty { padding: 40px; text-align: center; color: #94a3b8; }
footer.site { border-top: 1px solid var(--line); padding: 18px 0; color: var(--muted); font-size: 13px; background: var(--card); }

/* product page */
.prod .heroimg img { max-width: 100%; border-radius: 16px; }
.prod .short { color: #475569; font-size: 15px; margin: 8px 0 14px; }
.detail { margin-top: 18px; }
.detail img, .detail video { max-width: 100%; height: auto; }

/* chat page */
.chatpage { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; max-width: 760px; margin: 0 auto; }
.chatpage .msgs { min-height: 320px; max-height: 58vh; overflow-y: auto; }
.prod-banner { background: #fff8f0; border: 1px solid #f6dcc6; border-radius: 10px; padding: 8px 12px; margin: 10px 0; font-size: 13px; }

/* ============ messages (PHP widget.js parity) ============ */
.msg-customer { text-align: end; margin: 4px 0; }
.msg-assistant { text-align: start; margin: 4px 0 8px; }
.msg-time { font-size: 10px; color: #999; margin-bottom: 2px; }
.msg-prod { font-size: 11px; color: #1a73e8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble { display: inline-block; padding: 6px 12px; border-radius: 12px; max-width: 80%; text-align: start; word-break: break-word; white-space: pre-wrap; }
.msg-customer .bubble { background: #e2e8f0; color: #222; }
.msg-assistant .bubble { background: var(--brand); color: #fff; }
.status-bubble { display: inline-block; background: #f0f0f0; color: #999; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.inbar { display: flex; gap: 8px; margin-top: 10px; }
.inbar input { flex: 1; border: 1px solid #cbd5e1; border-radius: 9px; padding: 8px 10px; font-size: 14px; }
.guest-hint { font-size: 12px; color: #2c5282; background: #ebf8ff; padding: 8px 12px; border-radius: 6px; border-inline-start: 3px solid #4299e1; margin-bottom: 8px; }
.register-btn { background: #fff; color: var(--brand); border: 1px solid var(--brand); border-radius: 9px; padding: 8px 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.account-chip { font-size: 12px; color: #38a169; padding: 2px 0 8px; }
.account-chip button { border: 0; background: none; color: #e53e3e; cursor: pointer; font-size: 12px; text-decoration: underline; }

/* register modal */
.modal-overlay { position: fixed; inset: 0; z-index: 100000; background: rgba(0,0,0,.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 16px; padding: 26px 30px; max-width: 420px; width: 92%; animation: modalPop .25s cubic-bezier(.34,1.56,.64,1); }
@keyframes modalPop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { color: var(--navy); margin-bottom: 6px; }
.modal p.hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.modal label { display: block; font-size: 12px; color: #475569; margin: 8px 0 4px; }
.modal input { width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; padding: 9px 11px; font-size: 14px; }
.modal .code-row { display: flex; gap: 8px; }
.modal .code-row input { flex: 1; }
.modal .code-row button { border: 0; background: var(--brand); color: #fff; border-radius: 9px; padding: 0 14px; cursor: pointer; white-space: nowrap; }
.modal .msgline { min-height: 18px; font-size: 13px; margin: 10px 0; color: #e53e3e; }
.modal .btns { display: flex; gap: 10px; }
.modal .btns .cancel { flex: 1; background: #fff; border: 1px solid #cbd5e1; border-radius: 9px; padding: 9px; cursor: pointer; }
.modal .btns .ok { flex: 2; background: var(--brand); color: #fff; border: 0; border-radius: 9px; padding: 9px; cursor: pointer; }

/* ============ unified float nav panel (PHP #ai-unified-float-panel parity) ============ */
#ai-nav-panel { position: fixed; right: 20px; top: 50%; transform: translateY(-50%); width: 280px; max-height: 92vh; background: #fff; border-radius: 16px; z-index: 99999; overflow: hidden; box-shadow: 0 12px 40px rgba(16,42,67,.22), 0 2px 8px rgba(16,42,67,.12); }
#ai-nav-panel.dragged { transform: none; }
#ai-nav-panel.panel-disk { width: 64px; height: 64px; border-radius: 50%; right: 0; cursor: pointer; background: linear-gradient(135deg,#1a73e8,#7c3aed); }
#ai-nav-panel.panel-disk:not(.dragged) { animation: diskBreath 2.5s infinite; }
#ai-nav-panel.panel-disk > *:not(.disk-inner) { display: none !important; }
#ai-nav-panel .disk-inner { display: none; width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 28px; color: #fff; }
#ai-nav-panel.panel-disk .disk-inner { display: flex; }
@keyframes diskBreath { 0%,100% { transform: translateY(-50%) scale(1); } 50% { transform: translateY(-50%) scale(1.06); } }
#ai-nav-panel .drag-handle { background: linear-gradient(135deg,#2d3748,#1a202c); color: #fff; font-size: 11px; padding: 6px 10px; cursor: grab; display: flex; justify-content: space-between; align-items: center; }
#ai-nav-panel .breath-bar { background: linear-gradient(90deg,#1a73e8,#7c3aed,#1a73e8); background-size: 200% 100%; animation: shimmer 3s linear infinite; color: #fff; padding: 8px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
@keyframes shimmer { 0% { background-position: 0 0; } 100% { background-position: -200% 0; } }
#ai-nav-panel .breath-bar .dots span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #fff; margin: 0 2px; animation: dotFade 1.2s infinite; }
#ai-nav-panel .breath-bar .dots span:nth-child(2) { animation-delay: .2s; }
#ai-nav-panel .breath-bar .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dotFade { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
#ai-nav-panel .breath-bar .tog { margin-inline-start: auto; background: rgba(255,255,255,.25); border: 0; color: #fff; border-radius: 999px; padding: 3px 10px; font-size: 11px; cursor: pointer; }
#ai-nav-panel .btn-row { display: flex; gap: 8px; padding: 10px 12px 0; }
#ai-nav-panel .btn-row button, #ai-nav-panel .btn-row a { flex: 1; border: 0; border-radius: 10px; color: #fff; padding: 8px 6px; font-size: 12px; cursor: pointer; text-align: center; display: inline-block; }
#ai-nav-panel .btn-about { background: linear-gradient(135deg,#667eea,#764ba2); }
#ai-nav-panel .btn-video { background: linear-gradient(135deg,#f6ad55,#dd6b20); }
#ai-nav-panel .contact-bar { padding: 10px 12px 0; }
#ai-nav-panel .contact-bar a { display: block; background: linear-gradient(135deg,#3182ce,#1a73e8); color: #fff; border-radius: 10px; padding: 9px; text-align: center; font-size: 13px; }
#ai-nav-panel .panel-body { max-height: 46vh; overflow-y: auto; transition: max-height .3s ease; }
#ai-nav-panel.collapsed .panel-body { max-height: 0 !important; overflow: hidden; }
#ai-nav-panel .panel-tabs { display: flex; border-bottom: 1px solid var(--line); margin-top: 10px; }
#ai-nav-panel .panel-tabs button { flex: 1; background: #fff; border: 0; padding: 8px 4px; font-size: 13px; color: #64748b; cursor: pointer; border-bottom: 3px solid transparent; }
#ai-nav-panel .panel-tabs button.active { color: #1a73e8; border-bottom-color: #1a73e8; }
#ai-nav-panel .tab-pane { padding: 10px 12px; display: none; }
#ai-nav-panel .tab-pane.active { display: block; }
#ai-nav-panel .shop-entry { display: block; text-align: center; background: #eef4ff; border-radius: 10px; padding: 8px; margin-bottom: 8px; font-size: 13px; }
#ai-nav-panel .cat-tree { list-style: none; font-size: 13px; }
#ai-nav-panel .cat-tree li { margin: 4px 0; }
#ai-nav-panel .cat-tree a { color: #334155; display: block; padding: 4px 6px; border-radius: 6px; }
#ai-nav-panel .cat-tree a:hover { background: #f1f5f9; }
#ai-nav-panel .cat-tree .cnt { color: #94a3b8; font-size: 11px; }
#ai-nav-panel .recent-list { list-style: none; margin-top: 8px; font-size: 13px; }
#ai-nav-panel .recent-list a { display: block; padding: 5px 6px; color: #334155; border-radius: 6px; }
#ai-nav-panel .recent-list a:hover { background: #f1f5f9; }
#ai-nav-panel .view-all { display: block; text-align: center; font-size: 12px; margin-top: 6px; }
#ai-nav-panel .mini-title { font-size: 12px; color: #64748b; margin: 8px 0 4px; }

/* ============ welcome window (PHP #ai-welcome-window parity) ============ */
#wel-overlay { position: fixed; inset: 0; z-index: 999999; background: rgba(0,0,0,.5); backdrop-filter: blur(4px); display: none; }
#wel-overlay.show { display: block; }
#wel-overlay.closing { transition: opacity .3s ease; opacity: 0; }
#wel-win { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 80vw; height: 80vh; min-width: 320px; min-height: 300px; max-width: 90vw; max-height: 90vh; background: #fff; border-radius: 20px; z-index: 1000000; display: none; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); user-select: none; }
#wel-win.show { display: flex; }
#wel-win.pop { animation: winPop .4s cubic-bezier(.34,1.56,.64,1); }
#wel-win.closing { transition: all .3s ease; opacity: 0; transform: translate(-50%,-50%) scale(.9); }
#wel-win.dragged { transform: none; left: auto; top: auto; }
@keyframes winPop { from { transform: translate(-50%,-50%) scale(.8); opacity: 0; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }
#wel-win .wel-head { background: linear-gradient(135deg,#1a2332 0%,#2d3748 100%); border-bottom: 2px solid #4a5568; color: #fff; padding: 12px 18px; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: grab; flex-shrink: 0; }
#wel-win .wel-head:active { cursor: grabbing; }
#wel-win .wel-head .drag-handle { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; letter-spacing: .5px; }
#wel-win .wel-head .drag-handle .dots { display: flex; gap: 4px; }
#wel-win .wel-head .drag-handle .dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.6); }
#wel-win .wel-head .drag-handle .drag-icon { font-size: 16px; opacity: .8; }
#wel-win .wel-head .wel-close { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.2); font-size: 20px; color: #fff; cursor: pointer; padding: 2px 12px; line-height: 1.4; border-radius: 4px; transition: all .2s; flex-shrink: 0; font-weight: 300; }
#wel-win .wel-head .wel-close:hover { background: rgba(229,62,62,.7); border-color: rgba(229,62,62,.8); transform: rotate(90deg); }
#wel-win .wel-body { flex: 1; overflow-y: auto; padding: 24px 28px; font-size: 15px; line-height: 1.7; color: #1a2332; }
#wel-win .wel-body::-webkit-scrollbar { width: 6px; }
#wel-win .wel-body::-webkit-scrollbar-thumb { background: #c0c8d4; border-radius: 3px; }
#wel-win .wel-body h2 { margin-top: 0; color: #1a73e8; font-size: 24px; }
#wel-win .wel-body h3 { margin-top: 16px; color: #1a2332; font-size: 18px; }
#wel-win .wel-body ul, #wel-win .wel-body ol { padding-inline-start: 20px; margin: 8px 0; }
#wel-win .wel-body li { margin-bottom: 6px; }
#wel-win .wel-body .welcome-link { color: #1a73e8; text-decoration: underline; font-weight: 500; }
#wel-win .wel-body .welcome-link:hover { color: #0d47a1; }
#wel-win .wel-body .welcome-btn { display: inline-block; padding: 10px 24px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 14px; transition: transform .2s, box-shadow .2s; }
#wel-win .wel-body .welcome-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.15); }
#wel-win .wel-body .welcome-btn.primary { background: #1a73e8; color: #fff; }
#wel-win .wel-body .welcome-btn.secondary { background: #f0f6ff; color: #1a73e8; border: 1px solid #d4e2fc; }
#wel-win .wel-foot { padding: 8px 16px 12px; text-align: center; font-size: 11px; color: #b0b8c4; border-top: 1px solid #f0f2f5; cursor: pointer; flex-shrink: 0; }
/* tip modal (PHP #ai-welcome-tip-modal) */
#ai-wel-tip { position: fixed; inset: 0; z-index: 1000001; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); justify-content: center; align-items: center; display: none; }
#ai-wel-tip .tip-card { background: #fff; border-radius: 16px; padding: 30px 35px; max-width: 480px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: winPop .3s cubic-bezier(.34,1.56,.64,1); }
#ai-wel-tip .tip-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
#ai-wel-tip .tip-hd span { font-size: 28px; }
#ai-wel-tip .tip-hd h3 { margin: 0; color: #1a2332; font-size: 18px; }
#ai-wel-tip p { font-size: 15px; line-height: 1.7; color: #333; margin: 0 0 20px; }
#ai-wel-tip .tip-btns { display: flex; gap: 10px; justify-content: flex-end; }
#ai-wel-tip .tip-btns button { padding: 10px 28px; background: linear-gradient(135deg,#667eea,#764ba2); color: #fff; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 12px rgba(102,126,234,.3); }

/* ============ video gallery (PHP .avg parity: single group carousel) ============ */
.avg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; font-size: 13px; }
.avg-toolbar .sep { color: #cbd5e1; }
.avg-lang-badge { background: #eef4ff; color: #1a73e8; border-radius: 999px; padding: 4px 12px; }
.avg-lang-badge.downgraded { background: #fff7ed; color: #c2410c; }
.avg-toolbar button, .avg-toolbar a.tbtn { border: 0; border-radius: 9px; padding: 7px 12px; cursor: pointer; font-size: 13px; text-decoration: none; display: inline-block; }
.avg-next { background: #7c3aed; color: #fff; }
.avg-play { background: var(--brand); color: #fff; }
.avg-fs { background: #475569; color: #fff; }
.avg-mute { background: #e2e8f0; color: #334155; }
.avg-contact { background: linear-gradient(135deg,#38a169,#2f855a); color: #fff; }
.avg-shop { background: linear-gradient(135deg,#3182ce,#1a73e8); color: #fff; margin-inline-start: auto; }
.avg-title { font-size: 24px; color: var(--navy); margin: 6px 0 12px; }
.avg-stage { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.avg-video-wrap { position: relative; aspect-ratio: 9/16; width: min(420px,58vh); background: #000; border-radius: 12px; overflow: hidden; flex-shrink: 0; }
.avg-video-wrap video { width: 100%; height: 100%; object-fit: contain; }
.avg-video-wrap .avg-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.avg-video-wrap .avg-overlay .pbtn { width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,.92); color: #1a73e8; font-size: 28px; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.avg-video-wrap.avg-fullscreen { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
.avg-unmute-hint { position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.65); color: #fff; border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; animation: hintPulse 1.6s infinite; }
@keyframes hintPulse { 0%,100% { opacity: .75; } 50% { opacity: 1; } }
.avg-text { flex: 1; min-width: 260px; white-space: pre-wrap; color: #334155; font-size: 14px; line-height: 1.8; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.avg-dots { text-align: center; margin: 14px 0; }
.avg-dots i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; margin: 0 4px; cursor: pointer; }
.avg-dots i.on { background: #7c3aed; }
#avg-jumpbar { position: fixed; right: 16px; bottom: 16px; background: rgba(15,23,42,.85); color: #fff; border-radius: 12px; padding: 10px 14px; font-size: 13px; display: none; align-items: center; gap: 10px; z-index: 600; }
#avg-jumpbar.show { display: flex; }
#avg-jumpbar button { border: 0; background: #fff; color: #0f172a; border-radius: 8px; padding: 5px 10px; cursor: pointer; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(15,23,42,.92); color: #fff; border-radius: 10px; padding: 10px 16px; font-size: 13px; z-index: 120000; display: none; }

@media (max-width: 760px) {
  #ai-nav-panel { display: none; }        /* PHP: no float panel on mobile */
  #wel-win, #wel-overlay { display: none !important; }  /* PHP: no welcome window on mobile */
  .avg-video-wrap { width: 100%; max-width: 360px; margin: 0 auto; }
  .avg-title { display: none; }
}

/* ============ chat page product binding bar ============ */
.chat-prodbar { margin-top: 14px; padding: 10px 14px; background: #eef4ff; border: 1px solid #c7dcff; border-radius: 10px; font-size: 14px; }
.chat-prodbar .pcat { color: #64748b; }
.chat-noprod { margin-top: 14px; padding: 10px 14px; background: #fff7e6; border: 1px solid #f0d9a8; border-radius: 10px; font-size: 14px; }
.chatpage.locked .inbar input, .chatpage.locked .inbar .btn { opacity: .5; cursor: not-allowed; }
.chat-lockbar { padding: 8px 12px; color: #b45309; font-size: 13px; border-top: 1px dashed #e2e8f0; }
