/* ---- Hard reset ภายในบล็อกเพื่อกันของเดิมมาทับ ---- */
#fs-section .fs-media::before,
#fs-section .fs-media::after,
#fs-section .fs-sticker::before,
#fs-section .fs-sticker::after {
  content: none !important;
}
#fs-section.fs-theme-flawless {
  --bg-1: #3b302b; /* cocoa */
  --bg-2: #2c2623; /* espresso */
  --txt: #eee9e6;
  --muted: #cfc7c2;
  --gold1: #f4c8a1; /* rose-gold light */
  --gold2: #c89b72; /* rose-gold deep */
  --ink: #181818;
  --flw-gold: #b88a63;
}

/* พื้นหลังบล็อก กับขอบหรู */
#fs-section.fs-theme-flawless .container {
  background: radial-gradient(
      1200px 520px at 15% 20%,
      rgba(244, 200, 161, 0.12),
      transparent 55%
    ),
    radial-gradient(
      900px 420px at 85% 80%,
      rgba(244, 200, 161, 0.09),
      transparent 60%
    ),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid rgba(244, 200, 161, 0.2);
  border-radius: 28px;
  padding: 36px 28px 40px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}
#fs-section.fs-theme-flawless .container {
  position: relative;
  isolation: isolate;
}
#fs-section.fs-theme-flawless .container::before {
  content: "";
  position: absolute;
  /* inset: -40px; */
  background: radial-gradient(
    600px 400px at 50% 10%,
    rgba(244, 200, 161, 0.25),
    transparent 70%
  );
  z-index: -1;
  filter: blur(60px);
}

/* หัวข้อสายหรู */
#fs-section.fs-theme-flawless .title-underline {
  color: transparent;
  background: linear-gradient(90deg, var(--gold1), var(--gold2));
  -webkit-background-clip: text;
  background-clip: text;
}
#fs-section.fs-theme-flawless .title-underline::after {
  background: linear-gradient(90deg, var(--gold1), var(--gold2));
}

/* คำบรรยาย */
#fs-section.fs-theme-flawless p,
#fs-section.fs-theme-flawless .text-muted {
  color: var(--muted) !important;
  opacity: 0.95;
}

/* แถบนับถอยหลังดีไซน์บล็อกพรีเมียม */
#fs-section.fs-theme-flawless #fs-countdown > div {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(244, 200, 161, 0.25);
  color: var(--txt);
  min-width: 86px;
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 6px 16px rgba(0, 0, 0, 0.15);
}
/* ====== Mobile tweak: countdown พอดีขอบ เป๊ะขึ้น ====== */
@media (max-width: 576px) {
  #fs-section.fs-theme-flawless #fs-countdown {
    flex-wrap: nowrap;
    justify-content: space-between; /* กระจาย 4 ช่องเท่ากัน */
    gap: 0.55rem; /* เว้นระยะระหว่างกัน */
    padding-inline: 10px; /* กันชนซ้าย/ขวา ไม่ชนขอบ */
    max-width: 100%;
    box-sizing: border-box;
  }

  /* ให้แต่ละช่องแบ่งเนื้อที่เท่ากัน และไม่บังคับกว้างเกิน */
  #fs-section.fs-theme-flawless #fs-countdown > div {
    flex: 1 0 0; /* 4 ช่องพอดีแถว */
    min-width: 0; /* ตัด min-width เดิม */
    padding: 8px 10px; /* ลด padding ให้ฟิต */
    border-radius: 10px;
  }

  /* ฟอนต์ไม่ล้นกล่อง */
  #fs-section.fs-theme-flawless #fs-countdown .display-6 {
    font-size: clamp(1rem, 4.5vw, 1.2rem);
    line-height: 1.15;
  }
  #fs-section.fs-theme-flawless #fs-countdown small {
    font-size: 0.8rem;
  }
}

/* ป้องกันการล้นในจอกว้างกว่านี้นิดหน่อยด้วย */
@media (min-width: 577px) and (max-width: 768px) {
  #fs-section.fs-theme-flawless #fs-countdown {
    gap: 0.75rem;
    padding-inline: 10px;
  }
}

/* Fallback สำหรับจอเล็กมาก (ต่ำกว่า 340px) */
@media (max-width: 340px) {
  #fs-section.fs-theme-flawless #fs-countdown {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  #fs-section.fs-theme-flawless #fs-countdown::-webkit-scrollbar {
    display: none;
  }

  #fs-section.fs-theme-flawless #fs-countdown > div {
    flex: 0 0 74px; /* กำหนดขนาดพอดีให้เลื่อนได้ */
  }
}

/* การ์ดสินค้า – ปรับลุคหรู */
#fs-section.fs-theme-flawless .fs-card {
  background: linear-gradient(180deg, #fff, #f8f7f6);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.1);
  transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease;
  overflow: clip;
}
#fs-section.fs-theme-flawless .fs-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.16);
}

/* สติ๊กเกอร์ราคา/สถานะ – เม็ดโกลว์ */
#fs-section.fs-theme-flawless .fs-sticker {
  font-weight: 800;
  letter-spacing: 0.2px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.22));
}
#fs-section.fs-theme-flawless .fs-sticker.fs-danger {
  background: linear-gradient(135deg, #ff5e57, #e53935);
}
#fs-section.fs-theme-flawless .fs-sticker.fs-dark {
  background: linear-gradient(135deg, #23272f, #0f1218);
}
#fs-section.fs-theme-flawless .fs-sticker.fs-primary {
  background: linear-gradient(135deg, #5aa1ff, #0d6efd);
}

/* รูปสินค้าให้ดูใสคม */
#fs-section.fs-theme-flawless .fs-media {
  background: #f0f2f4;
}
#fs-section.fs-theme-flawless .fs-media img {
  transform: scale(1.01);
  transition: transform 0.35s ease;
}
#fs-section.fs-theme-flawless .fs-card:hover .fs-media img {
  transform: scale(1.04);
}

/* ชื่อ/ราคา */
#fs-section.fs-theme-flawless .fs-title {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.2px;
}
#fs-section.fs-theme-flawless .card-body .h5.fw-bold,
#fs-section.fs-theme-flawless .card-body .h5 {
  color: var(--ink);
}

/* Progress bar – โทนโกลด์ */
#fs-section.fs-theme-flawless .progress {
  background: #ececec;
  border-radius: 999px;
}
#fs-section.fs-theme-flawless .progress-bar {
  background: linear-gradient(90deg, var(--gold1), var(--gold2));
  border-radius: 999px;
}
#fs-section.fs-theme-flawless .btn.btn-dark:active {
  transform: scale(0.96) translateY(1px);
  filter: brightness(0.98);
}
/* ปุ่มให้หรูและตอบสนอง */
#fs-section.fs-theme-flawless .btn.btn-dark {
  color: #101010;
  background: linear-gradient(135deg, var(--gold1), var(--gold2));
  border: none;
  box-shadow: 0 10px 24px rgba(200, 155, 114, 0.35);
  font-weight: 700;
}

#fs-section.fs-theme-flawless .btn.btn-dark:hover {
  filter: brightness(1.03);
  transform: translateY(-2px);
  color: #fff;
}

.btn-flawless-viewall::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.2),
    rgba(214, 177, 132, 0.1)
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  border-radius: inherit;
}

.btn-flawless-viewall:hover {
  color: #fff;
  background: linear-gradient(135deg, #b58a63, #dcb78b);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(214, 177, 132, 0.45);
}

#fs-section.fs-theme-flawless .btn.btn-outline-secondary {
  color: var(--gold2);
  border-color: rgba(200, 155, 114, 0.55);
  background: rgba(200, 155, 114, 0.06);
  font-weight: 700;
}
#fs-section.fs-theme-flawless .btn.btn-outline-secondary:hover {
  background: rgba(200, 155, 114, 0.14);
  color: #0f0f0f;
}

/* เส้นคั่นใต้หัวข้อ – ทำให้เนียนขึ้นในธีมหรู */
#fs-section.fs-theme-flawless .fs-divider {
  background: linear-gradient(
    90deg,
    rgba(244, 200, 161, 0),
    rgba(244, 200, 161, 0.45),
    rgba(244, 200, 161, 0)
  );
  opacity: 0.35;
}

/* กริด – เงานุ่มๆ เมื่อเลื่อนเข้ามา (ผูกกับ JS ด้านล่าง) */
#fs-section.fs-theme-flawless .fs-card {
  opacity: 0;
  transform: translateY(14px);
}
#fs-section.fs-theme-flawless .fs-card.reveal-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
/* ---- Card & media ---- */
#fs-section .fs-card {
  border: 0;
  border-radius: 0.9rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
#fs-section .fs-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
}

/* ใช้ aspect-ratio แทน .ratio เพื่อตัดปัญหาทุกอย่าง */
#fs-section .fs-media {
  position: relative;
  overflow: hidden;
  border-top-left-radius: 0.9rem;
  border-top-right-radius: 0.9rem;
  aspect-ratio: 4 / 3; /* ปรับเป็น 1/1 ถ้าต้องการสี่เหลี่ยมจตุรัส */
  background: #f6f7f9;
}
#fs-section .fs-media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* ป้ายสติ๊กเกอร์ custom (ไม่ใช้ .badge) */
#fs-section .fs-sticker {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 2;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.2px;
}
#fs-section .fs-right {
  left: auto;
  right: 0.6rem;
}
#fs-section .fs-danger {
  background: #e53935;
}
#fs-section .fs-dark {
  background: #111827;
}
#fs-section .fs-primary {
  background: #0d6efd;
}

/* ชื่อสินค้า 2 บรรทัดพอดี ๆ */
#fs-section .fs-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 1.8rem;
}
/* เพิ่ม CSS สำหรับตรึงความสูงของชื่อสินค้า */
#fs-section.fs-theme-flawless .fs-title-fixed {
  min-height: 2.8rem; /* กำหนดความสูงขั้นต่ำสำหรับ 2 บรรทัด */
  line-height: 1.4;
  font-weight: 800;
}

/* ข้อความรายละเอียดสินค้า (วัสดุ, ราคา) */
#fs-section.fs-theme-flawless .fs-material-text,
#fs-section.fs-theme-flawless .fs-material-text strong {
  color: var(--ink) !important; /* เปลี่ยนเป็นสีเข้ม */
  font-weight: 600;
  opacity: 0.85;
}

/* ราคา */
#fs-section.fs-theme-flawless .fs-price-text {
  color: #dc3545 !important; /* ใช้สีแดงที่โดดเด่น */
  font-weight: 800 !important;
  font-size: 1.15rem; /* เพิ่มขนาดเล็กน้อยให้เด่นขึ้น */
}

/* Swatch สี (Color Swatch) */
#fs-section.fs-theme-flawless .fs-color-swatch {
  width: 14px; /* เพิ่มขนาด */
  height: 14px; /* เพิ่มขนาด */
  border: 0px solid #fff; /* ขอบขาวเพื่อให้เห็นชัดเจนบนพื้นหลังสีเข้ม */
  outline: 1px solid #c9c9c9; /* ขอบเทาอ่อนด้านนอกสุด */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  margin-top: 2px;
}

/* Countdown center on mobile */
@media (max-width: 991.98px) {
  #fs-countdown {
    justify-content: center !important;
  }
}

#fs-section .fs-divider {
  border: 0;
  height: 2px;
  background: linear-gradient(90deg, #000 0%, #aaa 50%, #000 100%);
  opacity: 0.15;
  border-radius: 10px;
}
@media (prefers-color-scheme: dark) {
  #fs-section .fs-divider {
    background: linear-gradient(90deg, #fff 0%, #777 50%, #fff 100%);
    opacity: 0.2;
  }
}

.title-underline::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -8px;
  width: 80px;
  height: 4px;
  background-color: #d9b48f;
  border-radius: 10px;
  transition: width 0.4s ease-in-out;
}

/* เพิ่มเอฟเฟกต์ hover นิด ๆ ให้ดูแพง */
.title-underline:hover::after {
  width: 120px;
}

/* ปุ่ม "ดูสินค้าทั้งหมด" โทนหรู + Fade Effect */
.btn-flawless-viewall {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #dcb78b, #b58a63);
  color: #1b1b1b;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 14px 38px;
  font-size: 1.1rem;
  transition: all 0.35s ease;
  box-shadow: 0 8px 25px rgba(214, 177, 132, 0.35);
  overflow: hidden;
}

/* เอฟเฟกต์เฟด + ซอฟต์โกลว์ */
.btn-flawless-viewall::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.2),
    rgba(214, 177, 132, 0.1)
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  border-radius: inherit;
}

.btn-flawless-viewall:hover {
  color: #fff;
  background: linear-gradient(135deg, #b58a63, #dcb78b);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(214, 177, 132, 0.45);
}

.btn-flawless-viewall:hover::before {
  opacity: 1;
}

.btn-flawless-viewall svg {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.btn-flawless-viewall:hover svg {
  transform: translateX(5px);
  opacity: 0.85;
}

.btn-flawless-viewall:active {
  transform: scale(0.96);
  box-shadow: 0 6px 18px rgba(214, 177, 132, 0.3);
}

/* ใช้เฉพาะในส่วน Flash Sale เท่านั้น */
#fs-section.fs-theme-flawless {
  --flw-gold: #b88a63; /* สีทองนวลของธีม */
}

#fs-section.fs-theme-flawless .btn-dark {
  transition: all 0.3s ease;
}
#fs-section.fs-theme-flawless .btn-dark:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}
#fs-section.fs-theme-flawless .btn-dark:active {
  transform: scale(0.97);
}

/* ปุ่มดูรายละเอียด (outline) – เพิ่มไฟวิ่ง แต่ใช้เฉพาะใน section นี้ */
#fs-section.fs-theme-flawless .btn-outline-secondary {
  transition: all 0.35s ease;
  position: relative;
  overflow: hidden;
}
#fs-section.fs-theme-flawless .btn-outline-secondary:hover {
  transform: translateY(-2px);
  color: #101010; /* เปลี่ยนสีข้อความเมื่อ hover ให้เห็นชัดเจน */
  background-color: var(--flw-gold);
  border-color: var(--flw-gold);
  box-shadow: 0 6px 14px rgba(184, 138, 99, 0.35);
}
/* เส้นไฟวิ่ง */
#fs-section.fs-theme-flawless .btn-outline-secondary::before {
  content: "";
  position: absolute;
  inset: 0;
  left: -100%;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.35),
    rgba(255, 255, 255, 0)
  );
  transition: left 0.5s ease;
}
#fs-section.fs-theme-flawless .btn-outline-secondary:hover::before {
  left: 100%;
}

/* เคารพผู้ใช้ที่ปิด motion */
@media (prefers-reduced-motion: reduce) {
  #fs-section.fs-theme-flawless .btn-dark,
  #fs-section.fs-theme-flawless .btn-outline-secondary {
    transition: none;
    transform: none !important;
  }
}

/* ปรับปรุงการจัดเรียง Card บนมือถือ (2 คอลัมน์) */
@media (max-width: 575.98px) {
  #fs-section .col-6 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
}
