/* ════════════════════════════════
   detail.css — Product detail page
   ════════════════════════════════ */

/* Layer 0: พื้นหลังทั้งหน้า สีเข้ม — เห็นรอบ card */
#detailPage {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  overflow-y: auto;
  visibility: hidden; pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease, visibility 0s linear .25s;
  padding: 60px 14px 30px;
  box-sizing: border-box;
}
#detailPage.show {
  visibility: visible; pointer-events: auto;
  opacity: 1;
  transition: opacity .25s ease, visibility 0s linear 0s;
}
#homePage { transition: opacity .2s ease; }

/* ── Layer 1: card กรอบโค้งครอบทุกอย่าง ── */
/* พื้นที่วางรูป/ข้อความเป็นสีขาวตามที่ขอ ส่วนขอบ/เงา/ความโค้งเหมือนเดิม */
.detail-outer-card {
  background: #FFFFFF;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(46,16,101,0.15);
  margin-bottom: 20px;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
}

/* ลบ bg-layer ที่ไม่ใช้แล้ว */
.detail-bg-layer { display: none; }

/* Image fade */
#dMainImg img { transition: opacity .22s ease; }
#dMainImg img.fading { opacity: 0; }

/* ── Breadcrumb — อยู่บนสุดของ card ── */
.detail-crumb {
  font-size: .72rem; color: rgba(42,27,77,0.45);
  display: flex; align-items: center; gap: 5px;
  padding: 16px 18px 10px;
  flex-wrap: nowrap; overflow: hidden;
}
.detail-crumb a {
  color: rgba(42,27,77,0.45); text-decoration: none;
  transition: color .15s; flex-shrink: 0;
}
.detail-crumb a:hover { color: var(--or); }
.crumb-home {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(76,29,149,0.1); color: var(--or) !important;
  padding: 4px 9px 4px 7px; border-radius: 20px; font-weight: 700;
}
.crumb-home:hover { background: rgba(76,29,149,0.18); }
.detail-crumb svg { flex-shrink: 0; }
.crumb-current {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex-shrink: 1;
}

/* ── รูปภาพ + รูปย่อ — ระยะขอบซ้าย/ขวาชุดเดียวกันจากกล่องนี้กล่องเดียว ── */
.detail-media-wrap { padding: 0 16px; box-sizing: border-box; background: transparent; }
.detail-main-img {
  width: 100%;
  background: rgba(76,29,149,0.06);
  border-radius: 16px; overflow: hidden; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.detail-main-img img {
  width: 100%; height: auto;
  display: block; border-radius: 16px;
  object-fit: contain;
}
.detail-main-img svg { width: 72px; height: 72px; opacity: .15; }

/* ── Thumbnail strip ── */
/* เลื่อนอิสระตามปกติ ไม่ล็อคเป็นชุดๆ — ขอบซ้าย/ขวารับมาจาก .detail-media-wrap กล่องเดียวกับรูปใหญ่
   จึงชิดขอบเดียวกันเป๊ะเสมอ ไม่มีทางเบี้ยว/ล้นออกไปนอกกรอบรูปด้านบนได้อีก */
.thumb-strip {
  width: 100%; max-width: 100%;
  box-sizing: border-box;
  display: flex; gap: 8px; padding: 10px 0;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; background: transparent;
}
.thumb-strip::-webkit-scrollbar { display: none; }
.thumb {
  box-sizing: border-box;
  width: 68px; height: 68px; flex: 0 0 auto;
  border-radius: 10px; overflow: hidden;
  border: 2px solid transparent; cursor: pointer;
  background: rgba(76,29,149,0.12); transition: border-color .18s;
  display: flex; align-items: center; justify-content: center;
}
.thumb.active { border-color: var(--or); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── Share strip ── */
.share-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px 8px; background: transparent;
}
.share-row-label {
  font-size: .85rem; font-weight: 700;
  color: rgba(42,27,77,0.55);
  margin-right: 2px; white-space: nowrap;
}
.share-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none;
  transition: transform .15s, opacity .15s; flex-shrink: 0;
}
.share-btn:active { transform: scale(.9); opacity: .8; }
.share-btn.wa   { background: #25D366; }
.share-btn.msg  { background: linear-gradient(135deg,#0084FF,#A033FF); }
.share-btn.fb   { background: #1877F2; }
.share-btn.copy { background: rgba(76,29,149,0.15); }

/* ── เนื้อหา detail ── */
.detail-card {
  background: transparent;
  padding: 4px 18px 0;
}

.detail-id-badge { display: none; }
.detail-title {
  font-weight: 800; font-size: 1.15rem; color: var(--white);
  line-height: 1.3; padding-bottom: 14px;
  border-bottom: 1px solid rgba(42,27,77,0.1); margin-bottom: 14px;
}
.detail-meta  { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.dmeta {
  display: flex; align-items: center; gap: 5px;
  background: rgba(76,29,149,0.15); border-radius: 20px;
  padding: 5px 12px; font-size: .76rem; color: var(--or); font-weight: 600;
}

.detail-status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 14px; border-radius: 50px;
  font-size: .76rem; font-weight: 700; margin-bottom: 14px;
}
.detail-status-pill.avail { background: rgba(22,163,74,0.15); color: #4ade80; border: 1.5px solid rgba(22,163,74,0.35); }
.detail-status-pill.sold  { background: rgba(192,57,43,0.15); color: #f87171; border: 1.5px solid rgba(192,57,43,0.3); }

.detail-price-box {
  background: transparent; border: none; border-radius: 0;
  padding: 0; margin-bottom: 20px;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.dp-main { flex: 1; min-width: 140px; }
.dp-stock { text-align: right; flex-shrink: 0; }
.dp-lbl  { font-size: .7rem; color: rgba(42,27,77,0.45); margin-bottom: 4px; font-weight: 600; line-height: 1; }
.dp-val  { font-family: 'Oswald', 'Noto Sans Thai', sans-serif; font-weight: 700; font-size: 1.2rem; color: var(--or); line-height: 1; }
.dp-unit { font-size: .72rem; color: var(--ord); margin-left: 4px; font-weight: 600; }
.dp-old  { font-size: .72rem; color: rgba(42,27,77,0.3); text-decoration: line-through; margin-top: 3px; }
.dp-stock-val { font-weight: 700; font-size: 1.2rem; line-height: 1; }
.dp-stock-val.avail { color: var(--white); }
.dp-stock-val.sold  { color: var(--sold); }

/* ── การ์ดรายละเอียด — ตอนนี้เป็น card แยกต่างหากทั้งใบ (ดู index.php) ── */
.detail-note-wrap {
  padding: 18px;
}
.detail-desc-text { font-size: .92rem; color: rgba(42,27,77,0.7); line-height: 1.65; word-break: break-word; }
.desc-link {
  color: #2563EB; text-decoration: underline;
  text-underline-offset: 2px; word-break: break-all;
}
.desc-link:hover { color: #1D4ED8; }

.detail-section-title {
  font-size: 1.05rem; font-weight: 800; color: var(--white);
  text-transform: none; letter-spacing: normal;
  margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.detail-table {
  background: rgba(76,29,149,0.06); border-radius: 12px;
  overflow: hidden; border: 1px solid rgba(76,29,149,0.12); margin-bottom: 14px;
}
.drow {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px; font-size: .82rem; border-bottom: 1px solid rgba(76,29,149,0.1);
}
.drow:last-child { border-bottom: none; }
.drow .dk { color: rgba(42,27,77,0.5); }
.drow .dv { font-weight: 700; color: var(--white); }

/* ── Footer ปุ่มซื้อ — อยู่ติดขอบล่าง card ── */
.detail-footer {
  padding: 14px 4px 4px;
  background: transparent;
}
.buy-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 540px; margin: 0 auto;
  background: linear-gradient(135deg, #25D366, #1EAD52);
  color: #fff; border: none; border-radius: 50px; padding: 15px 24px;
  font-size: 1rem; font-weight: 900; cursor: pointer;
  box-shadow: 0 5px 20px rgba(37,211,102,0.3);
  transition: transform .18s, box-shadow .18s; text-decoration: none;
}
.buy-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(37,211,102,0.4); }
.buy-btn.disabled {
  background: rgba(76,29,149,0.12); color: rgba(42,27,77,0.3);
  box-shadow: none; cursor: not-allowed;
}
.buy-btn.disabled:hover { transform: none; }

@media (min-width: 768px) {
  #detailPage { padding: 80px 24px 40px; }
  .detail-media-wrap { padding: 0 24px; }
  .detail-card     { padding: 6px 24px 0; }
}

/* ══════════════════════════════════
   Detail Header — แถบส้มด้านบน
══════════════════════════════════ */
.detail-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 300;
  background: linear-gradient(135deg, var(--ord), var(--or) 60%, var(--orl));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  height: 58px;
  box-shadow: 0 2px 12px rgba(46,16,101,0.35);
  box-sizing: border-box;
}
@media (min-width: 961px) {
  .detail-header { padding-left: calc((100% - 640px)/2 + 14px); padding-right: calc((100% - 640px)/2 + 14px); }
}

/* โลโก้ — เหมือนหน้าโฮม: สี่เหลี่ยม */
.detail-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: 1;
}
.detail-header-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.3);
}
.detail-header-icon img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.detail-header-text {
  display: flex; flex-direction: column;
}
.detail-header-name {
  font-size: .95rem;
  font-weight: 900;
  color: #fff;
  line-height: 1.2;
}
.detail-header-sub {
  font-size: .62rem;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ปุ่มติดต่อ — พื้นขาว, ไอคอนเขียว, ตัวหนังสือส้ม */
.detail-header-contact {
  background: #fff;
  border: none;
  border-radius: 30px;
  padding: 8px 18px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}
.detail-header-contact svg { color: #16A34A; stroke: #16A34A; }
.detail-header-contact span { color: #2E1065; }
.detail-header-contact:hover { opacity: .85; }

/* ปรับ detailPage padding ให้เว้นที่ header */
#detailPage {
  padding-top: 74px !important;
}
