/*
 * หน้าแปลงเป็นโมเดล 3D (model3d.html)
 * โหลดต่อจาก upscale.css (สี ฟอนต์ แถบบน ปุ่ม กล่องสมัคร เครดิต ไฟล์ของฉัน) และ design.css (โครงสองคอลัมน์ หัวขั้น ผลงาน)
 * ไฟล์นี้มีแค่ส่วนของหน้านี้: การ์ดเลือกชนิดภาพ ที่วางภาพในฟอร์ม และตัวแสดงโมเดล
 */

/* ชนิดภาพ: การ์ดสองใบ เลือกได้ใบเดียว (radio + label แบบ .presets) */
.m3-sources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; clear: both; }
.m3-sources input { position: absolute; opacity: 0; pointer-events: none; }
.m3-sources label {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-content: start;
  min-height: 92px; margin: 0; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2);
  transition: border-color .18s var(--ease), background-color .18s var(--ease);
}
.m3-sources label .ic { grid-row: span 2; width: 26px; height: 26px; margin-top: 2px; color: var(--muted); }
.m3-sources label b { font-size: 15.5px; font-weight: 600; }
.m3-sources label small { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.m3-sources label:hover { border-color: var(--line-strong); }
.m3-sources input:checked + label { border-color: var(--pink); background: var(--pink-soft); }
.m3-sources input:checked + label .ic { color: var(--pink); }
.m3-sources input:focus-visible + label { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ที่วางภาพในฟอร์ม: เตี้ยกว่าหน้าขยายภาพ (ฟอร์มมีหลายขั้น) */
.m3-drop { min-height: 190px; clear: both; }
.m3-drop img { max-height: 280px; }
.m3-drop:has(#thumb:not([hidden])) { background: #f4f1ed; }
.m3-drop:has(#thumb:not([hidden])) img { box-shadow: none; }
.dz-form .hint { margin: 10px 0 0; }

.m3-size { grid-template-columns: repeat(2, minmax(0, 1fr)); clear: both; }
.m3-size .opt { color: var(--muted); font-weight: 400; }

/* ยังไม่สั่ง */
.m3-empty { min-height: 300px; align-content: center; }
.m3-empty-ic { width: 72px; height: 72px; color: var(--line-strong); stroke-width: 1.2; }

/* เสร็จแล้ว: ตัวแสดงโมเดล + ข้อมูล + ปุ่มโหลด */
.m3-done .done-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; }
.m3-done h3 { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 20px; color: var(--green); }
.m3-done .done-head h3 span { color: inherit; font-size: inherit; }
.m3-done h3 .ic { width: 20px; height: 20px; stroke-width: 2.2; }
.m3-done .done-head span { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }

.m3-view { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-sm); background: #dfe5ea; }
.m3-view #viewer-slot, .m3-view model-viewer {
  display: block; width: 100%; height: clamp(300px, 52vh, 520px);
  --poster-color: transparent; --progress-bar-color: var(--pink);
}
.m3-view-tip {
  position: absolute; left: 10px; bottom: 8px; margin: 0; padding: 3px 9px; border-radius: 999px;
  background: rgba(8, 10, 11, .62); color: var(--bone); font-size: 12px; pointer-events: none;
}

.m3-facts { display: grid; gap: 6px; margin: 14px 0 0; }
.m3-facts div { display: grid; grid-template-columns: minmax(118px, auto) minmax(0, 1fr); gap: 12px; font-size: 14px; }
.m3-facts dt { color: var(--muted); }
.m3-facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.m3-dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 16px; align-items: stretch; }
.m3-dl .go, .m3-dl .ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin: 0; min-height: 50px; }
.m3-dl .ic { width: 18px; height: 18px; }
.m3-dl .fine, .m3-dl .dl-status { grid-column: 1 / -1; margin: 0; }
.m3-done > .warn { margin-top: 14px; }
.m3-done > .ghost { margin-top: 14px; }

@media (max-width: 600px) {
  .m3-sources { grid-template-columns: minmax(0, 1fr); }
  .m3-sources label { min-height: 0; }
  .m3-size { grid-template-columns: minmax(0, 1fr); }
  .m3-dl { grid-template-columns: minmax(0, 1fr); }
  .m3-facts div { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

/* ตัวอย่างก่อน/หลัง (เจ้าของสั่ง 10 พ.ย. 2569) · การ์ดละงาน ภาพก่อนซ้าย หลังขวา กดหมุนดูแทนภาพหลังด้วย model-viewer */
.ex { padding: 40px 0 8px; }
.ex-head h2 { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.ex-head p { margin: 0 0 18px; color: var(--muted); max-width: 70ch; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.ex-card { display: grid; gap: 10px; align-content: start; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.ex-card h3 { margin: 0; font-size: 17px; font-weight: 600; }
.ex-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ex-pair figure { margin: 0; display: grid; gap: 6px; align-content: start; }
.ex-pair img, .ex-pair model-viewer { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; border-radius: var(--r-sm); background: #f2f3f5; display: block; }
.ex-pair model-viewer { height: auto; --poster-color: #f2f3f5; }
.ex-pair figcaption { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.ex-after figcaption { color: var(--pink); }
.ex-facts { margin: 0; font-size: 13.5px; line-height: 1.6; }
.ex-spin { justify-self: start; display: inline-flex; align-items: center; gap: 8px; }
.ex-spin .ic { width: 18px; height: 18px; }
.ex-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.m3-alt { margin: 6px 0 0; color: var(--muted); }
.m3-alt a, .ex-note a { color: var(--cyan); }
@media (max-width: 560px) { .ex-card { padding: 12px; } }

/* เต็มจอ: โมเดลเต็มพื้นที่ แถบชื่อ + ปิดด้านบน ภาพต้นฉบับเล็กมุมซ้ายบน */
.ex-after { cursor: zoom-in; }
.ex-after:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: var(--r-sm); }
.ex-full { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: linear-gradient(#f7f8fa, #e4e7ec); color: #16181d; overflow: hidden; }
.ex-full::backdrop { background: rgba(0, 0, 0, .7); }
.ex-full-stage, .ex-full-stage model-viewer { position: absolute; inset: 0; width: 100%; height: 100%; }
.ex-full-stage model-viewer { --poster-color: transparent; background: transparent; }
.ex-full-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; pointer-events: none; }
.ex-full-bar h2 { margin: 0; font-size: 18px; font-weight: 600; }
.ex-full-close { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15);
  background: #fff; color: #16181d; font-size: 18px; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.ex-full-close:hover { background: #f1f2f4; }
.ex-full-close:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.ex-full-orig { position: absolute; top: 64px; left: 16px; margin: 0; width: clamp(120px, 22vw, 300px); padding: 6px;
  background: #fff; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.ex-full-orig img { display: block; width: 100%; height: auto; max-height: 34vh; object-fit: contain; border-radius: 6px; }
.ex-full-orig figcaption { margin-top: 4px; font-size: 12px; color: #5b616e; text-align: center; }
.ex-full-tip { position: absolute; bottom: 14px; left: 0; right: 0; margin: 0; text-align: center; font-size: 13px; color: #5b616e; pointer-events: none; }
@media (max-width: 560px) { .ex-full-orig { width: 34vw; top: 60px; } .ex-full-bar h2 { font-size: 16px; } }

/* ภาพด้านอื่น (หลายด้าน): ช่องเล็กห้าช่อง ด้านละภาพ ไม่บังคับ */
.group .step-h .opt { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.m3-views { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; clear: both; }
.m3-side { position: relative; }
.m3-side-pick { display: grid; place-items: center; align-content: center; gap: 4px; aspect-ratio: 1; margin: 0; padding: 6px; cursor: pointer;
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm); background: var(--panel-2); text-align: center; overflow: hidden;
  transition: border-color .18s var(--ease), background-color .18s var(--ease); }
.m3-side-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.m3-side-pick b { font-size: 12px; font-weight: 500; color: var(--muted); }
.m3-side-plus { font-size: 20px; line-height: 1; color: var(--muted); }
.m3-side-pick:hover, .m3-side.over .m3-side-pick { border-color: var(--pink); }
.m3-side-pick:focus-within { outline: 2px solid var(--cyan); outline-offset: 2px; }
.m3-side.has .m3-side-pick { border-style: solid; border-color: var(--pink); background: #f4f1ed; padding: 0; }
.m3-side.has .m3-side-pick img { width: 100%; height: 100%; object-fit: cover; }
.m3-side.has .m3-side-plus { display: none; }
.m3-side.has .m3-side-pick b { position: absolute; left: 4px; bottom: 4px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; }
.m3-side-del { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--pink); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer; }
@media (max-width: 560px) { .m3-views { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ยินยอมให้แสดงผลงานบนเว็บ (กล่อง .share ใช้ของ upscale.css) · ผลงานจากลูกค้าใช้การ์ด .ex-card ชุดเดียวกับตัวอย่าง */
.m3-done .share { margin: 16px 0 0; }
.m3-done .share.sent > .fine:not([role="status"]) { display: none; }
.m3-done .shared-note { margin: 12px 0 0; }
#customer-work .ex-pair figure:not(.ex-after) img { cursor: default; }
