/* 🔸 Header — single source of truth (แทนที่บล็อก header เดิมทั้งหมด) */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 32px 16px;
  text-align: center;
  background: #fff;
  border-bottom: 1px solid #eee;
  transition: transform 0.4s ease, opacity 0.4s ease;
  min-height: 88px;
}

/* ซ่อน header ขณะเลื่อนลง */
header.hide-header {
  transform: translateY(-60%);
  opacity: 0;
}

/* องค์ประกอบใน header */
.logo {
  font-weight: 700;
  font-size: 28px;
  color: #ee4d2d;
}
.subtitle {
  margin-top: 6px;
  font-size: 18px;
  color: #555;
}

/* ปุ่ม CTA (ถ้ามี) */
.cta {
  display: inline-block;
  background: linear-gradient(90deg, #ee4d2d, #ff774d);
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  margin-top: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: 0.25s;
}
.cta:hover {
  background: linear-gradient(90deg, #d63b1e, #ff6a3a);
  transform: translateY(-2px);
}

body {
  font-family: 'Prompt', system-ui, -apple-system, 'Segoe UI', Roboto, Arial;
  margin: 0;
  color: #222;
  background: #fffaf8;
}

/* 🔸 หมวดหมู่ */
.category-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  padding: 20px 8px;
  background: #fff;
  border-bottom: 1px solid #f3f3f3;
}
.cat-btn {
  border: none;
  background: transparent;
  font-weight: 500;
  font-size: 16px;
  color: #666;
  cursor: pointer;
  padding-bottom: 6px;
  border-bottom: 3px solid transparent;
  transition: all 0.3s;
}
.cat-btn.active { color: #ee4d2d; border-color: #ee4d2d; }

/* 🔍 Search Box */
.search-box {
  display: flex;
  justify-content: center;
  background: #fff;
  padding: 16px;
  border-bottom: 1px solid #f3f3f3;
}
.search-box input {
  width: 100%;
  max-width: 500px;
  padding: 10px 16px;
  border: 2px solid #ee4d2d;
  border-radius: 50px;
  font-size: 16px;
  outline: none;
  transition: 0.3s;
}
.search-box input:focus { box-shadow: 0 0 0 3px rgba(238,77,45,0.2); }

/* 🔸 Section Layout */
main {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 16px;
}

section {
  background: #fff;
  border-radius: 20px;
  padding: 30px 20px 40px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.05);
  margin-bottom: 40px;
  transition: 0.3s;
}
section:hover { box-shadow: 0 5px 14px rgba(0,0,0,0.08); }

.section-title {
  font-weight: 700;
  font-size: 22px;
  color: #ee4d2d;
  margin: 12px 0 20px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 28px;
  background: linear-gradient(180deg, #ee4d2d, #ff9771);
  border-radius: 4px;
}

/* 🔹 Grid Card Layout */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

/* มือถือ: บังคับ 2 คอลัมน์ */
@media (max-width: 480px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .card .box { padding: 10px; }
  .title { font-size: 14px; }
  .price { font-size: 16px; }
}

.card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; }

.card .box {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.title {
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
  font-size: 15px;
  color: #333;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.price { font-weight: 700; color: #ee4d2d; font-size: 18px; margin-bottom: 10px; }

.buy {
  display: block;
  text-align: center;
  background: linear-gradient(90deg, #ee4d2d, #ff774d);
  color: #fff;
  padding: 12px 0;
  font-weight: 600;
  border-radius: 10px;
  margin: 12px;
  text-decoration: none;
  transition: all 0.25s ease;
  box-shadow: 0 3px 6px rgba(238,77,45,0.3);
}
.buy:hover {
  background: linear-gradient(90deg, #d63b1e, #ff6c3c);
  transform: translateY(-2px);
  box-shadow: 0 5px 10px rgba(238,77,45,0.4);
}

/* 🔸 Footer */
footer {
  padding: 30px 16px;
  text-align: center;
  color: #777;
  font-size: 14px;
  margin-top: 30px;
}

/* 🌀 Loading Overlay */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #ee4d2d;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
#loading.active { opacity: 1; pointer-events: all; }
.brand-logo { font-size: 42px; font-weight: 700; color: #ee4d2d; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:.4;transform:scale(1);}50%{opacity:1;transform:scale(1.1);} }
.spinner { border:4px solid #f3f3f3;border-top:4px solid #ee4d2d;border-radius:50%;
  width:50px;height:50px;margin:24px 0 12px;animation:spin 1s linear infinite;}
@keyframes spin {0%{transform:rotate(0deg);}100%{transform:rotate(360deg);} }
.hidden { display: none !important; }

/* 📱 Responsive */
@media (max-width: 768px) {
  .section-title { justify-content: center; text-align: center; }
  section { padding: 20px 12px 32px; }
}

/* === 🔥 สไลด์สินค้าขายดี === */
.carousel {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  gap: 16px;
  padding-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: #ee4d2d #fff;
}
.carousel::-webkit-scrollbar { height: 8px; }
.carousel::-webkit-scrollbar-thumb { background: #ee4d2d; border-radius: 10px; }
.carousel::-webkit-scrollbar-track { background: #fff; }
.carousel-wrap { position: relative; }
.carousel-btn {
  position: absolute;
  top: 40%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.9);
  border: 1px solid #eee;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #ee4d2d;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: 0.2s;
}
.carousel-btn:hover { background: #ee4d2d; color: #fff; }
.carousel-btn.left { left: -10px; }
.carousel-btn.right { right: -10px; }
.carousel .card { flex: 0 0 clamp(180px, 28vw, 240px); }
.carousel .card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }

/* ✅ บังคับให้ทุก element ใช้ฟอนต์ Prompt จริงๆ */
* {
  font-family: 'Prompt', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif !important;
}

/* ✅ ปุ่มและช่อง input ใช้ Prompt ด้วย */
button, input, select, textarea {
  font-family: 'Prompt', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif !important;
  letter-spacing: 0.2px;
}

.cat-btn {
  font-weight: 500;
  letter-spacing: 0.3px;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.share {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 12px 12px;
}
.share button{
  border: 1px solid #eee;
  background: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.share button:hover{
  background: #f9f9f9;
}
/* ปุ่มแชร์เฉพาะแพลตฟอร์ม */
.share .fb {
  background: #1877f2;
  color: #fff;
  border: none;
}
.share .fb:hover {
  background: #166fe5;
}
.share .line {
  background: #06c755;
  color: #fff;
  border: none;
}
.share .line:hover {
  background: #04b94d;
}
.social-proof {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
  margin-top: 4px;
}
.social-proof svg {
  width: 18px;
  height: 18px;
  fill: #2e7d32;
  stroke: #2e7d32;
  stroke-width: 0.5;
}
.social-proof b {
  color: #2e7d32;
}

/* === Credible Badge (Shield Verified) === */
.cred { display:flex; align-items:center; margin-top:6px; }
.cred .badge {
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 12px; border-radius:999px;
  border:1px solid #ececec; background:#fff;
  box-shadow:0 1px 0 rgba(0,0,0,.04);
  font-size:13px; color:#444;
}
.cred .meta { display:flex; align-items:baseline; gap:6px; }
.cred .meta b { font-size:14px; }

.cred .shield { width:18px; height:18px; flex:0 0 18px; }

/* ระดับความน่าเชื่อถือจากยอดคลิก */
.badge.bronze { border-color:#e9d1b8; }
.badge.silver { border-color:#d8dfe6; }
.badge.gold   { border-color:#f2d27b; }

/* สีโล่ */
.shield.gold   path.fill   { fill:#f4c64e; }
.shield.silver path.fill   { fill:#cfd7df; }
.shield.bronze path.fill   { fill:#dba66a; }
.shield path.tick { fill:#2e7d32; }

/* โน้ตเสริมเล็กๆ */
.badge small { color:#777; font-size:12px; }

/* กำหนดความสูงเฮดเดอร์เป็นตัวแปรเดียว */
:root { --header-h: 88px; }
/*main { padding-top: calc(var(--header-h) + 8px); }*/

/* มือถือ: ลดความสูงจริงของ header */
@media (max-width: 768px) {
  :root { --header-h: 56px; }

  header {
    padding: 10px 12px;
    min-height: var(--header-h);
  }

  .logo {
    font-size: 20px;
    line-height: 1.1;
  }

  .search-box {
    padding: 8px 12px;
  }
  .search-box input {
    padding: 8px 12px;
    font-size: 14px;
    border-width: 1.5px;
  }

  .category-bar {
    gap: 12px;
    padding: 12px 8px;
  }
  .cat-btn { font-size: 14px; padding-bottom: 4px; }
}

/* 1) รีเซ็ต .visually-hidden บนเดสก์ท็อปให้กลับมาแสดงผลได้ */
@media (min-width: 769px) {
  h1.visually-hidden {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    border: 0 !important;
  }
}

/* 2) มือถือ: ซ่อนโลโก้ + h1 จริง ๆ */
@media (max-width: 768px) {
  header .logo,
  header h1 {
    display: none !important;
  }
}
