/* ==========================================================================
   Velamart Article Commerce — trang chi tiết bài viết (/tin-tuc/{slug})
   Dùng token của main.css (:root). Chỉ tải ở app/Views/blog/detail.php.
   ========================================================================== */

/* Màu Velamart cố định trong scope bài viết — KHÔNG dùng --brand-primary/--button-*
   vì Cấu hình giao diện có thể override (hiện đang là vàng/tím) → link/nút navy ổn định. */
.vla-article {
  --vla-navy: #163a99; --vla-blue: #1c48c1; --vla-tint: #eef4ff; --vla-heading: #0f172a;
}
.vla-article { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; box-sizing: border-box; }
.vla-article *, .vla-article *::before, .vla-article *::after { box-sizing: border-box; }

.vla-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
.vla-layout--single { grid-template-columns: minmax(0, 1fr); max-width: 820px; margin: 0 auto; }
.vla-main { min-width: 0; }
.vla-sidebar { min-width: 0; align-self: stretch; } /* cao bằng cột nội dung để .vla-sidebar-inner sticky được */

/* ── Header ─────────────────────────────────────────────────────────────── */
.vla-header { margin: 12px 0 28px; }
.vla-title { font-size: 30px; font-weight: 700; line-height: 1.35; margin: 0 0 8px; color: var(--text-heading, #0f172a); }
.vla-lead {
  font-size: 16px; color: var(--text-mid, #475569); line-height: 1.7; margin: 16px 0 0;
  border-left: 3px solid var(--vla-blue); padding-left: 16px;
}

/* ── Nội dung ───────────────────────────────────────────────────────────── */
.vla-content { font-size: 16px; line-height: 1.85; color: var(--text-body, #1e293b); overflow-wrap: break-word; }
.vla-content > :first-child { margin-top: 0; }
.vla-content :where(p) { margin: 0 0 18px; }
.vla-content h2, .vla-content h3 { color: var(--text-heading, #0f172a); line-height: 1.4; scroll-margin-top: 130px; }
.vla-content h2 { font-size: 23px; font-weight: 700; margin: 40px 0 14px; }
.vla-content h3 { font-size: 19px; font-weight: 700; margin: 28px 0 10px; }
.vla-content :where(ul, ol) { margin: 0 0 18px; padding-left: 22px; }
.vla-content :where(li) { margin-bottom: 6px; }
.vla-content img, .vla-content video { max-width: 100%; height: auto; }
.vla-content iframe, .vla-content embed { max-width: 100%; }
.vla-content figure { margin: 24px 0; max-width: 100%; }
.vla-content figcaption { font-size: 13px; color: var(--text-muted, #64748b); text-align: center; margin-top: 6px; }
.vla-content pre { overflow-x: auto; max-width: 100%; }
.vla-content blockquote {
  margin: 24px 0; padding: 14px 18px; background: var(--surface-light, #eff6ff);
  border-left: 3px solid var(--vla-blue); border-radius: 0 8px 8px 0;
}

/* Bảng: cuộn ngang trong khung, không làm tràn trang */
.vla-table-wrap {
  max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 22px 0; border: 1px solid var(--border-soft, #e2e8f0); border-radius: 8px;
}
.vla-table-wrap table { width: 100%; border-collapse: collapse; margin: 0; font-size: 14.5px; line-height: 1.6; }
.vla-table-wrap th, .vla-table-wrap td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-light, #f1f5f9); text-align: left; vertical-align: top;
}
.vla-table-wrap th { background: var(--surface-light, #eff6ff); color: var(--text-heading, #0f172a); font-weight: 600; }
.vla-table-wrap tr:last-child td { border-bottom: 0; }

/* Internal link trong bài — nổi bật hơn chữ thường nhưng vẫn là text link.
   Không áp cho link bên trong Product Block / Product Section. */
.vla-content a:where(:not(.vla-pblock a, .vla-psection a)) {
  color: var(--vla-navy); font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 1px;
  text-decoration-color: rgba(22, 58, 153, .35); text-underline-offset: 3px;
  border-radius: 3px; padding: 0 1px;
  transition: background-color .15s ease, color .15s ease, text-decoration-color .15s ease;
}
.vla-content a:where(:not(.vla-pblock a, .vla-psection a)):hover {
  background-color: var(--vla-tint); color: var(--vla-blue);
  text-decoration-color: currentColor;
}
.vla-content a:where(:not(.vla-pblock a, .vla-psection a)):focus-visible {
  outline: 2px solid var(--vla-blue); outline-offset: 2px;
  background-color: var(--vla-tint);
}
.vla-content a:has(img) { text-decoration: none; background: none; padding: 0; }

/* ── Nút ────────────────────────────────────────────────────────────────── */
.vla-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: 0 18px; border-radius: 8px; font-size: 14px; font-weight: 600; line-height: 1.2;
  text-decoration: none; border: 1px solid transparent; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.vla-btn--primary { background: var(--vla-blue); color: #fff; }
.vla-btn--primary:hover { background: var(--vla-navy); color: #fff; }
.vla-btn--ghost { background: #fff; color: var(--vla-blue); border-color: var(--vla-blue); }
.vla-btn--ghost:hover { background: var(--vla-tint); color: var(--vla-navy); }
.vla-btn:focus-visible { outline: 2px solid var(--vla-blue); outline-offset: 2px; }

/* ── Product Block trong bài (product_card variant "article") ──────────── */
.vla-pblock {
  display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 20px; align-items: start;
  margin: 30px 0; padding: 18px; background: #f8faff;
  border: 1px solid #dbe4f7; border-radius: 12px;
}
.vla-pblock-media { display: block; border-radius: 8px; overflow: hidden; background: #fff; }
.vla-pblock-media img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: contain; }
.vla-pblock-noimg { display: block; aspect-ratio: 1 / 1; background: var(--surface-soft, #f1f5f9); }
.vla-pblock-body { min-width: 0; }
.vla-pblock-eyebrow {
  margin: 0 0 4px; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-muted, #64748b);
}
.vla-pblock-name { margin: 0 0 6px; font-size: 17px; font-weight: 700; line-height: 1.4; }
.vla-pblock-name a { color: var(--text-heading, #0f172a); text-decoration: none; }
.vla-pblock-name a:hover { color: var(--vla-blue); }
.vla-pblock-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin: 0 0 8px; }
.vla-pblock-price-now { font-size: 19px; font-weight: 700; color: var(--price-sale, #dc2626); }
.vla-pblock-price-old { font-size: 14px; color: var(--price-orig, #94a3b8); text-decoration: line-through; }
.vla-pblock-disc {
  font-size: 12px; font-weight: 700; color: #fff; background: var(--badge-sale, #dc2626);
  padding: 1px 6px; border-radius: 4px;
}
.vla-pblock-price-contact { font-size: 16px; font-weight: 700; color: var(--vla-blue); }
.vla-pblock-desc { margin: 0 0 8px; font-size: 14px; line-height: 1.6; color: var(--text-mid, #475569); }
.vla-pblock-hl { list-style: none; margin: 0 0 12px; padding: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-body, #1e293b); }
.vla-pblock-hl li { position: relative; padding-left: 16px; margin: 0 0 4px; }
.vla-pblock-hl li::before {
  content: ""; position: absolute; left: 2px; top: .6em; width: 6px; height: 6px;
  border-radius: 50%; background: var(--vla-blue);
}
.vla-pblock-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.vla-sidebar-inner {
  position: sticky; top: 110px; max-height: calc(100vh - 130px); overflow-y: auto;
  overscroll-behavior: contain; display: flex; flex-direction: column; gap: 16px; padding-bottom: 4px;
}
.vla-side-title {
  margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: var(--text-heading, #0f172a);
}
.vla-side-box, .vla-toc--side {
  background: #fff; border: 1px solid var(--border-soft, #e2e8f0); border-radius: 10px; padding: 16px;
}

/* TOC */
.vla-toc-list { list-style: none; margin: 0; padding: 0; }
.vla-toc-list li { margin: 0; }
.vla-toc-list a {
  display: block; padding: 5px 8px; border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
  font-size: 13.5px; line-height: 1.45; color: var(--text-mid, #475569); text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.vla-toc-list a:hover { background: var(--vla-tint); color: var(--vla-navy); }
.vla-toc-list a:focus-visible { outline: 2px solid var(--vla-blue); outline-offset: 1px; }
.vla-toc-list a.is-active {
  color: var(--vla-navy); font-weight: 600;
  border-left-color: var(--vla-blue); background: var(--vla-tint);
}
.vla-toc-l3 a { padding-left: 22px; font-size: 13px; }
.vla-toc--side .vla-toc-list { position: relative; max-height: 42vh; overflow-y: auto; }

.vla-toc--inline {
  margin: 0 0 28px; border: 1px solid var(--border-soft, #e2e8f0); border-radius: 10px; background: #fff;
}
.vla-toc--inline summary {
  cursor: pointer; padding: 12px 16px; font-weight: 700; font-size: 15px; color: var(--text-heading, #0f172a);
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.vla-toc--inline summary::-webkit-details-marker { display: none; }
.vla-toc--inline summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; flex: 0 0 8px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform .2s ease;
}
.vla-toc--inline[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.vla-toc--inline summary:focus-visible { outline: 2px solid var(--vla-blue); outline-offset: -2px; border-radius: 10px; }
.vla-toc-count { font-weight: 500; color: var(--text-muted, #64748b); font-size: 13px; }
.vla-toc--inline nav { padding: 0 10px 12px; }

/* Sản phẩm được nhắc đến (product_card variant "mini") */
.vla-mini {
  display: flex; align-items: center; gap: 10px; padding: 8px; margin: 0 -8px;
  border-radius: 8px; text-decoration: none; color: inherit; transition: background-color .15s ease;
}
.vla-mini:hover { background: var(--vla-tint); }
.vla-mini:focus-visible { outline: 2px solid var(--vla-blue); outline-offset: 1px; }
.vla-mini-img {
  flex: 0 0 56px; width: 56px; height: 56px; border-radius: 6px; overflow: hidden;
  background: var(--surface-soft, #f1f5f9); border: 1px solid var(--border-light, #f1f5f9);
}
.vla-mini-img img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.vla-mini-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vla-mini-name {
  font-size: 13.5px; font-weight: 600; line-height: 1.4; color: var(--text-heading, #0f172a);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vla-mini-price { font-size: 13px; font-weight: 700; color: var(--price-sale, #dc2626); }

/* CTA tư vấn */
.vla-consult { background: var(--surface-light, #eff6ff); border-color: #d6e2fb; }
.vla-consult-title { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--text-heading, #0f172a); }
.vla-consult-text { margin: 0 0 12px; font-size: 13.5px; line-height: 1.55; color: var(--text-mid, #475569); }
.vla-consult-actions { display: flex; flex-direction: column; gap: 8px; }
.vla-consult-actions .vla-btn { width: 100%; }

/* ── Cuối bài ───────────────────────────────────────────────────────────── */
.vla-section-title { font-size: 19px; font-weight: 700; margin: 0 0 18px; color: var(--text-heading, #0f172a); }
.vla-related-products { margin-top: 48px; padding-top: 24px; border-top: 2px solid var(--vla-blue); }
.vla-related-products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.vla-related-products-grid > * { min-width: 0; }
.vla-related-posts { margin-top: 48px; padding-top: 24px; border-top: 2px solid var(--vla-blue); }

/* Desktop: TOC nằm ở sidebar */
@media (min-width: 1024px) {
  .vla-toc--inline { display: none; }
}

/* Tablet / mobile: 1 cột, bỏ sticky sidebar; TOC dạng thu gọn đầu bài;
   sản phẩm đã có ở Product Block + "Sản phẩm liên quan" nên ẩn danh sách mini. */
@media (max-width: 1023px) {
  .vla-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .vla-sidebar-inner { position: static; max-height: none; overflow: visible; }
  .vla-toc--side, .vla-side-products { display: none; }
  .vla-sidebar { margin-top: 32px; }
  .vla-consult-actions { flex-direction: row; flex-wrap: wrap; }
  .vla-consult-actions .vla-btn { width: auto; flex: 1 1 160px; }
}

@media (max-width: 767px) {
  .vla-article { padding: 16px 16px 48px; }
  .vla-title { font-size: 24px; }
  .vla-content { font-size: 15.5px; line-height: 1.8; }
  .vla-content h2 { font-size: 20px; margin-top: 32px; scroll-margin-top: 90px; }
  .vla-content h3 { font-size: 17px; scroll-margin-top: 90px; }
  .vla-related-products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

@media (max-width: 600px) {
  .vla-pblock { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 14px; }
  .vla-pblock-media { max-width: 240px; width: 100%; margin: 0 auto; }
  .vla-pblock-actions .vla-btn { flex: 1 1 140px; }
}

/* ── Product Section giữa bài (2–4 sản phẩm, product_card variant "tile") ─ */
.vla-psection {
  margin: 30px 0; padding: 16px; background: #f8faff;
  border: 1px solid #dbe4f7; border-radius: 12px;
}
.vla-psection .vla-psection-title {
  margin: 0 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--text-muted, #64748b);
}
.vla-psection-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.vla-content .vla-tile, .vla-tile {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 10px;
  background: #fff; border: 1px solid var(--border-soft, #e2e8f0); border-radius: 10px;
  color: inherit; text-decoration: none; font-weight: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.vla-tile:hover { border-color: #b9c9ee; box-shadow: 0 4px 14px rgba(22, 58, 153, .10); }
.vla-tile:focus-visible { outline: 2px solid var(--vla-blue); outline-offset: 2px; }
.vla-tile-img { display: block; aspect-ratio: 1 / 1; border-radius: 6px; overflow: hidden; background: var(--surface-soft, #f1f5f9); }
.vla-tile-img img { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.vla-tile-name {
  font-size: 13.5px; font-weight: 600; line-height: 1.4; color: var(--vla-heading);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em;
}
.vla-tile-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; line-height: 1.3; }
.vla-tile-price-now { font-size: 15px; font-weight: 700; color: var(--price-sale, #dc2626); }
.vla-tile-price-old { font-size: 12px; color: var(--price-orig, #94a3b8); text-decoration: line-through; }
.vla-tile-disc { font-size: 11px; font-weight: 700; color: #fff; background: var(--badge-sale, #dc2626); padding: 0 5px; border-radius: 4px; }
.vla-tile-price-contact { font-size: 14px; font-weight: 700; color: var(--vla-blue); }
.vla-tile-cta {
  margin-top: auto; display: flex; align-items: center; justify-content: center; min-height: 34px;
  border: 1px solid var(--vla-blue); border-radius: 8px; color: var(--vla-blue);
  font-size: 13px; font-weight: 600; transition: background-color .15s ease, color .15s ease;
}
.vla-tile:hover .vla-tile-cta { background: var(--vla-blue); color: #fff; }

/* Sidebar: mở drawer khi có nhiều sản phẩm hơn danh sách rút gọn */
.vla-side-more {
  display: block; width: 100%; margin: 8px 0 0; padding: 8px 10px; border: 1px dashed #b9c9ee;
  border-radius: 8px; background: #fff; color: var(--vla-navy); font-size: 13px; font-weight: 600;
  cursor: pointer; text-align: center; line-height: 1.3; min-height: 0;
  font-family: inherit; text-transform: none; letter-spacing: 0;
}
.vla-side-more:hover { background: var(--vla-tint); }
.vla-side-more:focus-visible { outline: 2px solid var(--vla-blue); outline-offset: 2px; }

/* ── Nút nổi "Sản phẩm có trong bài" (góc TRÁI — chat widget ở góc phải) ── */
.vla-fab {
  --vla-navy: #163a99; --vla-blue: #1c48c1;
  position: fixed; left: 24px; bottom: 28px; z-index: 9000;
  display: inline-flex; align-items: center; gap: 8px; min-height: 46px; margin: 0; padding: 0 16px 0 14px;
  border: 0; border-radius: 999px; background: var(--vla-navy); color: #fff;
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
  letter-spacing: 0; text-transform: none; cursor: pointer;
  box-shadow: 0 8px 24px rgba(13, 27, 53, .28);
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s, background-color .15s ease;
}
.vla-fab.is-visible { opacity: 1; visibility: visible; transform: none; transition: opacity .2s ease, transform .2s ease, visibility 0s, background-color .15s ease; }
.vla-fab:hover { background: var(--vla-blue); }
.vla-fab:focus-visible { outline: 3px solid #ffcc32; outline-offset: 2px; }
.vla-fab svg { width: 18px; height: 18px; flex: 0 0 18px; }
.vla-fab-short { display: none; }
.vla-fab-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #fff; color: var(--vla-navy);
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}

/* ── Drawer (desktop: trượt từ trái 400px; mobile: bottom sheet) ─────────── */
.vla-drawer {
  --vla-navy: #163a99; --vla-blue: #1c48c1; --vla-tint: #eef4ff; --vla-heading: #0f172a;
  position: fixed; inset: 0; z-index: 99980; /* dưới chat widget (99990) → không che chat */
}
.vla-drawer[hidden] { display: none; }
.vla-drawer *, .vla-drawer *::before, .vla-drawer *::after { box-sizing: border-box; }
.vla-drawer-backdrop { position: absolute; inset: 0; background: rgba(8, 17, 31, .5); opacity: 0; transition: opacity .25s ease; }
.vla-drawer-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: 400px; max-width: calc(100vw - 48px);
  display: flex; flex-direction: column; background: #fff; box-shadow: 8px 0 32px rgba(13, 27, 53, .22);
  transform: translateX(-100%); transition: transform .25s ease; outline: none;
}
.vla-drawer.is-open .vla-drawer-backdrop { opacity: 1; }
.vla-drawer.is-open .vla-drawer-panel { transform: none; }
.vla-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft, #e2e8f0);
}
.vla-drawer-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--vla-heading); }
.vla-drawer-title span { font-weight: 500; color: var(--text-muted, #64748b); }
.vla-drawer-close {
  flex: 0 0 40px; width: 40px; height: 40px; margin: 0; padding: 0; border: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--vla-heading); cursor: pointer; min-height: 0;
}
.vla-drawer-close:hover { background: var(--vla-tint); }
.vla-drawer-close:focus-visible { outline: 2px solid var(--vla-blue); outline-offset: 1px; }
.vla-drawer-close svg { width: 20px; height: 20px; }
.vla-drawer-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px; }
.vla-drawer-body .vla-mini { margin: 0 -8px; }
.vla-drawer-body .vla-mini + .vla-mini { border-top: 1px solid var(--border-light, #f1f5f9); }
.vla-drawer-foot {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft, #e2e8f0);
}
.vla-drawer-foot .vla-btn { flex: 1 1 150px; }

@media (prefers-reduced-motion: reduce) {
  .vla-fab, .vla-drawer-panel, .vla-drawer-backdrop { transition: none; }
}

@media (max-width: 1023px) {
  .vla-psection-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .vla-psection { padding: 12px; }
  .vla-psection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  /* Nút nổi gọn để không đè hint "Cần hỗ trợ?" của chat (góc phải) */
  .vla-fab { left: 12px; bottom: 20px; min-height: 44px; padding: 0 12px; font-size: 13px; }
  .vla-fab-label { display: none; }
  .vla-fab-short { display: inline; }
  .vla-drawer-panel {
    top: auto; right: 0; width: 100%; max-width: none; max-height: 86vh; max-height: 86dvh;
    border-radius: 16px 16px 0 0; transform: translateY(100%); box-shadow: 0 -8px 32px rgba(13, 27, 53, .22);
  }
  /* chừa chỗ nút chat (góc phải dưới, z cao hơn drawer) */
  .vla-drawer-foot { padding-right: 84px; }
}
