/* wrapper */
.table-responsive {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

/* table: responsive - note: use auto layout so columns can wrap better */
.term-description .table-responsive > table {
  width: 100%;
  min-width: 900px; /* <-- giảm min-width so với trước, bạn có thể tinh chỉnh (750 - 1100) */
  max-width: none;
  table-layout: auto; /* auto giúp text không bị cắt cứng ở cột */
  border-collapse: collapse;
  background: #fff;
}

/* basic cells */
/* NOTE: remove overflow:hidden to allow wrapping instead of clipping */
.term-description th,
.term-description td {
  padding: 12px 10px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  color: #333;
  white-space: normal; /* allow wrap */
  overflow: visible;   /* don't hide overflowing text */
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.5;
}

/* header */
.term-description thead th {
  font-weight: 700;
  background: #fafafa;
  text-align: center;
  font-size: 14px;
}

/* first column header (Phiên bản) - left align */
.term-description thead th:first-child {
  text-align: left;
}

/* image container */
.term-description td img {
  max-width: 70px;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ===== Column sizing ===== */
/* Column 1 */
.term-description table th:nth-child(1),
.term-description table td:nth-child(1) {
  width: 18%;
  min-width: 140px;
  text-align: left;
  padding-left: 16px;
}

/* Product columns - use min-width only, avoid fixed 'width' if possible */
.term-description table th:nth-child(n+2),
.term-description table td:nth-child(n+2) {
  min-width: 120px;
  text-align: center;
  vertical-align: middle;
}

/* Scroll gradient */
.table-responsive::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(to left, rgba(255,255,255,0.98), rgba(255,255,255,0));
  z-index: 10;
  opacity: 1;
  transition: opacity 0.25s ease, visibility 0.25s;
}

/* Hide gradient when scrolled to end or no overflow */
.table-responsive.scrolled-end::after,
.table-responsive.no-overflow::after {
  opacity: 0;
  visibility: hidden;
}

/* Scroll arrow hint (use button for accessibility) */
.table-responsive .scroll-arrow {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  border: none;
  cursor: pointer;
  transition: opacity .25s ease, transform .12s ease;
  opacity: 1;
}

/* hide arrow when scrolled to end or no overflow */
.table-responsive.scrolled-end .scroll-arrow,
.table-responsive.no-overflow .scroll-arrow {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* arrow svg */
.table-responsive .scroll-arrow svg {
  width: 14px;
  height: 14px;
  fill: #666;
}

/* small press effect */
.table-responsive .scroll-arrow:active {
  transform: translateY(-50%) scale(.98);
}

/* ===== MOBILE OPTIMIZATION ===== */
@media (max-width: 768px) {
  .term-description .table-responsive > table {
    min-width: 900px; /* still allow scroll on small screens, adjust as needed */
  }

  .term-description th,
  .term-description td {
    padding: 10px 8px;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
  }

  .term-description table th:nth-child(1),
  .term-description table td:nth-child(1) {
    min-width: 120px;
    padding-left: 12px;
    font-size: 13px;
  }

  .term-description td img {
    max-width: 60px;
  }

  .table-responsive.has-overflow::after {
    width: 50px;
  }

  .table-responsive .scroll-arrow {
    right: 8px;
    width: 32px;
    height: 32px;
  }

  .table-responsive .scroll-arrow svg {
    width: 12px;
    height: 12px;
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  .term-description .table-responsive > table {
    min-width: 720px;
  }

  .term-description th,
  .term-description td {
    padding: 8px 6px;
    font-size: 12px;
  }

  .term-description table th:nth-child(1),
  .term-description table td:nth-child(1) {
    min-width: 100px;
    padding-left: 8px;
  }

  .term-description td img {
    max-width: 50px;
  }
}
