/* =========================================================
   108problems.com - Custom Minimalist CSS
   Theme: ขาว / เทา / ดำ + Accent สีแบรนด์แพลตฟอร์ม
   ========================================================= */

:root {
  --color-bg: #ffffff;
  --color-surface: #f7f7f8;
  --color-border: #e5e5e8;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b70;
  --color-accent: #111111;

  /* Brand colors ของแต่ละแพลตฟอร์ม */
  --brand-shopee: #ee4d2d;
  --brand-lazada: #0f146d;
  --brand-tiktok: #010101;
  --brand-tiktok-accent: #25f4ee;

  --radius-sm: 8px;
  --radius-md: 14px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 10px 20px rgba(0,0,0,0.08);

  /* Typography: serif ตัวหนาสำหรับหัวข้อ (ให้ความรู้สึกเหมือนบทความ/คู่มือ ไม่ใช่แค่แคตตาล็อกสินค้า)
     จับคู่กับ sans-serif อ่านง่ายสำหรับเนื้อหา */
  --font-body: "Noto Sans Thai", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Noto Serif Thai", "Noto Sans Thai", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }
.text-accent { color: var(--brand-shopee); }

/* ---------- Header ---------- */
.site-header { z-index: 1030; }
.navbar-brand { font-size: 1.35rem; letter-spacing: -0.5px; }
.nav-link { font-weight: 500; color: var(--color-text) !important; }
.nav-link:hover { color: var(--brand-shopee) !important; }
.nav-link.active { color: var(--brand-shopee) !important; font-weight: 700; }

/* ---------- Hero / Page heading ---------- */
.page-hero {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 2.5rem 0;
}
.page-hero h1 { font-weight: 800; letter-spacing: -0.5px; }

/* ---------- Product Card Grid ---------- */
.product-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
  height: 100%;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}
.product-card__img-wrap {
  aspect-ratio: 1 / 1;
  background: var(--color-surface);
  overflow: hidden;
}
.product-card__img-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .3s ease;
}
.product-card:hover .product-card__img-wrap img { transform: scale(1.04); }
.product-card__body { padding: .9rem 1rem 1.1rem; }
.product-card__title {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.product-card__price {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--color-accent);
}
.product-card__category {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}

/* ---------- Category filter chips ---------- */
.category-chip {
  display: inline-block;
  padding: .4rem .9rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  font-size: .85rem;
  font-weight: 500;
  color: var(--color-text);
  background: #fff;
}
.category-chip.active,
.category-chip:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

/* ---------- Product Detail ---------- */
.gallery-main {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-main img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 560px; /* กันภาพแนวตั้งสูงมากเกินไปจนหน้ายาวเกินควร ไม่กระทบภาพแนวนอนทั่วไป */
  object-fit: contain; /* แสดงภาพเต็ม ไม่ครอปตัด ไม่ว่าอัตราส่วนภาพจะเป็นเท่าไหร่ */
}
.gallery-thumb {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
}
.gallery-thumb.active { border-color: var(--color-accent); }

.before-after-box {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.before-after-box .ba-col { position: relative; aspect-ratio: 1/1; }
.before-after-box img { width: 100%; height: 100%; object-fit: cover; }
.before-after-box .ba-label {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.7); color: #fff;
  font-size: .7rem; font-weight: 700; letter-spacing: .05em;
  padding: 2px 10px; border-radius: 999px; text-transform: uppercase;
}

/* ---------- Affiliate Buttons ---------- */
.btn-affiliate {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: .85rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  color: #fff;
  font-weight: 700;
  margin-bottom: .6rem;
  transition: filter .15s ease, transform .15s ease;
}
.btn-affiliate:hover { filter: brightness(1.08); transform: translateY(-1px); color: #fff; }
.btn-affiliate .badge-note {
  font-weight: 500; font-size: .75rem;
  background: rgba(255,255,255,.18);
  padding: 2px 10px; border-radius: 999px;
}
.btn-shopee { background: var(--brand-shopee); }
.btn-lazada { background: var(--brand-lazada); }
.btn-tiktok { background: var(--brand-tiktok); }
.btn-other  { background: #3a3a3c; }

/* ---------- Admin ---------- */
.admin-sidebar {
  min-height: 100vh;
  background: #111;
  color: #eee;
}
.admin-sidebar a {
  color: #cfcfcf; display: block; padding: .65rem 1.2rem; font-size: .92rem;
}
.admin-sidebar a:hover, .admin-sidebar a.active {
  background: rgba(255,255,255,.08); color: #fff;
}
.stat-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  background: #fff;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-card .stat-label { font-size: .8rem; color: var(--color-text-muted); }

.repeater-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: .75rem;
  background: var(--color-surface);
}

.thumb-preview {
  width: 90px; height: 90px; object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* ---- Utilities ---- */
.text-muted-sm { font-size: .8rem; color: var(--color-text-muted); }
.empty-state { padding: 4rem 0; text-align: center; color: var(--color-text-muted); }

/* ---- Tag Chip Input (Admin: product-add/edit) ---- */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  border: 1px solid #ced4da;
  border-radius: var(--radius-sm);
  padding: .4rem .5rem;
  background: #fff;
}
.tag-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag-chip-item {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: .15rem .5rem .15rem .7rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text);
}
.tag-chip-remove {
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0 .1rem;
  cursor: pointer;
}
.tag-chip-remove:hover { color: var(--brand-shopee); }
.tag-text-input {
  flex: 1;
  min-width: 140px;
  border: none;
  outline: none;
  font-size: .85rem;
  padding: .15rem .2rem;
}

/* ---- Tag Pills (Frontend: product-detail.php) ---- */
.tag-pill-link {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .3rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: .78rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tag-pill-link:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}
.tag-pill-link::before { content: "#"; opacity: .55; }

/* ---- Social Share Buttons ---- */
.share-row { display: flex; align-items: center; gap: .5rem; }
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text);
  transition: transform .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.share-btn svg { width: 16px; height: 16px; fill: currentColor; }
.share-btn:hover { transform: translateY(-2px); color: #fff; }
.share-btn--facebook:hover { background: #1877F2; border-color: #1877F2; }
.share-btn--line:hover { background: #06C755; border-color: #06C755; }
.share-btn--x:hover { background: #000; border-color: #000; }

/* ---- Modern Product Tile (Homepage grid) ---- */
.product-tile {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease;
}
.product-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); }
.product-tile__media {
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--color-surface);
  overflow: hidden;
}
.product-tile__media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .3s ease;
}
.product-tile:hover .product-tile__media img { transform: scale(1.05); }
.product-tile__body {
  padding: .85rem .95rem 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.product-tile__tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .5rem;
}
.tag-pill-link--sm { font-size: .68rem; padding: .18rem .55rem .18rem .65rem; }
.product-tile__title-link {
  color: inherit;
  text-decoration: none;
  display: block;
  margin-bottom: .65rem;
}
.product-tile__category {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  margin-bottom: .2rem;
}
.product-tile__title {
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}
.product-tile__footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.product-tile__price {
  font-weight: 800;
  font-size: 1rem;
  color: var(--color-text);
  white-space: nowrap;
}
.product-tile__cta {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  font-size: .76rem;
  font-weight: 700;
  padding: .35rem .7rem;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  transition: filter .15s ease, transform .15s ease;
  flex-shrink: 0;
}
.product-tile__cta:hover { filter: brightness(1.1); color: #fff; transform: translateX(2px); }

/* =========================================================
   Product Detail — Redesign
   ========================================================= */

/* ---- Hero: eyebrow + serif title + teaser ---- */
.product-hero { padding: 2rem 0 1.5rem; }
.product-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brand-shopee);
  margin-bottom: .9rem;
}
.product-hero__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 3.2vw, 2.5rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: .6rem;
}
.product-hero__teaser {
  font-size: 1.02rem;
  color: var(--color-text-muted);
  max-width: 640px;
  line-height: 1.6;
}

/* ---- จุดเด่น (Highlights) Card ---- */
.highlight-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 1.4rem 1.5rem;
}

/* ---- Buy Box: ราคา + ปุ่มซื้อ (Sticky บนจอใหญ่ ใน col-lg-5 ทางขวา) ---- */
.buy-box {
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-card);
}
@media (min-width: 992px) {
  .buy-box--sticky { position: sticky; top: 88px; }
}
.buy-box__price-label {
  font-size: .75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .2rem;
}
.buy-box__price {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.1;
  margin-bottom: 1.1rem;
}

/* ---- Before / After Draggable Slider (signature interaction) ---- */
.ba-slider {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  cursor: ew-resize;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y;
  background: var(--color-surface);
}
.ba-slider__after,
.ba-slider__before {
  position: absolute;
  inset: 0;
}
.ba-slider__after img,
.ba-slider__before img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
  pointer-events: none;
}
.ba-slider__before {
  clip-path: inset(0 50% 0 0);
}
.ba-slider__handle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  pointer-events: none;
}
.ba-slider__handle-line {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 3px;
  background: #fff;
  transform: translateX(-50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.ba-slider__handle-grip {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
}
.ba-slider__label {
  position: absolute;
  bottom: 10px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 11px;
  border-radius: 999px;
  pointer-events: none;
}
.ba-slider__label--left { left: 10px; }
.ba-slider__label--right { right: 10px; }

/* ---- Rich Content (WYSIWYG output จาก Quill) ---- */
.rich-content { line-height: 1.75; color: var(--color-text); }
.rich-content p { margin-bottom: .85rem; }
.rich-content ul, .rich-content ol { margin-bottom: .85rem; padding-left: 1.3rem; }
.rich-content li { margin-bottom: .3rem; }
.rich-content a { color: var(--brand-shopee); text-decoration: underline; }
.rich-content strong { font-weight: 700; }

/* ---- Horizontal scroll carousel: "คุณอาจพบเจอปัญหานี้" ---- */
.suggest-scroll {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: .75rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.suggest-scroll::-webkit-scrollbar { height: 6px; }
.suggest-scroll::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 999px; }
.suggest-scroll::-webkit-scrollbar-track { background: transparent; }
.suggest-scroll__item {
  flex: 0 0 200px;
  scroll-snap-align: start;
}
@media (max-width: 575.98px) {
  .suggest-scroll__item { flex-basis: 155px; }
}

/* ---- Scroll reveal (เบา ๆ ไม่ overdo) ---- */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .5s ease, transform .5s ease;
}
.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .reveal-on-scroll { opacity: 1; transform: none; transition: none; }
}
