/* VNC AI — dùng biến màu của theme VNControl nếu có, có giá trị dự phòng cho theme khác. */
.vncai-q, .vncai-sg, .vncai-chat {
  --a-brand: var(--vnc-brand, #2E3192); --a-brand-h: var(--vnc-brand-h, #25287C); --a-brand-50: var(--vnc-brand-50, #EEF0FB);
  --a-ink: var(--vnc-ink, #111428); --a-ink-3: var(--vnc-ink-3, #5F6584);
  --a-line: var(--vnc-line, #E2E5EE); --a-line-2: var(--vnc-line-2, #CBD0DF);
  --a-surface: var(--vnc-surface, #fff); --a-surface-2: var(--vnc-surface-2, #F6F7FB);
  --a-price: var(--vnc-price, #C81E1E); --a-r: var(--vnc-r, 10px); --a-r-sm: var(--vnc-r-sm, 6px); --a-tap: var(--vnc-tap, 44px);
  --a-ok: var(--vnc-ok, #0E7234); --a-ok-bg: var(--vnc-ok-bg, #EAF7EF);
  --a-warn: var(--vnc-warn, #9A5B00); --a-warn-bg: var(--vnc-warn-bg, #FFF6E5);
  --a-bad: var(--vnc-bad, #C42B1C); --a-bad-bg: var(--vnc-bad-bg, #FEF1F0);
  color: var(--a-ink);
}
.vncai-q { background: var(--a-surface); border: 1px solid var(--a-line); border-radius: var(--a-r); padding: 20px; margin: 24px 0; }
.vncai-q__title { margin: 0 0 6px; font-size: 1.25rem; line-height: 1.3; }
.vncai-q__intro { margin: 0 0 16px; color: var(--a-ink-3); }
.vncai-q__form { display: grid; gap: 10px; }
.vncai-q__drop { position: relative; display: grid; gap: 4px; justify-items: center; text-align: center; padding: 22px 16px; border: 2px dashed var(--a-line-2); border-radius: var(--a-r); background: var(--a-surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.vncai-q__drop:hover, .vncai-q__drop.is-over, .vncai-q__drop:focus-within { border-color: var(--a-brand); background: var(--a-brand-50); }
.vncai-q__drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.vncai-q__drop-t { font-weight: 600; }
.vncai-q__drop-s { font-size: .85rem; color: var(--a-ink-3); }
.vncai-q__file { font-size: .9rem; font-weight: 600; color: var(--a-brand); word-break: break-all; }
.vncai-q__lbl { font-weight: 600; font-size: .95rem; margin-top: 4px; }
.vncai-q textarea { width: 100%; box-sizing: border-box; min-height: 120px; padding: 10px 12px; border: 1px solid var(--a-line-2); border-radius: var(--a-r-sm); font: inherit; font-family: var(--vnc-mono, ui-monospace, Menlo, Consolas, monospace); font-size: .9rem; resize: vertical; }
.vncai-q textarea:focus { outline: 2px solid var(--a-brand); outline-offset: 1px; border-color: var(--a-brand); }
.vncai-q__hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.vncai-q__privacy { margin: 0; font-size: .82rem; color: var(--a-ink-3); }
.vncai-q__status { margin-top: 10px; min-height: 1.4em; font-weight: 500; }
.vncai-q.is-busy .vncai-q__status::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid var(--a-line-2); border-top-color: var(--a-brand); border-radius: 50%; animation: vncai-spin .8s linear infinite; }
@keyframes vncai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .vncai-q.is-busy .vncai-q__status::before { animation: none; } }

.vncai-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--a-tap); padding: 0 18px; border: 1px solid var(--a-line-2); border-radius: var(--a-r-sm); background: var(--a-surface); color: var(--a-ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.vncai-btn:hover { border-color: var(--a-brand); color: var(--a-brand); }
.vncai-btn--primary { background: var(--a-brand); border-color: var(--a-brand); color: #fff; }
.vncai-btn--primary:hover { background: var(--a-brand-h); color: #fff; }
.vncai-btn[disabled] { opacity: .55; cursor: not-allowed; }
.vncai-btn--sm { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.vncai-btn.is-in { border-color: var(--a-ok); color: var(--a-ok); }

.vncai-q__out { margin-top: 16px; }
.vncai-sum { font-size: 1rem; margin-bottom: 6px; }
.vncai-note { margin: 4px 0; font-size: .88rem; color: var(--a-ink-3); }
.vncai-empty { color: var(--a-ink-3); }
.vncai-tw { overflow-x: auto; margin: 10px 0; border: 1px solid var(--a-line); border-radius: var(--a-r-sm); }
.vncai-t { width: 100%; border-collapse: collapse; font-size: .92rem; }
.vncai-t th, .vncai-t td { padding: 10px; border-bottom: 1px solid var(--a-line); text-align: left; vertical-align: top; }
.vncai-t thead th { background: var(--a-surface-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; color: var(--a-ink-3); white-space: nowrap; }
.vncai-t tbody tr:last-child > * { border-bottom: 0; }
.vncai-t tbody th { font-family: var(--vnc-mono, ui-monospace, Menlo, monospace); font-weight: 600; overflow-wrap: anywhere; min-width: 120px; }
.vncai-t small { display: block; font-family: var(--vnc-font, inherit); font-weight: 400; font-size: .8rem; color: var(--a-ink-3); }
.vncai-t input[type=checkbox] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--a-brand); }
.vncai-qty { width: 72px; min-height: 36px; padding: 4px 6px; border: 1px solid var(--a-line-2); border-radius: var(--a-r-sm); font: inherit; }
.vncai-pick { display: block; width: 100%; max-width: 360px; min-height: 36px; margin-bottom: 6px; border: 1px solid var(--a-line-2); border-radius: var(--a-r-sm); font: inherit; font-size: .85rem; }
.vncai-prod { display: flex; gap: 8px; align-items: flex-start; min-width: 200px; }
.vncai-prod img { width: 40px; height: 40px; object-fit: contain; border: 1px solid var(--a-line); border-radius: 4px; background: #fff; flex: none; }
.vncai-prod a { font-weight: 600; color: var(--a-brand); text-decoration: none; overflow-wrap: anywhere; }
.vncai-prod a:hover { text-decoration: underline; }
.vncai-price { display: block; font-weight: 700; color: var(--a-price); }
.vncai-price--ask { font-weight: 600; color: var(--a-ink-3); }
.vncai-muted { color: var(--a-ink-3); font-size: .88rem; }
.vncai-badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.vncai-badge--ok { background: var(--a-ok-bg); color: var(--a-ok); }
.vncai-badge--warn { background: var(--a-warn-bg); color: var(--a-warn); }
.vncai-badge--info { background: var(--a-brand-50); color: var(--a-brand); }
.vncai-badge--none { background: var(--a-surface-2); color: var(--a-ink-3); }
.vncai-t tr.is-fuzzy { background: color-mix(in srgb, var(--a-warn-bg) 50%, transparent); }
.vncai-acts { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 640px) {
  .vncai-q { padding: 16px; margin-left: 0; margin-right: 0; }
  .vncai-t thead { display: none; }
  .vncai-t, .vncai-t tbody, .vncai-t tr { display: block; }
  .vncai-t tr { display: grid; grid-template-columns: 28px 1fr auto; gap: 6px 10px; padding: 12px; border-bottom: 1px solid var(--a-line); }
  .vncai-t th, .vncai-t td { padding: 0; border: 0; }
  .vncai-t tr > :nth-child(1) { grid-row: 1; grid-column: 1; }
  .vncai-t tr > :nth-child(2) { grid-row: 1; grid-column: 2; min-width: 0; }
  .vncai-t tr > :nth-child(3) { grid-row: 1; grid-column: 3; }
  .vncai-t tr > :nth-child(4) { grid-row: 2; grid-column: 2 / 4; }
  .vncai-t tr > :nth-child(5) { grid-row: 3; grid-column: 2 / 4; }
  .vncai-prod { min-width: 0; }
  .vncai-acts .vncai-btn { flex: 1 1 100%; }
}

/* Gợi ý khi tìm không có kết quả */
.vncai-sg { margin: 24px 0; }
.vncai-sg__title { margin: 0 0 4px; font-size: 1.15rem; }
.vncai-sg__note { margin: 0 0 12px; font-size: .88rem; color: var(--a-ink-3); }
.vncai-sg__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.vncai-card { display: flex; gap: 10px; padding: 12px; background: var(--a-surface); border: 1px solid var(--a-line); border-radius: var(--a-r); }
.vncai-card__img { flex: none; width: 72px; height: 72px; display: grid; place-items: center; background: #fff; border-radius: var(--a-r-sm); }
.vncai-card__img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.vncai-card__b { display: grid; gap: 4px; align-content: start; min-width: 0; }
.vncai-card__t { color: var(--a-ink); font-weight: 600; font-size: .9rem; line-height: 1.35; text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vncai-card__t:hover { color: var(--a-brand); }
.vncai-card__sku { font-family: var(--vnc-mono, ui-monospace, Menlo, monospace); font-size: .8rem; color: var(--a-ink-3); overflow-wrap: anywhere; }
.vncai-card .vncai-btn { justify-self: start; margin-top: 4px; }

/* Sản phẩm gần giống (trang sản phẩm) */
.vncai-alt__note { margin: -4px 0 12px; font-size: .88rem; color: var(--vnc-ink-3, #5F6584); }


/* Trợ lý tư vấn (chat) */
.vncai-chat { position: fixed; right: 16px; bottom: calc(var(--vnc-bnav-h, 0px) + 16px + env(safe-area-inset-bottom)); z-index: 70; font-size: 15px; line-height: 1.45; }
.vncai-chat.is-open { z-index: 90; }
.vncai-chat svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.vncai-vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.vncai-chat__fab { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 20px 0 16px; border: 0; border-radius: 999px; background: var(--a-brand); color: #fff; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 6px 20px rgba(17, 20, 40, .22); transition: background .15s, transform .15s; }
.vncai-chat__fab:hover { background: var(--a-brand-h); }
.vncai-chat__fab:focus-visible, .vncai-chat__ib:focus-visible, .vncai-chat__send:focus-visible, .vncai-chat__chip:focus-visible { outline: 3px solid var(--a-brand); outline-offset: 2px; }
.vncai-chat__fab:focus-visible { outline-color: var(--a-ink); }
.vncai-chat.is-open .vncai-chat__fab { display: none; }
.vncai-chat__panel { position: fixed; right: 16px; bottom: calc(var(--vnc-bnav-h, 0px) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; width: min(400px, calc(100vw - 32px)); height: min(640px, calc(100vh - var(--vnc-bnav-h, 0px) - 32px)); height: min(640px, calc(100dvh - var(--vnc-bnav-h, 0px) - 32px - env(safe-area-inset-bottom))); background: var(--a-surface); border: 1px solid var(--a-line); border-radius: 14px; box-shadow: 0 16px 48px rgba(17, 20, 40, .22); overflow: hidden; }
.vncai-chat__panel[hidden] { display: none; }
.vncai-chat__hd { display: flex; align-items: center; gap: 4px; padding: 10px 8px 10px 16px; background: var(--a-brand); color: #fff; }
.vncai-chat__hd-t { flex: 1; min-width: 0; }
.vncai-chat__t { margin: 0; font-size: 1rem; line-height: 1.3; color: #fff; }
.vncai-chat__sub { margin: 0; font-size: .78rem; opacity: .85; }
.vncai-chat__ib { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: #fff; cursor: pointer; }
.vncai-chat__ib:hover { background: rgba(255, 255, 255, .15); }
.vncai-chat__hd .vncai-chat__ib:focus-visible { outline-color: #fff; outline-offset: -3px; }
.vncai-chat__log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 12px; background: var(--a-surface-2); display: flex; flex-direction: column; gap: 10px; }
.vncai-chat__log:focus { outline: none; }
.vncai-chat__m { display: flex; flex-direction: column; gap: 8px; max-width: 92%; }
.vncai-chat__m--u { align-self: flex-end; align-items: flex-end; }
.vncai-chat__m--a { align-self: flex-start; }
.vncai-chat__b { padding: 9px 12px; border-radius: 14px; overflow-wrap: anywhere; }
.vncai-chat__m--a .vncai-chat__b { background: var(--a-surface); border: 1px solid var(--a-line); border-top-left-radius: 4px; color: var(--a-ink); }
.vncai-chat__m--u .vncai-chat__b { background: var(--a-brand); color: #fff; border-top-right-radius: 4px; }
.vncai-chat__m.is-err .vncai-chat__b { background: var(--a-bad-bg); border-color: transparent; color: var(--a-bad); }
.vncai-chat__items { display: grid; gap: 8px; width: 100%; }
.vncai-chat__items .vncai-card { padding: 10px; gap: 10px; }
.vncai-chat__items .vncai-card__img { width: 56px; height: 56px; }
.vncai-chat__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.vncai-chat__chip { min-height: 36px; padding: 6px 12px; border: 1px solid var(--a-brand); border-radius: 999px; background: var(--a-surface); color: var(--a-brand); font: inherit; font-size: .88rem; text-align: left; cursor: pointer; }
.vncai-chat__chip:hover { background: var(--a-brand-50); }
.vncai-chat__dots { display: inline-flex; gap: 4px; padding: 13px 14px; }
.vncai-chat__dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--a-ink-3); animation: vncai-dot 1s infinite ease-in-out; }
.vncai-chat__dots i:nth-child(2) { animation-delay: .15s; }
.vncai-chat__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes vncai-dot { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.vncai-chat__f { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--a-line); background: var(--a-surface); }
.vncai-chat__f textarea { flex: 1; min-height: 44px; max-height: 120px; padding: 10px 12px; border: 1px solid var(--a-line-2); border-radius: 10px; font: inherit; font-size: 16px; line-height: 1.4; resize: none; box-sizing: border-box; color: var(--a-ink); background: var(--a-surface); }
.vncai-chat__f textarea:focus { outline: 2px solid var(--a-brand); outline-offset: 0; border-color: var(--a-brand); }
.vncai-chat__send { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: 10px; background: var(--a-brand); color: #fff; cursor: pointer; }
.vncai-chat__send:hover { background: var(--a-brand-h); }
.vncai-chat__send[disabled] { opacity: .5; cursor: progress; }
.vncai-chat__ft { padding: 8px 12px 10px; font-size: .76rem; color: var(--a-ink-3); background: var(--a-surface); }
.vncai-chat__ft p { margin: 0; }
.vncai-chat__ct { display: flex; gap: 16px; margin-top: 4px !important; }
.vncai-chat__ct a { font-weight: 700; font-size: .85rem; color: var(--a-brand); text-decoration: none; }
.vncai-chat__ct a:hover { text-decoration: underline; }
/* Trang tư vấn [vnc_ai_chat]: khung đặt trong nội dung trang. Bộ chọn hai lớp để thắng kiểu nội dung bài viết của theme (.vnc-prose a, p…). */
.vncai-cp__intro { margin: 16px 0 0; color: var(--vnc-ink-3, #5F6584); }
.vncai-cp__off { margin: 0; padding: 14px 16px; border: 1px solid var(--vnc-line, #E2E5EE); border-radius: var(--vnc-r, 10px); background: var(--vnc-surface-2, #F6F7FB); }
.vncai-chat.vncai-chat--page { position: static; z-index: auto; margin: 0 0 8px; }
/* Giữ chỗ bằng chiều cao khung trước khi JS chạy để trang không nhảy (CLS). */
.vncai-chat.vncai-chat--page:not(.is-off) { min-height: clamp(440px, calc(100vh - 290px), 760px); min-height: clamp(440px, calc(100dvh - 290px), 760px); }
.vncai-chat--page .vncai-chat__panel { position: relative; inset: auto; width: 100%; height: clamp(440px, calc(100vh - 290px), 760px); height: clamp(440px, calc(100dvh - 290px), 760px); scroll-margin: 12px 0 calc(var(--vnc-bnav-h, 0px) + 12px); border: 1px solid var(--a-line); border-radius: var(--a-r); box-shadow: none; padding: 0; }
.vncai-chat--page .vncai-chat__hd { gap: 8px; padding: 6px 6px 6px 14px; background: var(--a-brand-50); color: var(--a-ink); border-bottom: 1px solid var(--a-line); }
.vncai-chat.vncai-chat--page .vncai-chat__sub { flex: 1; display: flex; align-items: center; gap: 8px; margin: 0; font-size: .85rem; opacity: 1; color: var(--a-ink-3); }
.vncai-chat--page .vncai-chat__sub svg { color: var(--a-brand); }
.vncai-chat--page .vncai-chat__ib { display: inline-flex; align-items: center; width: auto; gap: 6px; padding: 0 12px; color: var(--a-brand); font: inherit; font-size: .85rem; font-weight: 600; }
.vncai-chat--page .vncai-chat__ib:hover { background: var(--a-surface); }
.vncai-chat--page .vncai-chat__hd .vncai-chat__ib:focus-visible { outline-color: var(--a-brand); }
.vncai-chat--page .vncai-chat__log { padding: 18px 16px; gap: 14px; }
.vncai-chat--page .vncai-chat__m { max-width: min(760px, 88%); }
.vncai-chat--page .vncai-chat__items { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.vncai-chat--page .vncai-chat__chips { max-width: 760px; }
.vncai-chat--page .vncai-chat__f { padding: 12px 14px; }
.vncai-chat.vncai-chat--page a { text-decoration: none; }
.vncai-chat.vncai-chat--page .vncai-chat__ct a:hover { text-decoration: underline; }
.vncai-chat.vncai-chat--page p { margin: 0; }
.vncai-chat.vncai-chat--page .vncai-chat__ct { margin-top: 4px; }
@media (max-width: 767.98px) {
  .vncai-chat--page .vncai-chat__panel { height: clamp(400px, calc(100vh - var(--vnc-bnav-h, 0px) - 24px), 720px); height: clamp(400px, calc(100dvh - var(--vnc-bnav-h, 0px) - 24px), 720px); }
  .vncai-chat.vncai-chat--page:not(.is-off) { min-height: clamp(400px, calc(100vh - var(--vnc-bnav-h, 0px) - 24px), 720px); min-height: clamp(400px, calc(100dvh - var(--vnc-bnav-h, 0px) - 24px), 720px); }
  .vncai-chat--page .vncai-chat__hd { padding-top: 6px; }
  .vncai-chat--page .vncai-chat__ib span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .vncai-chat--page .vncai-chat__ib { width: 40px; padding: 0; justify-content: center; }
  .vncai-chat--page .vncai-chat__log { padding: 14px 10px; }
  .vncai-chat--page .vncai-chat__m { max-width: 94%; }
  .vncai-chat--page .vncai-chat__items { grid-template-columns: 1fr; }
}

/* Tránh đè thanh so sánh và thanh mua hàng của theme */
body:has(.vnc-cmpbar:not([hidden])) .vncai-chat:not(.is-open) { bottom: calc(var(--vnc-bnav-h, 0px) + 72px + env(safe-area-inset-bottom)); }
@media (max-width: 1023.98px) {
  body.vnc-has-sbar .vncai-chat:not(.is-open) { bottom: calc(var(--vnc-bnav-h, 0px) + 92px + env(safe-area-inset-bottom)); }
  body.vnc-has-sbar:has(.vnc-cmpbar:not([hidden])) .vncai-chat:not(.is-open) { bottom: calc(var(--vnc-bnav-h, 0px) + 148px + env(safe-area-inset-bottom)); }
}
@media (max-width: 767.98px) {
  .vncai-chat__fab { width: 52px; height: 52px; min-height: 0; padding: 0; justify-content: center; }
  .vncai-chat__fab svg { width: 24px; height: 24px; }
  .vncai-chat__fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .vncai-chat__panel { inset: 0; width: auto; height: auto; border: 0; border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
  .vncai-chat__hd { padding-top: calc(10px + env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) { .vncai-chat__dots i { animation: none; opacity: .6; } .vncai-chat__fab { transition: none; } }
@media print { .vncai-chat { display: none !important; } }
