/* TTN – trình bày lại trang chủ + hiệu ứng động. Tắt plugin là về giao diện cũ. */
:root {
  --ttn-xanh: #1e7bc9;
  --ttn-xanh-nhat: #eaf3fc;
  --ttn-cam: #f54e23;
  --ttn-chu: #1d2733;
  --ttn-phu: #6b7685;
  --ttn-vien: #e4e9f0;
  --ttn-em: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Banner: khung theo đúng tỉ lệ ảnh (2500x630) ----------
   Flickity đo chiều cao lúc ảnh còn là placeholder lazy-load nên trên điện thoại
   để lại khoảng trống ~100px dưới banner. */
.ss-banner .flickity-viewport { height: auto !important; aspect-ratio: 2500 / 630; }

/* ---------- Tiêu đề khối ---------- */
.title-ct { margin-bottom: 28px; }
.title-ct h2 { letter-spacing: .01em; color: var(--ttn-chu); }
.title-ct h2::after {
  content: "";
  position: absolute;
  left: 40px;
  bottom: -10px;
  width: 56px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--ttn-xanh), var(--ttn-cam));
  transform-origin: left center;
  transition: transform .8s var(--ttn-em) .15s;
}
.ttn-js .title-ct.ttn-rv:not(.ttn-in) h2::after { transform: scaleX(0); }
.title-ct .list-pr ul li:last-child a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 18px;
  white-space: nowrap;
  box-shadow: 0 6px 16px -8px rgba(245, 78, 35, .7);
}
@media (max-width: 549px) {
  .title-ct .list-pr ul li:last-child a { padding: 6px 14px; font-size: 13px; }
}
.title-ct .list-pr ul li:last-child a::after {
  content: "→";
  transition: transform .3s var(--ttn-em);
}
.title-ct .list-pr ul li:last-child a:hover::after { transform: translateX(4px); }

/* Các mục cạnh tiêu đề khối là link tới danh mục: rê chuột thì đổi màu + gạch chân chạy ra */
.title-ct .list-pr ul li:not(:last-child) a {
  color: var(--ttn-chu);
  background: linear-gradient(var(--ttn-cam), var(--ttn-cam)) left bottom / 0 2px no-repeat;
  padding-bottom: 2px;
  transition: color .25s, background-size .35s var(--ttn-em);
}
.title-ct .list-pr ul li:not(:last-child) a:hover { color: var(--ttn-cam); background-size: 100% 2px; }

/* ---------- Lưới danh mục ---------- */
/* flex thay grid để hàng cuối thiếu ô được canh giữa, không còn một ô đứng lẻ bên trái */
.product-categories-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.product-categories-grid .single-category { flex: 0 0 calc((100% - 5 * 16px) / 6); box-sizing: border-box; }
@media (min-width: 1100px) {
  .product-categories-grid .single-category { flex-basis: calc((100% - 6 * 16px) / 7); }
}
@media (min-width: 550px) and (max-width: 849px) {
  .product-categories-grid .single-category { flex-basis: calc((100% - 3 * 16px) / 4); }
}
.product-categories-grid .single-category {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--ttn-vien);
  border-radius: 16px;
  padding: 18px 10px 16px;
  box-shadow: 0 1px 2px rgba(16, 40, 80, .04);
  transition: transform .35s var(--ttn-em), box-shadow .35s var(--ttn-em), border-color .35s;
}
.product-categories-grid .single-category::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ttn-xanh), var(--ttn-cam));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .4s var(--ttn-em);
}
.product-categories-grid .single-category a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  height: 100%;
}
.product-categories-grid .single-category a img,
.product-categories-grid .single-category a:not(:has(img))::before {
  width: 92px;
  height: 92px;
  margin: 0;
  padding: 10px;
  border-radius: 50%;
  object-fit: contain;
  background: radial-gradient(circle at 50% 40%, #fff 0, var(--ttn-xanh-nhat) 70%);
  transition: transform .45s var(--ttn-em);
}
/* Danh mục chưa có ảnh: vẽ biểu tượng máy in thay cho ô trống */
.product-categories-grid .single-category a:not(:has(img))::before {
  content: "";
  box-sizing: border-box;
  display: block;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e7bc9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9V3h12v6'/%3E%3Crect x='3' y='9' width='18' height='8' rx='2'/%3E%3Cpath d='M6 14h12v7H6z'/%3E%3Ccircle cx='17.5' cy='12' r='.6' fill='%23f54e23'/%3E%3C/svg%3E") center / 46% no-repeat,
    radial-gradient(circle at 50% 40%, #fff 0, var(--ttn-xanh-nhat) 70%);
}
.product-categories-grid .single-category a h3 {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6em;
  font-size: 14.5px;
  line-height: 1.3;
  color: var(--ttn-chu);
  transition: color .3s;
}
@media (hover: hover) {
  .product-categories-grid .single-category:hover {
    transform: translateY(-6px);
    border-color: transparent;
    box-shadow: 0 16px 32px -14px rgba(30, 123, 201, .45);
  }
  .product-categories-grid .single-category:hover::after { transform: scaleX(1); }
  .product-categories-grid .single-category:hover a img,
  .product-categories-grid .single-category:hover a:not(:has(img))::before { transform: scale(1.08) rotate(-4deg); }
  .product-categories-grid .single-category:hover a h3 { color: var(--ttn-cam); }
}

/* Điện thoại: dải hai hàng vuốt ngang, đỡ cuộn dọc và các ô luôn đều nhau */
@media (max-width: 549px) {
  .ss-cat .col-inner { min-width: 0; }
  .product-categories-grid {
    display: grid;
    /* KHÔNG để center: dải tràn khung sẽ lòi ra cả bên trái, phần đó không cuộn tới được */
    justify-content: start;
    grid-template-columns: none;
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - 20px) / 3.3);
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    padding: 4px 2px 10px;
    margin: 0 -2px;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
            mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .product-categories-grid::-webkit-scrollbar { display: none; }
  .product-categories-grid .single-category {
    flex: none;
    scroll-snap-align: start;
    padding: 12px 6px 10px;
    border-radius: 14px;
  }
  .product-categories-grid .single-category a { gap: 8px; }
  .product-categories-grid .single-category a img,
  .product-categories-grid .single-category a:not(:has(img))::before { width: 62px; height: 62px; padding: 6px; }
  .product-categories-grid .single-category a h3 { font-size: 12.5px; }
}

/* ---------- Thẻ sản phẩm ---------- */
.products-grid-ct { gap: 22px; }
.item-product {
  position: relative;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(16, 40, 80, .06), 0 8px 22px -14px rgba(16, 40, 80, .25);
  transition: transform .35s var(--ttn-em), box-shadow .35s var(--ttn-em);
}
.item-product > a { display: block; height: 100%; }
.item-product .box-img { position: relative; }
.item-product .box-img::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-18deg);
  pointer-events: none;
}
.item-product .box-content { padding: 16px 16px 18px; }
.item-product .box-content .product-title { color: var(--ttn-chu); font-weight: 600; }
.item-product .box-content .price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.item-product .box-content .price del { color: #9aa3ae; }
.item-product .box-content .price ins { text-decoration: none; }
.item-product .box-content .price ins bdi { font-weight: 700; }
/* "Giá giảm theo số lượng": nhãn nhỏ dịu màu thay cho dòng chữ cam lặp lại */
.item-product .box-content p {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: var(--ttn-xanh-nhat);
  color: #155e9e;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}
.item-product .box-content p::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23155e9e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7l6 6 4-4 8 8'/%3E%3Cpath d='M15 17h6v-6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ttn-giam {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ttn-cam);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  box-shadow: 0 4px 10px -4px rgba(245, 78, 35, .8);
}
@media (hover: hover) {
  .item-product:hover {
    transform: translateY(-6px);
    box-shadow: 0 2px 4px rgba(16, 40, 80, .06), 0 22px 40px -18px rgba(30, 123, 201, .5);
  }
  .item-product:hover .box-img::after { left: 130%; transition: left .9s var(--ttn-em); }
}
@media (max-width: 549px) {
  .products-grid-ct { gap: 12px; }
  .item-product { border-radius: 14px; }
  .item-product .box-content { padding: 12px 12px 14px; }
  .item-product .box-content .product-title { font-size: 14px; line-height: 20px; min-height: 40px; }
  .item-product .box-content p { font-size: 11px; padding: 2px 8px 2px 6px; }
  .ttn-giam { top: 8px; right: 8px; font-size: 11px; }
}

/* ---------- Tin tức ---------- */
.item-sl {
  border-radius: 14px;
  padding: 10px;
  background: #fff;
  transition: transform .35s var(--ttn-em), box-shadow .35s var(--ttn-em);
}
.item-sl img { border-radius: 10px; transition: transform .6s var(--ttn-em); }
.item-sl a { display: block; overflow: hidden; }
.item-sl span i { transition: transform .3s var(--ttn-em); }
@media (hover: hover) {
  .item-sl:hover { transform: translateY(-5px); box-shadow: 0 18px 34px -18px rgba(30, 123, 201, .55); }
  .item-sl:hover h4 { color: var(--ttn-cam); }
  .item-sl:hover span i { transform: translateX(4px); }
}

/* ---------- Nút đặt in & hộp liên hệ ---------- */
.header-button .button, .header-bottom .button.primary { position: relative; }
@keyframes ttn-vong {
  0% { box-shadow: 0 0 0 0 rgba(245, 78, 35, .55); }
  70%, 100% { box-shadow: 0 0 0 12px rgba(245, 78, 35, 0); }
}
.header-bottom .button.primary, .header-bottom a.button[href*="dat"] { animation: ttn-vong 2.4s ease-out infinite; }

/* Máy tính: hộp liên hệ nổi thành cột nút tròn, rê chuột mới hiện chữ — không đè lên nội dung */
@media (min-width: 993px) {
  .contact-box-bottom-nav {
    right: 22px;
    bottom: 22px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .contact-box-bottom-nav ul { display: flex; flex-direction: column; gap: 10px; }
  .contact-box-bottom-nav ul li { padding: 0; }
  .contact-box-bottom-nav ul > li a {
    position: relative;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fff;
    font-size: 0;
    box-shadow: 0 8px 20px -8px rgba(16, 40, 80, .45);
    transition: transform .3s var(--ttn-em);
  }
  .contact-box-bottom-nav ul li svg { margin: 0; width: 28px; height: 28px; }
  .contact-box-bottom-nav ul > li a::after {
    content: attr(data-ttn-nhan);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--ttn-chu);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translate(6px, -50%);
    pointer-events: none;
    transition: opacity .25s, transform .25s var(--ttn-em);
  }
  .contact-box-bottom-nav ul > li a:hover { transform: scale(1.08); }
  .contact-box-bottom-nav ul > li a:hover::after { opacity: 1; transform: translate(0, -50%); }
}

/* ---------- Hiện dần khi cuộn ---------- */
.ttn-js .ttn-rv {
  opacity: 0;
  transform: translateY(26px);
}
.ttn-js .ttn-rv.ttn-in {
  opacity: 1;
  transform: none;
  transition:
    opacity .7s var(--ttn-em) var(--ttn-tre, 0s),
    transform .7s var(--ttn-em) var(--ttn-tre, 0s),
    box-shadow .35s var(--ttn-em),
    border-color .35s;
}
/* sau khi đã hiện xong thì trả transition hover về như thường */
.ttn-js .ttn-rv.ttn-xong { transition: transform .35s var(--ttn-em), box-shadow .35s var(--ttn-em), border-color .35s; }

@media (prefers-reduced-motion: reduce) {
  .ttn-js .ttn-rv { opacity: 1 !important; transform: none !important; }
  .title-ct h2::after { transform: none !important; }
  .header-bottom .button.primary, .header-bottom a.button[href*="dat"] { animation: none; }
  .item-product, .product-categories-grid .single-category, .item-sl { transition: none; }
}


/* ===== Thanh liên hệ cố định đáy màn (mobile) ===== */
.ttn-bb { display: none; }
@media (max-width: 767px) {
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)) !important; }
  .ttn-bb {
    display: grid; grid-template-columns: repeat(3, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 99990;
    background: #ffffff; border-top: 1px solid #e6e8ec;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  }
  .ttn-bb__i {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 58px; padding: 6px 4px; text-decoration: none !important;
    font-size: 12px; font-weight: 700; line-height: 1.1; color: #1f2937 !important;
  }
  .ttn-bb__i svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .ttn-bb__goi  { color: #0a7d2c !important; }
  .ttn-bb__zalo { color: #0068ff !important; border-left: 1px solid #eef0f3; border-right: 1px solid #eef0f3; }
  .ttn-bb__bg   { color: #d4380d !important; }
  .ttn-bb__i:active { background: #f3f4f6; }
  /* nút gọi nổi/footer cũ của theme (nếu có) đừng chồng lên thanh này */
  #main-content, #footer { padding-bottom: 0; }
}

/* Logo Zalo ở bottombar: dùng màu riêng của logo, không áp stroke như icon line */
.ttn-bb__zalo svg.ttn-zalo-logo { width: 26px; height: 26px; fill: initial; stroke: none; }
.ttn-bb__zalo { color: #0068ff !important; }
/* Logo Zalo chính chủ (icons8 #2962ff) — giữ màu gốc, size hợp bottombar */
.ttn-bb__zalo svg.ttn-zalo-logo { width: 28px; height: 28px; fill: initial; stroke: none; }
.ttn-bb__zalo svg.ttn-zalo-logo path { stroke: none; }
