/* Maya Care Labs — แบบสำรวจข้อมูลสินค้า OEM (/oem/)
   ต่อยอดตัวแปรสี/ฟอนต์จาก /styles.css (โหลดก่อนไฟล์นี้)
   ออกแบบ mobile-first: ปุ่มตัวเลือกใหญ่ กดง่ายด้วยนิ้วโป้ง พิมพ์น้อยที่สุด */

.oem-body { background: var(--cream-2); }

/* JS ซ่อน/แสดงปุ่มด้วย .hidden = true — ต้องชนะ display:flex/inline-flex ด้านล่าง
   ไม่งั้นปุ่ม "ย้อนกลับ"/"ส่งข้อมูล" จะโผล่ตั้งแต่ขั้นแรก (UA stylesheet แพ้ author rule) */
.oem-wrap [hidden] { display: none !important; }

.oem-main { padding: 1.6rem 0 7.5rem; }        /* เผื่อที่ให้แถบปุ่มลอยด้านล่าง */
.oem-wrap { max-width: 720px; }

/* ---------- หัวเรื่อง ---------- */
.oem-head { text-align: center; margin-bottom: 1.4rem; }
.oem-head h1 { font-size: clamp(1.55rem, 6vw, 2.3rem); margin-bottom: 0.5rem; }
.oem-head .hl { color: var(--emerald); }
.oem-sub { color: var(--ink-soft); font-size: 0.95rem; margin: 0 auto; max-width: 34rem; }

/* ---------- แถบความคืบหน้า ---------- */
.oem-progress {
  position: sticky; top: 72px; z-index: 20;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0 0.85rem;
  background: linear-gradient(var(--cream-2) 82%, rgba(255, 245, 250, 0));
}
.oem-progress-bar {
  flex: 1; height: 8px; border-radius: 999px;
  background: var(--sage); overflow: hidden;
}
.oem-progress-bar span {
  display: block; height: 100%; width: 14%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--emerald-mid), var(--emerald-deep));
  transition: width 0.35s ease;
}
.oem-progress-text { font-size: 0.85rem; font-weight: 600; color: var(--emerald-deep); white-space: nowrap; }

/* ---------- การ์ดของแต่ละขั้น ---------- */
.oem-form { position: relative; }
.oem-step { display: none; animation: oemIn 0.28s ease; }
.oem-step.is-on { display: block; }
@keyframes oemIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.oem-step-title {
  display: flex; align-items: center; gap: 0.55rem;
  font-size: 1.22rem; color: var(--emerald-deep); margin-bottom: 0.9rem;
}
.oem-step-ic { font-size: 1.4rem; line-height: 1; }
.oem-note {
  background: var(--cream); border-radius: 14px; padding: 0.7rem 0.9rem;
  font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 1rem;
}

/* ---------- คำถาม 1 ข้อ ---------- */
.q {
  border: 0; margin: 0 0 1.1rem; padding: 1rem 1rem 1.1rem;
  background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.q legend {
  padding: 0; margin-bottom: 0.75rem;
  font-weight: 600; font-size: 1rem; color: var(--ink);
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.q-hint {
  font-weight: 400; font-size: 0.76rem; color: var(--ink-soft);
  background: var(--cream); border-radius: 999px; padding: 0.12rem 0.6rem;
}
.q-req {
  font-weight: 600; font-size: 0.74rem; color: #fff;
  background: var(--emerald); border-radius: 999px; padding: 0.12rem 0.6rem;
}

/* ---------- ปุ่มตัวเลือก (chip) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  font-family: inherit; font-size: 0.95rem; font-weight: 500; color: var(--ink);
  min-height: 46px; padding: 0.55rem 1rem;
  background: var(--cream-2); border: 1.5px solid rgba(160, 30, 100, 0.16);
  border-radius: 999px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--gold-soft); }
.chip:active { transform: scale(0.97); }
.chip:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 2px; }
.chip.is-on {
  background: linear-gradient(135deg, var(--emerald-mid), var(--emerald-deep));
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 6px 16px rgba(216, 27, 122, 0.28);
}
.chip.is-on::before { content: "✓ "; }
.chips-sm .chip { font-size: 0.9rem; padding: 0.5rem 0.9rem; }

/* ---------- ช่องพิมพ์ ---------- */
.q-text, .q-other {
  font-family: inherit; font-size: 1rem; color: var(--ink);
  width: 100%; min-height: 50px; padding: 0.7rem 0.9rem;
  background: var(--cream-2); border: 1.5px solid rgba(160, 30, 100, 0.16);
  border-radius: 14px; margin-top: 0.6rem;
}
.q-text::placeholder, .q-other::placeholder { color: #b892a5; }
.q-text:focus, .q-other:focus {
  outline: none; border-color: var(--emerald); background: var(--paper);
  box-shadow: 0 0 0 3px rgba(224, 33, 138, 0.12);
}
.q-other { font-size: 0.92rem; }
textarea.q-text { min-height: 76px; resize: vertical; line-height: 1.5; }
.q-text.is-bad { border-color: #e11d48; background: #fff1f4; }

/* honeypot — คนจริงต้องมองไม่เห็นและโฟกัสไม่โดน */
.oem-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- แถบปุ่มด้านล่าง ---------- */
.oem-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 0.6rem; align-items: center;
  padding: 0.7rem max(1.2rem, calc((100vw - var(--maxw)) / 2)) calc(0.7rem + env(safe-area-inset-bottom));
  background: rgba(255, 245, 250, 0.95);
  backdrop-filter: saturate(140%) blur(10px);
  border-top: 1px solid rgba(120, 20, 70, 0.09);
}
.oem-btn {
  font-family: inherit; font-size: 1rem; font-weight: 600;
  min-height: 52px; padding: 0.75rem 1.3rem;
  border: 0; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
}
.oem-btn:active { transform: scale(0.98); }
.oem-btn-back {
  background: var(--paper); color: var(--emerald-deep);
  border: 1.5px solid rgba(160, 30, 100, 0.2); flex: 0 0 auto;
}
.oem-btn-next, .oem-btn-send {
  flex: 1; color: #fff;
  background: linear-gradient(135deg, var(--emerald-mid), var(--emerald-deep));
  box-shadow: 0 10px 24px rgba(216, 27, 122, 0.3);
}
.oem-btn-send { background: linear-gradient(135deg, #10b981, #047857); box-shadow: 0 10px 24px rgba(4, 120, 87, 0.28); }
.oem-btn[disabled] { opacity: 0.6; cursor: progress; }

.oem-hint { text-align: center; font-size: 0.85rem; color: var(--ink-soft); margin: 0.9rem 0 0; }
.oem-err {
  margin: 0.8rem 0 0; padding: 0.7rem 0.9rem; border-radius: 12px;
  background: #fff1f4; color: #be123c; font-size: 0.92rem; font-weight: 500;
}

/* ---------- สรุปคำตอบก่อนส่ง (modal) ---------- */
.oem-modal {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(58, 31, 46, 0.45);
  backdrop-filter: blur(2px);
  animation: oemFade 0.2s ease;
}
@keyframes oemFade { from { opacity: 0; } to { opacity: 1; } }
.oem-modal-box {
  width: min(100%, 620px); max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--cream-2);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg);
  animation: oemUp 0.28s ease;
}
@keyframes oemUp { from { transform: translateY(18px); } to { transform: none; } }
.oem-modal-head {
  padding: 1.1rem 1.1rem 0.8rem;
  border-bottom: 1px solid rgba(120, 20, 70, 0.09);
}
.oem-modal-head h2 { font-size: 1.15rem; color: var(--emerald-deep); margin-bottom: 0.25rem; }
.oem-modal-sub { font-size: 0.85rem; color: var(--ink-soft); margin: 0; }

.oem-summary { flex: 1; overflow-y: auto; padding: 0.9rem 1.1rem 0.4rem; -webkit-overflow-scrolling: touch; }
.oem-sum-group {
  background: var(--paper); border-radius: 16px;
  padding: 0.8rem 0.9rem; margin-bottom: 0.7rem;
  box-shadow: var(--shadow-sm);
}
.oem-sum-group.is-key { border: 1.5px solid var(--gold-soft); }
.oem-sum-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  margin-bottom: 0.55rem;
}
.oem-sum-title { font-weight: 600; font-size: 0.95rem; color: var(--emerald-deep); }
.oem-sum-edit {
  font-family: inherit; font-size: 0.82rem; font-weight: 600; color: var(--emerald);
  background: var(--cream); border: 0; border-radius: 999px;
  min-height: 34px; padding: 0.3rem 0.85rem; cursor: pointer; white-space: nowrap;
}
.oem-sum-edit:active { transform: scale(0.97); }
.oem-sum-row { display: flex; gap: 0.6rem; padding: 0.32rem 0; font-size: 0.9rem; }
.oem-sum-row + .oem-sum-row { border-top: 1px dashed rgba(120, 20, 70, 0.1); }
.oem-sum-label { flex: 0 0 38%; color: var(--ink-soft); }
.oem-sum-value { flex: 1; font-weight: 500; word-break: break-word; }
.oem-sum-empty { text-align: center; color: var(--ink-soft); font-size: 0.9rem; padding: 1rem 0; }

.oem-modal-actions {
  display: flex; gap: 0.6rem;
  padding: 0.8rem 1.1rem calc(0.9rem + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(120, 20, 70, 0.09);
  background: rgba(255, 245, 250, 0.96);
}
.oem-modal-actions .oem-btn-ghost { flex: 0 0 auto; }
.oem-modal-actions .oem-btn-send { flex: 1; }
.oem-modal .oem-err { margin: 0 1.1rem; }
body.oem-locked { overflow: hidden; }

@media (min-width: 620px) {
  .oem-modal { align-items: center; }
  .oem-modal-box { border-radius: 24px; }
}

/* ---------- หน้าจอหลังส่งสำเร็จ ---------- */
.oem-done { text-align: center; padding: 2rem 1rem 1rem; }
.oem-done-ic { font-size: 3.4rem; line-height: 1; margin-bottom: 0.6rem; }
.oem-done h2 { color: var(--emerald-deep); font-size: 1.5rem; }
.oem-done p { color: var(--ink-soft); max-width: 30rem; margin-inline: auto; }
.oem-done-ref { font-weight: 600; color: var(--emerald-deep) !important; }
.oem-done-cta { display: flex; flex-direction: column; gap: 0.7rem; max-width: 22rem; margin: 1.4rem auto 1rem; }
.oem-btn-line { background: var(--line-green); color: #fff; }
.oem-btn-ghost { background: var(--paper); color: var(--emerald-deep); border: 1.5px solid rgba(160, 30, 100, 0.2); }
.oem-done-home { color: var(--ink-soft); font-size: 0.92rem; text-decoration: underline; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 560px) {
  .oem-main { padding-top: 1.1rem; }
  .q { padding: 0.9rem 0.85rem 1rem; border-radius: 16px; }
  .chip { font-size: 0.92rem; padding: 0.55rem 0.85rem; }
  .oem-progress { top: 64px; }
  .oem-btn { font-size: 0.97rem; padding: 0.7rem 1rem; }
  .oem-btn-back { padding-inline: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  .oem-step { animation: none; }
  .oem-progress-bar span { transition: none; }
}
