/* --- ประกาศตัวแปรกลาง (Design Tokens) เพื่อให้ทุกหน้าใช้ค่าเดียวกัน --- */
:root {
  --bg: #060a08;
  --bg-panel: #0d1512;
  --text: #eef6f1;
  --text-muted: #9fb3a8;
  --border: #1f2f28;
  --green-bright: #4dffa0;
  --font-body: 'Noto Sans Thai', sans-serif;
  --font-display: 'Kanit', sans-serif;
  --fb-blue: #1877f2;
  --fb-blue-hover: #166fe5;
}

/* --- โครงสร้างพื้นฐานทุกหน้า --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg, #060a08);
  color: var(--text, #eef6f1);
  font-family: var(--font-body, 'Noto Sans Thai', sans-serif);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Navbar กลาง --- */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 5%;
  background: var(--bg-panel, #0d1512);
  border-bottom: 1px solid var(--border, #1f2f28);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-family: var(--font-display, 'Kanit', sans-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green-bright, #4dffa0);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-links {
  display: flex;
  gap: 25px;
  align-items: center;
}

.nav-links a {
  color: var(--text, #eef6f1);
  text-decoration: none;
  font-weight: 400;
  transition: color 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--green-bright, #4dffa0);
}

/* --- Responsive สำหรับหน้าจอโทรศัพท์ (Mobile Menu) --- */
@media (max-width: 768px) {
  /* ปรับแต่งเมนูเวลาเปิดบนมือถือ (ให้แสดงผลแบบแนวตั้งลงมาด้านล่าง) */
  #nav-menu {
    display: none; /* ซ่อนไว้เป็นค่าเริ่มต้น */
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-panel, #0d1512);
    border-bottom: 1px solid var(--border, #1f2f28);
    flex-direction: column;
    align-items: flex-start;
    padding: 1.5rem 2rem;
    gap: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  }

  /* เมื่อ JS สั่งเปิดเมนู จะเปลี่ยนเป็น class flex */
  #nav-menu.flex {
    display: flex;
  }

  #nav-menu a {
    width: 100%;
    padding: 0.5rem 0;
    font-size: 1rem;
  }
}

/* --- พื้นที่เนื้อหาหลักแต่ละหน้า (ดัน Footer ลงล่างสุดเสมอ) --- */
main {
  flex: 1;
}

/* --- Footer กลาง --- */
.main-footer {
  text-align: center;
  padding: 1.5rem;
  background: var(--bg-panel, #0d1512);
  border-top: 1px solid var(--border, #1f2f28);
  color: var(--text-muted, #9fb3a8);
  font-size: 0.9rem;
  margin-top: auto;
}

/* =========================================================
   --- Fly to Cart Animation (รูปสินค้าลอยเข้าตะกร้า) ---
   ========================================================= */
.fly-to-cart-item {
  position: fixed !important;
  z-index: 99999 !important;
  object-fit: cover;
  border-radius: 1rem;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(77, 255, 160, 0.5);
  border: 2px solid var(--green-bright, #4dffa0);
  transition: all 0.8s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* เอฟเฟกต์การเด้งของไอคอนตะกร้าสินค้าเมื่อสินค้าลอยมาถึง */
@keyframes cartBounce {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.35) rotate(-12deg);
    color: var(--green-bright, #4dffa0);
  }
  100% {
    transform: scale(1);
  }
}

.cart-bounce {
  animation: cartBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* =========================================================
   --- Floating Facebook Messenger Button (ปุ่มลอยมุมขวาล่าง) ---
   ========================================================= */
.fb-float-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--fb-blue, #1877f2);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 9999px;
  box-shadow: 0 10px 25px -5px rgba(24, 119, 242, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.fb-float-btn:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 20px 30px -10px rgba(24, 119, 242, 0.7);
  background-color: var(--fb-blue-hover, #166fe5);
}

.fb-float-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 9999px;
  background: var(--fb-blue, #1877f2);
  opacity: 0.4;
  z-index: -1;
  animation: fb-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes fb-ping {
  75%, 100% {
    transform: scale(1.15, 1.3);
    opacity: 0;
  }
}