/* =============================================
   AFFILIATE WEBSITE - style.css
   Cách dùng: File này chứa toàn bộ giao diện.
   Bạn có thể thay màu sắc ở phần :root bên dưới.
   ============================================= */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&display=swap');

/* --- Biến màu sắc (CSS Variables) ---
   Muốn đổi màu toàn trang? Chỉ sửa ở đây! */
:root {
  --primary: #ff6b35;        /* Màu cam chính */
  --primary-dark: #e85a24;   /* Cam đậm hơn (hover) */
  --secondary: #2d2d2d;      /* Màu chữ tối */
  --bg: #f7f5f2;             /* Nền trang */
  --card-bg: #ffffff;        /* Nền card */
  --border: #ebe8e4;         /* Màu viền */
  --text-muted: #888;        /* Màu chữ mờ */
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 24px rgba(255,107,53,0.18);
  --radius: 16px;
  --radius-sm: 10px;

  /* Màu nút theo sàn - có thể tùy chỉnh */
  --tiktok: #010101;
  --tiktok-hover: #333;
  --shopee: #ee4d2d;
  --shopee-hover: #d44127;
  --lazada: #0f146b;
  --lazada-hover: #0a0f55;
}

/* --- Reset cơ bản --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Be Vietnam Pro', sans-serif;
  background: var(--bg);
  color: var(--secondary);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* =============================================
   HEADER
   ============================================= */
.site-header {
  background: #fff;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.logo span {
  color: var(--secondary);
}

/* --- Thanh tìm kiếm --- */
.search-box {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border: 2px solid var(--border);
  border-radius: 50px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  background: var(--bg);
  color: var(--secondary);
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  background: #fff;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
}

/* =============================================
   FILTER / MENU DANH MỤC
   (menu ngang cuộn ngang trên mobile)
   ============================================= */
.filter-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Ẩn thanh cuộn nhưng vẫn cuộn được */
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  max-width: 1100px;
  margin: 0 auto;
  white-space: nowrap;
}

.filter-btn {
  padding: 7px 18px;
  border: 2px solid var(--border);
  border-radius: 50px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--secondary);
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Nút đang được chọn */
.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* =============================================
   NỘI DUNG CHÍNH
   ============================================= */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* --- Thông báo không tìm thấy --- */
#no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  display: none; /* Ẩn mặc định, JS sẽ hiện khi cần */
}

#no-results .no-results-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

#no-results p {
  font-size: 16px;
}

/* =============================================
   SECTION DANH MỤC
   (mỗi danh mục là một section)
   ============================================= */
.category-section {
  margin-bottom: 36px;
}

/* --- Tiêu đề danh mục --- */
.category-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--secondary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-title::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 22px;
  background: var(--primary);
  border-radius: 3px;
}

/* --- Lưới sản phẩm ---
   2 cột trên mobile, 3-4 cột trên desktop */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

/* 3 cột từ màn hình 640px trở lên */
@media (min-width: 640px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
}

/* 4 cột từ màn hình 900px trở lên */
@media (min-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }
}

/* =============================================
   CARD SẢN PHẨM
   ============================================= */
.product-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

/* --- Ảnh sản phẩm --- */
.product-img-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4/3; /* Tỷ lệ ảnh cố định */
  background: #f0ede9;
}

.product-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  display: block;
}

.product-card:hover .product-img-wrap img {
  transform: scale(1.06);
}

/* --- Tags (badge) --- */
.product-tags {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 50px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* Màu đặc biệt cho một số tag */
.tag[data-tag="#sale"] { background: #e53e3e; }
.tag[data-tag="#hot"]  { background: #dd6b20; }
.tag[data-tag="#mới"]  { background: #38a169; }
.tag[data-tag="#trending"] { background: #805ad5; }
.tag[data-tag="#bestseller"] { background: #d69e2e; }

/* --- Thông tin sản phẩm --- */
.product-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--secondary);
  line-height: 1.4;
  /* Cắt tối đa 2 dòng */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Giá sản phẩm --- */
.product-price-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

/* Giá gốc — gạch ngang */
.price-original {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: line-through;
}

/* Giá sau giảm — nổi bật */
.price-sale {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
}

/* Badge % giảm */
.price-badge {
  font-size: 10px;
  font-weight: 700;
  background: #fff0eb;
  color: var(--primary);
  border: 1px solid #ffd0bc;
  padding: 2px 6px;
  border-radius: 50px;
}

/* Nếu chỉ có 1 giá (không giảm) */
.price-normal {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
}

/* --- Khu vực nút mua --- */
.product-links {
  padding: 0 10px 12px;
}

/* 3 logo nằm ngang */
.buy-btns-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.buy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 6px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.buy-btn img {
  height: 22px;
  width: auto;
  display: block;
  object-fit: contain;
  transition: transform 0.15s;
}

.buy-btn:hover img { transform: scale(1.1); }
.buy-btn:active    { transform: scale(0.95); }

.btn-tiktok:hover { border-color: #010101; background: #f2f2f2; }
.btn-shopee:hover { border-color: var(--shopee); background: #fff4f1; }
.btn-lazada:hover { border-color: var(--lazada); background: #f0f2ff; }

/* =============================================
   FOOTER
   ============================================= */
.site-footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* =============================================
   LOADING ANIMATION (hiện khi đang tải data)
   ============================================= */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =============================================
   ANIMATION HIỆN CARD
   ============================================= */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.product-card {
  animation: fadeUp 0.3s ease both;
}

/* Stagger - mỗi card hiện ra trễ hơn 1 chút */
.product-card:nth-child(1) { animation-delay: 0.05s; }
.product-card:nth-child(2) { animation-delay: 0.10s; }
.product-card:nth-child(3) { animation-delay: 0.15s; }
.product-card:nth-child(4) { animation-delay: 0.20s; }
