/* ============================================================
   style.css — Customer Page Styles
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;500;600;700;800&display=swap');
@import url('variables.css');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  font-size: var(--font-size-md);
  color: var(--color-text-main);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Page wrapper ---- */
#page-wrapper {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding-bottom: 120px; /* room for sticky footer */
}

/* ============================================================
   SECTION BASE
   ============================================================ */
.section {
  padding: var(--space-xl) var(--space-md);
}
.section--alt {
  background: var(--color-surface-alt);
}
.section__title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--color-text-main);
  text-align: center;
  margin-bottom: var(--space-md);
  line-height: 1.3;
}
.section__subtitle {
  font-size: var(--font-size-md);
  color: var(--color-text-sub);
  text-align: center;
  margin-bottom: var(--space-lg);
}

/* ============================================================
   HERO SECTION
   ============================================================ */
#hero {
  background: var(--color-primary);
  padding: var(--space-xl) var(--space-md) var(--space-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
}
#hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,0,0,.25) 0%, transparent 60%);
  pointer-events: none;
}
#hero-logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-full);
  border: 3px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.1);
}
#hero-logo-placeholder {
  width: 100px; height: 100px;
  margin: 0 auto var(--space-md);
  border-radius: var(--radius-full);
  background: rgba(255,255,255,.2);
  border: 3px solid rgba(255,255,255,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
}
#hero-headline {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  margin-bottom: var(--space-sm);
  position: relative;
}
#hero-subtext {
  font-size: var(--font-size-lg);
  color: rgba(255,255,255,.9);
  margin-bottom: var(--space-lg);
  position: relative;
}
/* Countdown */
#countdown-wrapper {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.countdown-box {
  background: rgba(0,0,0,.35);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  min-width: 64px;
  text-align: center;
}
.countdown-num {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: #fff;
  line-height: 1;
  display: block;
}
.countdown-label {
  font-size: 11px;
  color: rgba(255,255,255,.7);
}

/* ============================================================
   TRUST BADGES
   ============================================================ */
#trust-badges {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
}
.trust-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-sub);
  background: var(--color-surface-alt);
  border-radius: var(--radius-full);
  padding: 6px 14px;
}
.trust-badge__icon { font-size: 18px; }

/* ============================================================
   IMAGE BLOCK
   ============================================================ */
.image-block {
  width: 100%;
  position: relative;
  overflow: hidden;
  background: var(--color-border);
}
.image-block img {
  width: 100%;
  aspect-ratio: 4 / 5;     /* รูปสัดส่วน 4:5 เต็มความกว้าง */
  display: block;
  object-fit: cover;
}
.image-block--banner { width: 100%; }
.image-block--small  { max-width: 400px; margin: 0 auto; }
.image-block__caption {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-sub);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
}
.image-block__placeholder {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  background: var(--color-surface-alt);
}

/* ============================================================
   PRODUCT SECTION
   ============================================================ */
#products-section {
  padding: var(--space-lg) var(--space-md);
  background: var(--color-surface);
}
#products-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Product Card */
.product-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: box-shadow .2s, transform .2s;
}
.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.product-card--soldout {
  opacity: .6;
  pointer-events: none;
}

/* Badge overlay */
.product-card__badge {
  position: absolute;
  top: 12px; left: 12px;
  background: var(--color-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  z-index: 2;
  letter-spacing: .5px;
}
.product-card__badge--soldout {
  background: #888;
}

/* Image */
.product-card__image-wrap {
  width: 100%;
  aspect-ratio: 4 / 5;     /* รูปสินค้าสัดส่วน 4:5 */
  overflow: hidden;
  background: var(--color-surface-alt);
  position: relative;
}
.product-card__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;       /* เต็มกรอบ 4:5 ไม่มีแถบว่าง */
  display: block;
  transition: transform .3s;
}
.product-card:hover .product-card__image-wrap img { transform: scale(1.04); }
.product-card__img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 56px;
  color: var(--color-border);
}

/* Body */
.product-card__body {
  padding: var(--space-md);
}
.product-card__name {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--color-text-main);
  margin-bottom: 4px;
  line-height: 1.2;
}
.product-card__desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-sub);
  margin-bottom: var(--space-sm);
  line-height: 1.5;
}
.product-card__weight {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
  margin-bottom: var(--space-sm);
}

/* Pricing */
.product-card__pricing {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}
.product-card__price {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}
.product-card__price-original {
  font-size: var(--font-size-md);
  color: var(--color-text-light);
  text-decoration: line-through;
}
.product-card__price-unit {
  font-size: var(--font-size-sm);
  color: var(--color-text-sub);
}

/* Product banner image (above qty-control) */
.product-card__banner {
  margin: var(--space-sm) 0;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
}
.product-card__banner img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;     /* รูปแบนเนอร์สัดส่วน 4:5 */
  object-fit: cover;
  max-width: 100%;
}

/* Quantity control */
.qty-control {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.qty-control__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-sub);
  flex: 1;
}
.qty-buttons {
  display: flex;
  align-items: center;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.qty-btn {
  width: 44px; height: 44px;
  background: transparent;
  border: none;
  font-size: 22px;
  font-weight: 700;
  color: var(--color-primary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  line-height: 1;
}
.qty-btn:hover { background: var(--color-primary); color: #fff; }
.qty-btn:active { opacity: .8; }
.qty-display {
  min-width: 44px;
  text-align: center;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text-main);
}

/* ============================================================
   TEXT BLOCKS (editable content sections)
   ============================================================ */
.text-block {
  padding: var(--space-xl) var(--space-md);
}
.text-block__heading {
  font-size: var(--font-size-xl);
  font-weight: 800;
  margin-bottom: var(--space-md);
  line-height: 1.3;
}
.text-block__body {
  font-size: var(--font-size-md);
  color: var(--color-text-sub);
  line-height: 1.8;
  white-space: pre-line;
}
.text-block__body ul {
  list-style: none;
  padding: 0;
}
.text-block__body ul li::before {
  content: '✅ ';
}
.text-block__body ul li {
  padding: 4px 0;
}
.text-block__image {
  width: 100%;
  aspect-ratio: 4 / 5;     /* รูปสัดส่วน 4:5 */
  display: block;
  border-radius: var(--radius-md);
  object-fit: cover;
  /* responsive: จำกัด max-width บน desktop แต่เต็มจอบน mobile */
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.text-block__image--above { margin-bottom: var(--space-md); }
.text-block__image--below { margin-top: var(--space-md); }
@media (max-width: 480px) {
  .text-block__image {
    max-width: 100%;
    border-radius: var(--radius-sm);
  }
}

/* ============================================================
   ORDER SUMMARY (sticky bottom)
   ============================================================ */
#order-summary {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--color-surface);
  border-top: 3px solid var(--color-primary);
  padding: var(--space-md) var(--space-md) var(--space-sm);
  z-index: 100;
  box-shadow: 0 -4px 24px rgba(0,0,0,.12);
  max-width: var(--page-max-width);
  margin: 0 auto;
}
#order-summary--empty { display: none; }

.order-summary__items {
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: var(--space-sm);
}
.order-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  padding: 2px 0;
  color: var(--color-text-sub);
}
.order-line__name { flex: 1; }
.order-line__price { font-weight: 600; color: var(--color-text-main); }

.order-summary__divider {
  height: 1px; background: var(--color-border);
  margin: var(--space-sm) 0;
}
.order-summary__row {
  display: flex; justify-content: space-between;
  font-size: var(--font-size-sm);
  color: var(--color-text-sub);
  margin-bottom: 2px;
}
.order-summary__total {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--color-text-main);
  margin: var(--space-sm) 0;
}
.order-summary__total-price { color: var(--color-primary); }

/* CTA Button */
#btn-order {
  width: 100%;
  padding: 16px;
  background: var(--color-primary);
  color: #fff;
  font-size: var(--font-size-lg);
  font-weight: 800;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  letter-spacing: .5px;
  transition: background .2s, transform .1s, box-shadow .2s;
  box-shadow: 0 4px 16px rgba(192,57,43,.4);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
#btn-order:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 6px 24px rgba(192,57,43,.5);
  transform: translateY(-1px);
}
#btn-order:active { transform: translateY(0); }
#btn-order:disabled { background: #ccc; box-shadow: none; cursor: not-allowed; }

/* ============================================================
   ORDER MODAL (ฟอร์มก่อนส่ง Messenger)
   ============================================================ */
#order-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
#order-modal-overlay.active { display: flex; }
#order-modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-xl) var(--space-lg);
  width: 100%;
  max-width: var(--page-max-width);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .3s ease;
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal__title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  margin-bottom: var(--space-md);
}
.modal__close {
  float: right; font-size: 24px;
  background: none; border: none;
  cursor: pointer; color: var(--color-text-light);
  line-height: 1;
}
.form-group {
  margin-bottom: var(--space-md);
}
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-main);
  margin-bottom: 6px;
}
.form-label span { color: var(--color-danger); }
.form-input {
  width: 100%;
  padding: 14px 16px;
  font-size: var(--font-size-md);
  font-family: var(--font-main);
  color: var(--color-text-main);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color .2s;
}
.form-input:focus { border-color: var(--color-primary); }
.form-textarea {
  resize: vertical;
  min-height: 80px;
}
.modal__order-summary {
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
}
#btn-send-messenger {
  width: 100%;
  padding: 18px;
  background: #0084ff;
  color: #fff;
  font-size: var(--font-size-lg);
  font-weight: 800;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,132,255,.35);
  transition: background .2s, transform .1s;
}
#btn-send-messenger:hover { background: #006fdb; transform: translateY(-1px); }

/* ============================================================
   FOOTER
   ============================================================ */
#page-footer {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border);
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-center { text-align: center; }
.text-primary { color: var(--color-primary); }
.text-accent  { color: var(--color-accent); }
.fw-bold { font-weight: 700; }
.fw-black { font-weight: 800; }
.hidden { display: none !important; }

/* Pulse animation for CTA */
@keyframes pulse {
  0%,100% { box-shadow: 0 4px 16px rgba(192,57,43,.4); }
  50%      { box-shadow: 0 4px 28px rgba(192,57,43,.7); }
}
.btn-pulse { animation: pulse 2s infinite; }

/* ============================================================
   FLOATING CART WIDGET (bottom-right corner)
   ============================================================ */
#floating-cart {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 150;
  pointer-events: all;
}

/* ---- Tab (ซ่อน) ---- */
#floating-cart__tab { display: none; }

/* ---- Panel (always open, always visible) ---- */
#floating-cart__panel {
  width: 195px;
  background: var(--color-surface);
  border-radius: 16px 16px 0 0;
  box-shadow: -4px -4px 24px rgba(0,0,0,.14);
  overflow: hidden;
  pointer-events: all;
  border: 1.5px solid var(--color-border);
  border-right: none;
  border-bottom: none;
}

/* Panel inner padding */
.fcp-inner {
  padding: 10px 12px 12px;
}

/* Header row */
.fcp-header {
  background: var(--color-primary);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.fcp-title {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  display: flex; align-items: center; gap: 6px;
  flex: 1;
}
.fcp-item-count {
  background: rgba(255,255,255,.25);
  color: #fff;
  font-size: 11px; font-weight: 800;
  padding: 2px 7px;
  border-radius: 100px;
  white-space: nowrap;
}

/* Item lines */
.fcp-items {
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.fcp-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--color-border);
  gap: 6px;
}
.fcp-item:last-child { border-bottom: none; }
.fcp-item__name {
  flex: 1; color: var(--color-text-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fcp-item__qty {
  font-size: 12px; color: var(--color-text-light);
  white-space: nowrap;
}
.fcp-item__price {
  font-size: 13px; font-weight: 700;
  color: var(--color-text-main);
  white-space: nowrap;
}

/* Empty state */
.fcp-empty {
  text-align: center;
  padding: 12px 0;
  color: var(--color-text-light);
  font-size: 13px;
}

/* Divider */
.fcp-divider {
  height: 1px;
  background: var(--color-border);
  margin: 8px 0;
}

/* Subtotal / shipping rows */
.fcp-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-sub);
  margin-bottom: 4px;
}
.fcp-row__label { }
.fcp-row__value { font-weight: 600; color: var(--color-text-main); }
.fcp-row--free .fcp-row__value { color: var(--color-success); font-weight: 800; }
.fcp-row--total {
  font-size: 16px;
  font-weight: 800;
  color: var(--color-text-main);
  margin-top: 4px;
  margin-bottom: 0;
}
.fcp-row--total .fcp-row__value { color: var(--color-primary); }

/* Free shipping progress */
.fcp-freeship {
  margin: 10px 0 8px;
  background: var(--color-surface-alt);
  border-radius: 10px;
  padding: 8px 10px;
}
.fcp-freeship__text {
  font-size: 12px;
  color: var(--color-text-sub);
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 4px;
}
.fcp-freeship__text b { color: var(--color-primary); }
.fcp-freeship__text--done {
  color: var(--color-success);
  font-weight: 700;
}
.fcp-progress-track {
  height: 6px;
  background: var(--color-border);
  border-radius: 100px;
  overflow: hidden;
}
.fcp-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: 100px;
  transition: width .4s ease;
  min-width: 4px;
}

/* CTA button inside panel */
.fcp-cta {
  width: 100%;
  padding: 12px;
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s;
  font-family: var(--font-main);
  margin-top: 10px;
}
.fcp-cta:hover { background: var(--color-primary-hover); }
.fcp-cta:disabled {
  background: var(--color-border);
  color: var(--color-text-light);
  cursor: not-allowed;
}

/* Bounce animation when item added */
@keyframes cartBounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.08); }
  60%  { transform: scale(.97); }
  100% { transform: scale(1); }
}
#floating-cart.bounce {
  transform-origin: bottom right;
  animation: cartBounce .35s ease;
}

