/* Affilinet Connector — giao diện sản phẩm affiliate
   Dùng biến CSS để theme dễ ghi đè màu sắc theo thương hiệu riêng. */

.afl-card,
.afl-grid-wrap,
.afl-compare-wrap,
.afl-cta-wrap {
  --afl-radius: 12px;
  --afl-border: #e5e7eb;
  --afl-text: #111827;
  --afl-muted: #6b7280;
  --afl-price: #dc2626;
  --afl-cta: #ea580c;
  --afl-cta-hover: #c2410c;
  --afl-bg: #ffffff;
}

/* Theo màu nền tối của trình duyệt nếu người đọc dùng chế độ tối */
@media (prefers-color-scheme: dark) {
  .afl-card, .afl-grid-wrap, .afl-compare-wrap {
    --afl-border: #374151;
    --afl-text: #f3f4f6;
    --afl-muted: #9ca3af;
    --afl-bg: #1f2937;
  }
}

/* ---------- Thẻ sản phẩm ---------- */
.afl-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  margin: 20px 0;
  border: 1px solid var(--afl-border);
  border-radius: var(--afl-radius);
  background: var(--afl-bg);
  color: var(--afl-text);
}

.afl-card__imgwrap {
  flex: 0 0 140px;
  display: block;
}

.afl-card__img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
  background: #f9fafb;
}

.afl-card__body { flex: 1; min-width: 0; }

.afl-card__brand {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--afl-muted);
  margin-bottom: 4px;
}

.afl-card__title {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.4;
  font-weight: 600;
}

.afl-card__title a {
  color: var(--afl-text);
  text-decoration: none;
}
.afl-card__title a:hover { text-decoration: underline; }

/* ---------- Giá ---------- */
.afl-price { margin-bottom: 8px; }

.afl-price__now {
  font-size: 22px;
  font-weight: 700;
  color: var(--afl-price);
}

.afl-price__was {
  font-size: 14px;
  color: var(--afl-muted);
  text-decoration: line-through;
  margin-left: 6px;
}

/* Giá quá cũ thì không hiện số — nhiều chương trình affiliate cấm */
.afl-price--stale {
  font-size: 15px;
  color: var(--afl-muted);
  font-style: italic;
}

/* ---------- Nhãn ---------- */
.afl-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  vertical-align: middle;
}

.afl-badge--sale { background: #fee2e2; color: #b91c1c; }
.afl-badge--official { background: #dbeafe; color: #1e40af; }

/* ---------- Thông tin phụ ---------- */
.afl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--afl-muted);
  margin-bottom: 12px;
}

.afl-meta__rating { color: #f59e0b; font-weight: 600; }

/* ---------- Nút mua ---------- */
.afl-cta {
  display: inline-block;
  padding: 11px 22px;
  background: var(--afl-cta);
  color: #fff !important;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none !important;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.afl-cta:hover { background: var(--afl-cta-hover); color: #fff !important; }

.afl-cta-wrap { margin: 16px 0; }

.afl-card__updated {
  margin-top: 10px;
  font-size: 11px;
  color: var(--afl-muted);
}

/* ---------- Lưới sản phẩm ---------- */
.afl-grid-wrap { margin: 24px 0; }

.afl-grid__title {
  font-size: 20px;
  margin: 0 0 16px;
  color: var(--afl-text);
}

.afl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* Trong lưới thì xếp dọc cho gọn */
.afl-card--grid {
  flex-direction: column;
  margin: 0;
}

.afl-card--grid .afl-card__imgwrap {
  flex: none;
  width: 100%;
  max-height: 180px;
  overflow: hidden;
}

.afl-card--grid .afl-card__img { max-height: 180px; }

/* ---------- Bảng so sánh ---------- */
.afl-compare-wrap {
  margin: 24px 0;
  overflow-x: auto;   /* cuộn ngang trên điện thoại, không làm vỡ trang */
  -webkit-overflow-scrolling: touch;
}

.afl-compare {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--afl-bg);
  color: var(--afl-text);
}

.afl-compare th,
.afl-compare td {
  padding: 12px;
  border: 1px solid var(--afl-border);
  text-align: left;
  vertical-align: middle;
}

.afl-compare thead th {
  background: #f9fafb;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .afl-compare thead th { background: #111827; }
  .afl-card__img { background: #111827; }
}

.afl-compare tbody th {
  width: 110px;
  font-weight: 600;
  color: var(--afl-muted);
}

.afl-compare .afl-price__now { font-size: 17px; }
.afl-compare .afl-cta { padding: 8px 14px; font-size: 14px; }

/* ---------- Thông báo cho quản trị viên ---------- */
.afl-notice {
  padding: 10px 14px;
  margin: 16px 0;
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  border-radius: 4px;
  font-size: 14px;
  color: #78350f;
}

/* ---------- Điện thoại ---------- */
@media (max-width: 600px) {
  .afl-card { flex-direction: column; }
  .afl-card__imgwrap { flex: none; width: 100%; }
  .afl-card__img { max-height: 220px; }
  .afl-cta { display: block; text-align: center; }
}

/* ============================================================
   Tinh chỉnh giao diện — làm sản phẩm nổi bật trong bài viết
   ============================================================ */

.afl-card {
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  transition: box-shadow .2s ease, transform .2s ease;
  position: relative;
  overflow: hidden;
}

.afl-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  transform: translateY(-2px);
}

/* Dải màu mỏng bên trái để thẻ sản phẩm tách khỏi nội dung bài */
.afl-card--card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--afl-cta), var(--afl-price));
}

.afl-card--card { padding-left: 20px; }

.afl-card__imgwrap {
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
}

.afl-card__img {
  transition: transform .3s ease;
  aspect-ratio: 1;
  padding: 8px;
}

.afl-card:hover .afl-card__img { transform: scale(1.04); }

.afl-cta {
  box-shadow: 0 2px 6px rgba(234,88,12,.25);
  letter-spacing: .01em;
}

.afl-cta:hover {
  box-shadow: 0 4px 12px rgba(234,88,12,.35);
  transform: translateY(-1px);
}

.afl-cta::after {
  content: ' →';
  opacity: .7;
}

/* Lưới sản phẩm: các thẻ cao bằng nhau, nút mua luôn nằm dưới cùng */
.afl-grid { align-items: stretch; }

.afl-card--grid {
  height: 100%;
  padding-left: 16px;
}

.afl-card--grid .afl-card__body {
  display: flex;
  flex-direction: column;
}

.afl-card--grid .afl-card__title {
  font-size: 15px;
  /* Cắt còn 2 dòng để các thẻ đều nhau */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.afl-card--grid .afl-cta { margin-top: auto; }
.afl-card--grid .afl-price__now { font-size: 19px; }

.afl-grid__title {
  padding-bottom: 10px;
  border-bottom: 2px solid var(--afl-border);
}

/* Bảng so sánh: gợi ý người dùng cuộn ngang trên điện thoại */
.afl-compare-wrap { position: relative; }

@media (max-width: 700px) {
  .afl-compare-wrap::after {
    content: 'Vuốt ngang để xem đầy đủ →';
    display: block;
    padding: 8px 0 0;
    font-size: 12px;
    color: var(--afl-muted);
    text-align: right;
  }
}

.afl-compare tbody tr:hover td { background: rgba(0,0,0,.02); }

/* Câu mở đầu và dòng công bố tiếp thị */
.afl-lead {
  font-size: 17px;
  line-height: 1.7;
  color: var(--afl-muted);
}

.afl-disclosure {
  margin-top: 32px;
  padding: 12px 16px;
  background: #f9fafb;
  border-left: 3px solid var(--afl-border);
  border-radius: 4px;
  font-size: 13px;
  color: var(--afl-muted);
}

@media (prefers-color-scheme: dark) {
  .afl-disclosure { background: #111827; }
  .afl-compare tbody tr:hover td { background: rgba(255,255,255,.03); }
}

/* ============================================================
   TRANG CHI TIẾT SẢN PHẨM
   ============================================================ */

.afl-single {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 32px;
  margin: 0 0 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--afl-border, #e5e7eb);
}

.afl-single__media {
  border: 1px solid var(--afl-border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  padding: 16px;
}

.afl-single__media img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
}

.afl-single__brand {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--afl-muted, #6b7280);
  margin-bottom: 10px;
}

.afl-single__price .afl-price__now { font-size: 32px; }
.afl-single__price .afl-price__was { font-size: 16px; }
.afl-single__price { margin-bottom: 20px; }

/* Bảng thông số */
.afl-specs {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0;
  margin: 0 0 20px;
  font-size: 14px;
  border-top: 1px solid var(--afl-border, #e5e7eb);
}

.afl-specs dt,
.afl-specs dd {
  padding: 10px 0;
  margin: 0;
  border-bottom: 1px solid var(--afl-border, #e5e7eb);
}

.afl-specs dt {
  color: var(--afl-muted, #6b7280);
  font-weight: 500;
}

.afl-specs dd { font-weight: 600; }

.afl-single__badges { margin-bottom: 16px; }

.afl-single__buy {
  padding: 20px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
}

.afl-single__buy .afl-cta {
  display: block;
  text-align: center;
  font-size: 17px;
  padding: 14px 24px;
}

.afl-single__updated,
.afl-single__note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--afl-muted, #6b7280);
  text-align: center;
}

.afl-related { margin-top: 40px; }

/* ============================================================
   TRANG DANH SÁCH SẢN PHẨM
   ============================================================ */

.afl-archive {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.afl-archive__head {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--afl-border, #e5e7eb);
}

.afl-archive__title {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.2;
}

.afl-archive__desc {
  margin: 0 0 8px;
  color: var(--afl-muted, #6b7280);
  font-size: 16px;
}

.afl-archive__count {
  font-size: 14px;
  color: var(--afl-muted, #6b7280);
}

/* Nút phụ — dẫn vào trang chi tiết chứ không ra thẳng sàn */
.afl-cta--soft {
  background: transparent;
  color: var(--afl-cta, #ea580c) !important;
  border: 1.5px solid var(--afl-cta, #ea580c);
  box-shadow: none;
  padding: 9px 18px;
  font-size: 14px;
}

.afl-cta--soft:hover {
  background: var(--afl-cta, #ea580c);
  color: #fff !important;
}

.afl-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--afl-muted, #6b7280);
}

.afl-pagination {
  margin-top: 40px;
  text-align: center;
}

.afl-pagination .page-numbers {
  display: inline-block;
  padding: 8px 14px;
  margin: 0 3px;
  border: 1px solid var(--afl-border, #e5e7eb);
  border-radius: 6px;
  text-decoration: none;
  color: var(--afl-text, #111827);
}

.afl-pagination .page-numbers.current,
.afl-pagination .page-numbers:hover {
  background: var(--afl-cta, #ea580c);
  border-color: var(--afl-cta, #ea580c);
  color: #fff;
}

/* Điện thoại */
@media (max-width: 782px) {
  .afl-single {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .afl-single__price .afl-price__now { font-size: 26px; }
  .afl-archive__title { font-size: 24px; }
}

@media (prefers-color-scheme: dark) {
  .afl-single__media { background: #1f2937; }
  .afl-single__buy { background: #292524; border-color: #57534e; }
}
