/**
 * SP listing + detail — layout gọn, không tràn ngang, ảnh đồng kích thước
 * Bám quangcaoadv: container 1200px, lưới 4 cột, gallery 4×3
 */

/* Chặn tràn ngang toàn site trên trang SP */
html,
body.page-sp,
body.page-sp-detail {
  overflow-x: hidden;
  max-width: 100vw;
}

.page-sp *,
.page-sp-detail * {
  box-sizing: border-box;
}

.page-sp img,
.page-sp-detail img {
  max-width: 100%;
  height: auto;
}

/* ===== LISTING ===== */
.section-sp {
  padding-top: 2.5rem;
  padding-bottom: 3.5rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.35rem;
}

.filter-btn {
  border: 1px solid var(--line, #e2e8f0);
  background: #fff;
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink, #0f172a);
  cursor: pointer;
  transition: 0.2s ease;
  white-space: nowrap;
}

.filter-btn:hover,
.filter-btn.active {
  background: linear-gradient(135deg, #1d6ef5, #2563eb);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(29, 110, 245, 0.22);
}

/* Lưới cố định — minmax(0,1fr) tránh tràn */
.sp-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 100%;
}

.sp-card {
  display: flex;
  flex-direction: column;
  min-width: 0; /* quan trọng: không tràn grid */
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.sp-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.1);
}

/* Ảnh listing: VUÔNG đồng kích thước */
.sp-card .sp-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #eef2ff;
  flex-shrink: 0;
}

.sp-card .sp-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.4s ease;
}

.sp-card:hover .sp-thumb img {
  transform: scale(1.05);
}

.sp-card .sp-title {
  padding: 0.75rem 0.85rem 0.95rem;
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.55em;
  color: var(--ink, #0f172a);
}

.sp-pager {
  margin-top: 1.5rem;
  width: 100%;
}

.sp-pager .product-pager,
.product-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.pager-btn {
  min-width: 2.35rem;
  height: 2.35rem;
  padding: 0 0.55rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  color: #0f172a;
}

.pager-btn:hover:not(:disabled) {
  border-color: #1d6ef5;
  color: #1d6ef5;
}

.pager-btn.is-active {
  background: linear-gradient(135deg, #1d6ef5, #2563eb);
  border-color: transparent;
  color: #fff;
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pager-meta {
  width: 100%;
  text-align: center;
  font-size: 0.84rem;
  color: #64748b;
  margin-top: 0.2rem;
}

/* ===== DETAIL ===== */
.section-sp-detail {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.sp-detail-card {
  width: 100%;
  max-width: 100%;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  padding: 1.25rem 1.15rem 1.5rem;
  overflow: hidden; /* chặn tràn trong card */
}

.sp-detail-card .breadcrumb {
  font-size: 0.88rem;
  color: #64748b;
  margin-bottom: 0.65rem;
  word-break: break-word;
}

.sp-detail-card .breadcrumb a {
  color: #1d6ef5;
}

.sp-detail-card h1 {
  font-size: clamp(1.35rem, 2.8vw, 1.85rem);
  line-height: 1.25;
  margin: 0 0 0.65rem;
  color: var(--navy, #0b1d36);
  word-wrap: break-word;
}

.sp-detail-card .sp-lead {
  color: #64748b;
  font-size: 0.95rem;
  line-height: 1.65;
  margin: 0 0 1rem;
}

.sp-gallery-meta {
  font-size: 0.84rem;
  color: #64748b;
  margin: 0 0 0.75rem;
}

/* Gallery: 4 cột, ảnh CÙNG kích thước */
.sp-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  width: 100%;
  max-width: 100%;
  margin: 0 0 1rem;
}

.sp-gallery-item {
  position: relative;
  margin: 0;
  min-width: 0;
  width: 100%;
  aspect-ratio: 1 / 1; /* đồng kích thước tuyệt đối */
  border-radius: 12px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid rgba(15, 23, 42, 0.08);
  cursor: zoom-in;
}

.sp-gallery-item img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: cover !important;
  object-position: center;
  display: block;
  margin: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  transition: transform 0.3s ease;
}

.sp-gallery-item:hover img {
  transform: scale(1.04);
}

.sp-gallery-item figcaption,
.sp-gallery-item .adv-caption {
  display: none !important;
}

.sp-gallery-pager {
  margin-top: 0.35rem;
}

/* Khối dưới: 3 cột trong container, không tràn */
.sp-below {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 100%;
}

.sp-side-card {
  min-width: 0;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  padding: 1rem 1.05rem;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.sp-side-card h4 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  color: var(--navy, #0b1d36);
}

.sp-side-cta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sp-side-cta .btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}

.sp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sp-chips a {
  display: inline-block;
  max-width: 100%;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: rgba(29, 110, 245, 0.09);
  color: #1d4ed8;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-chips a:hover {
  background: rgba(29, 110, 245, 0.16);
}

.empty-state {
  text-align: center;
  color: #64748b;
  padding: 2rem 1rem;
}

/* ===== Responsive tablet / mobile ===== */
@media (max-width: 1024px) {
  .sp-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
  }
  .sp-gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .page-banner {
    padding: 2.25rem 0 1.75rem;
  }
  .page-banner h1 {
    font-size: clamp(1.45rem, 4vw, 1.9rem);
  }
}

@media (max-width: 768px) {
  .sp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
  }
  .sp-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
  .sp-below {
    grid-template-columns: 1fr;
  }
  .sp-detail-card {
    padding: 1rem 0.85rem 1.2rem;
    border-radius: 14px;
  }
  .sp-card .sp-title {
    font-size: 0.84rem;
    padding: 0.55rem 0.6rem 0.7rem;
    min-height: 2.4em;
  }
  .section-sp,
  .section-sp-detail {
    padding-top: 1.5rem;
    padding-bottom: 2.5rem;
  }
  .filter-btn {
    min-height: 40px;
    padding: 0.38rem 0.7rem;
    font-size: 0.8rem;
  }
  .pager-btn {
    min-width: 2.5rem;
    height: 2.5rem;
  }
  .sp-side-cta .btn {
    min-height: 44px;
  }
}

@media (max-width: 380px) {
  .sp-grid {
    gap: 0.5rem;
  }
  .sp-card .sp-title {
    font-size: 0.76rem;
    min-height: 2.3em;
  }
  .sp-gallery-grid {
    gap: 0.4rem;
  }
}

/* Touch: tắt hover lift */
@media (hover: none) {
  .sp-card:hover {
    transform: none;
  }
  .sp-card:hover .sp-thumb img,
  .sp-gallery-item:hover img {
    transform: none;
  }
}


/* no letterbox in thumbs */
.sp-card .sp-thumb { background: #0f172a !important; }
.sp-card .sp-thumb img {
  object-fit: cover !important;
  object-position: center !important;
  background: transparent !important;
}
.sp-gallery-meta { display: none !important; }
.sp-gallery-item { border: 0 !important; background: #0f172a !important; }
.sp-gallery-item img { background: transparent !important; box-shadow: none !important; }
.sp-gallery-pager:empty { display: none !important; margin: 0 !important; }
