/* ═══════════════════════════════════════════════════════════
   Commerce Studio — Binary Mode (Easy/Advanced) + Accordion
   ใช้โทน Dark + Indigo (#6366f1) Active เพื่อกลมกลืนกับธีม
═══════════════════════════════════════════════════════════ */

:root{
  --cm-bg:#0f172a;          /* navy/dark slate */
  --cm-bg-2:#111827;
  --cm-line:rgba(148,163,184,.18);
  --cm-text:#e2e8f0;
  --cm-muted:rgba(148,163,184,.6);
  --cm-indigo:#6366f1;
  --cm-indigo-2:#818cf8;
  --cm-emerald:#10b981;
  --cm-emerald-2:#22c55e;
}

/* ─── Mode Toggle — Inline ใน hero button-row ─── */
.cm-mode-switch{
  display:inline-flex;
  background:rgba(15,23,42,.85);
  border:1px solid var(--cm-line);
  border-radius:14px;
  padding:5px;
  height:48px;          /* ตรงกับ .btn height */
  position:relative;
  isolation:isolate;
  box-shadow:0 8px 22px rgba(0,0,0,.32);
  flex-shrink:0;
}
.cm-mode-switch::before{
  content:'';position:absolute;top:5px;left:5px;
  width:calc(50% - 5px);height:calc(100% - 10px);
  background:linear-gradient(135deg,var(--cm-indigo),var(--cm-indigo-2));
  border-radius:9px;
  transition:transform .32s cubic-bezier(.34,1.4,.64,1);
  box-shadow:
    0 4px 14px rgba(99,102,241,.45),
    0 0 0 1px rgba(255,255,255,.06) inset;
  z-index:-1;
}
body.cm-advanced .cm-mode-switch::before{
  transform:translateX(100%);
}
.cm-mode-btn{
  background:transparent;border:none;
  padding:0 18px;
  font-size:13.5px;font-weight:600;letter-spacing:-.01em;
  color:rgba(148,163,184,.7);
  cursor:pointer;font-family:inherit;
  border-radius:9px;
  transition:color .22s;
  display:inline-flex;align-items:center;gap:7px;
  position:relative;z-index:1;
  min-width:118px;justify-content:center;
  height:38px;
  white-space:nowrap;
}
.cm-mode-btn.active{color:#fff}
.cm-mode-btn:hover:not(.active){color:rgba(226,232,240,.95)}
.cm-mode-btn svg{
  width:16px;height:16px;
  fill:none;stroke:currentColor;stroke-width:1.8;
  stroke-linecap:round;stroke-linejoin:round;
  flex-shrink:0;
  transition:transform .25s;
}
.cm-mode-btn.active svg{transform:scale(1.1)}

/* ─── Easy Mode: ซ่อน step 3,4,5 ─── */
body.cm-easy .section[data-cm-step="3"],
body.cm-easy .section[data-cm-step="4"],
body.cm-easy .section[data-cm-step="5"]{display:none!important}
body.cm-easy .data-divider.cm-advanced-divider{display:none}

/* ─── Section Step ─── */
.section[data-cm-step]{
  scroll-margin-top:120px;
  transition:opacity .3s, transform .3s, border-color .3s, box-shadow .3s;
}

/* ─── Accordion: Collapsed state ─── */
.section.cm-collapsed{
  padding:0;
  cursor:pointer;
  background:linear-gradient(180deg,rgba(15,23,42,.6),rgba(17,24,39,.5));
  border:1px solid rgba(99,102,241,.15);
  transition:all .3s ease;
}
.section.cm-collapsed:hover{
  background:linear-gradient(180deg,rgba(30,41,59,.7),rgba(15,23,42,.6));
  border-color:rgba(99,102,241,.4);
  transform:translateY(-1px);
  box-shadow:0 8px 24px rgba(0,0,0,.28);
}
.section.cm-collapsed > *:not(.cm-collapsed-bar){
  display:none!important;
}

.cm-collapsed-bar{
  display:none;
  align-items:center;gap:14px;
  padding:14px 22px;
  cursor:pointer;
  border-radius:24px;
}
.section.cm-collapsed .cm-collapsed-bar{display:flex!important}

.cm-collapsed-icon{
  width:34px;height:34px;border-radius:10px;
  background:linear-gradient(135deg,var(--cm-emerald),var(--cm-emerald-2));
  display:grid;place-items:center;
  color:#fff;font-weight:800;font-size:14px;
  box-shadow:0 4px 12px rgba(16,185,129,.35);
  flex-shrink:0;
}
.cm-collapsed-info{flex:1;min-width:0}
.cm-collapsed-title{
  font-size:14.5px;font-weight:650;color:#fff;
  margin:0;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.cm-collapsed-summary{
  font-size:12px;color:var(--cm-muted);
  margin-top:2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.cm-collapsed-edit{
  font-size:12px;color:var(--cm-indigo-2);font-weight:600;
  background:rgba(99,102,241,.12);
  border:1px solid rgba(99,102,241,.3);
  padding:6px 12px;border-radius:999px;
  white-space:nowrap;
  display:inline-flex;align-items:center;gap:5px;
  transition:all .2s;
}
.cm-collapsed-edit svg{
  width:13px;height:13px;
  fill:none;stroke:currentColor;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round;
}
.section.cm-collapsed:hover .cm-collapsed-edit{
  background:rgba(99,102,241,.25);
  border-color:rgba(99,102,241,.5);
}

/* ─── Active section (currently editing) ─── */
.section.cm-active{
  border-color:rgba(99,102,241,.4);
  box-shadow:
    0 22px 70px rgba(99,102,241,.16),
    0 0 0 1px rgba(99,102,241,.18) inset;
  position:relative;
}
.section.cm-active::before{
  content:'';position:absolute;
  top:-1px;left:24px;height:3px;width:60px;
  background:linear-gradient(90deg,var(--cm-indigo),var(--cm-indigo-2));
  border-radius:0 0 6px 6px;
  box-shadow:0 0 16px rgba(99,102,241,.5);
}

/* ─── Status Badge ─── */
.cm-status-badge{
  display:inline-flex;align-items:center;gap:5px;
  font-size:11px;font-weight:700;
  padding:4px 10px;border-radius:999px;
  margin-left:10px;
  vertical-align:middle;
}
.cm-status-badge.completed{
  background:rgba(16,185,129,.15);color:var(--cm-emerald-2);
  border:1px solid rgba(16,185,129,.35);
}
.cm-status-badge svg{
  width:12px;height:12px;
  fill:none;stroke:currentColor;stroke-width:2.5;
  stroke-linecap:round;stroke-linejoin:round;
}

/* ─── Step actions (Done & Continue) ─── */
.cm-step-actions{
  display:flex;justify-content:flex-end;gap:10px;
  margin-top:22px;padding-top:18px;
  border-top:1px solid rgba(148,163,184,.10);
}
body.cm-easy .cm-step-actions{display:none}
.cm-done-btn{
  background:linear-gradient(135deg,var(--cm-emerald),var(--cm-emerald-2));
  color:#fff;border:none;
  padding:11px 22px;border-radius:12px;
  font-size:13.5px;font-weight:700;cursor:pointer;
  font-family:inherit;
  display:inline-flex;align-items:center;gap:8px;
  box-shadow:0 8px 22px rgba(16,185,129,.32);
  transition:all .25s;
}
.cm-done-btn svg{
  width:16px;height:16px;
  fill:none;stroke:currentColor;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round;
}
.cm-done-btn:hover{
  transform:translateY(-2px);
  box-shadow:0 12px 28px rgba(16,185,129,.45);
}
.cm-done-btn:active{transform:translateY(0)}
.cm-done-btn.is-final{
  background:linear-gradient(135deg,var(--cm-indigo),var(--cm-indigo-2));
  box-shadow:0 8px 22px rgba(99,102,241,.4);
}
.cm-done-btn.is-final:hover{box-shadow:0 12px 28px rgba(99,102,241,.55)}

.cm-skip-btn{
  background:rgba(148,163,184,.08);
  border:1px solid rgba(148,163,184,.18);
  color:rgba(226,232,240,.7);
  padding:11px 18px;border-radius:12px;
  font-size:13px;font-weight:600;cursor:pointer;
  font-family:inherit;
  transition:all .2s;
}
.cm-skip-btn:hover{
  background:rgba(148,163,184,.15);
  color:#fff;
}

/* ─── Progress dots ─── */
.cm-progress-bar{
  display:none;
  align-items:center;gap:6px;
  margin:0 4px 16px;
}
body.cm-advanced .cm-progress-bar{display:flex}
.cm-progress-dot{
  flex:1;height:4px;border-radius:999px;
  background:rgba(148,163,184,.15);
  position:relative;overflow:hidden;
  transition:background .3s;
}
.cm-progress-dot.done{background:linear-gradient(90deg,var(--cm-emerald),var(--cm-emerald-2))}
.cm-progress-dot.active{background:linear-gradient(90deg,var(--cm-indigo),var(--cm-indigo-2))}
.cm-progress-dot.active::after{
  content:'';position:absolute;inset:0;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.4),transparent);
  animation:cmProgressShine 1.8s linear infinite;
}
@keyframes cmProgressShine{
  0%{transform:translateX(-100%)}
  100%{transform:translateX(100%)}
}

/* ─── Slide-in animation ─── */
.section[data-cm-step]:not(.cm-collapsed){
  animation:cmSlideIn .4s cubic-bezier(.4,0,.2,1);
}
@keyframes cmSlideIn{
  from{opacity:0;transform:translateY(8px)}
  to{opacity:1;transform:translateY(0)}
}

/* ─── Easy mode hint (inline ใน hero — แสดงด้านล่าง toggle) ─── */
.cm-easy-hero{
  display:none;
  background:linear-gradient(135deg,rgba(99,102,241,.12),rgba(16,185,129,.05));
  border:1px solid rgba(99,102,241,.22);
  border-radius:14px;
  padding:14px 18px;
  margin-top:14px;
  align-items:center;gap:14px;
  text-align:left;
  max-width:680px;
}
body.cm-easy .cm-easy-hero{display:flex}
.cm-easy-hero-icon{
  width:38px;height:38px;border-radius:11px;
  background:linear-gradient(135deg,var(--cm-indigo),var(--cm-indigo-2));
  display:grid;place-items:center;color:#fff;
  flex-shrink:0;
}
.cm-easy-hero-icon svg{
  width:18px;height:18px;
  fill:none;stroke:currentColor;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round;
}
.cm-easy-hero-text{flex:1;font-size:13px;line-height:1.5;color:rgba(226,232,240,.9)}
.cm-easy-hero-text b{color:var(--cm-indigo-2);font-weight:700}
.cm-easy-hero-text small{display:block;font-size:11.5px;color:rgba(148,163,184,.7);margin-top:2px}

/* ────────────────────────────────────────
   🎯 ซ่อนสิ่งที่ไม่ใช้ใน Easy Mode
──────────────────────────────────────── */

/* Flow nodes ที่อยู่ใน step 3,4,5 — ซ่อนตอน Easy mode */
body.cm-easy .flow-node[data-cm-flow="hidden"]{display:none!important}

/* Data divider: ซ่อน divider ที่อยู่ติดกับ section ที่ถูกซ่อน/พับ */
body.cm-easy .data-divider[data-cm-divider-hidden="1"]{display:none!important}
body.cm-advanced .data-divider[data-cm-divider-collapsed="1"]{display:none!important}

/* ────────────────────────────────────────
   📱 Mobile Responsive (≤768px)
──────────────────────────────────────── */
@media(max-width:768px){
  /* Toggle เต็มความกว้าง อยู่ตรงกลาง */
  .cm-mode-switch{
    width:100%;
    max-width:340px;
    margin:0 auto;
  }
  .cm-mode-btn{
    flex:1;
    min-width:0;
    padding:0 12px;
    font-size:13px;
  }
  .cm-easy-hero{margin-top:12px;padding:12px 14px;gap:10px}
  .cm-easy-hero-icon{width:34px;height:34px}
  .cm-easy-hero-text{font-size:12.5px}

  /* Step actions — column on mobile */
  .cm-step-actions{flex-direction:column-reverse;gap:8px}
  .cm-done-btn,.cm-skip-btn{width:100%;justify-content:center;padding:14px 18px}

  /* Collapsed bar compact */
  .cm-collapsed-bar{padding:12px 14px;gap:10px}
  .cm-collapsed-title{font-size:13px}
  .cm-collapsed-summary{font-size:11px}
  .cm-collapsed-edit{font-size:11px;padding:5px 9px}

  /* 🎯 Section title: บีบให้พอดี 1-2 บรรทัด */
  .section[data-cm-step] .section-title{
    font-size:19px!important;
    line-height:1.25!important;
    font-weight:650!important;
    letter-spacing:-.02em!important;
  }
  .section[data-cm-step]{padding:18px 16px!important}
  .section-head{margin-bottom:14px!important;gap:10px!important}
  .section-head .btn,.section-head .btn-premium{
    font-size:12px!important;padding:8px 12px!important;height:36px!important;
  }
}

@media(max-width:480px){
  .cm-mode-btn{font-size:12.5px;padding:0 8px;gap:4px}
  .cm-mode-btn svg{width:14px;height:14px}
  .section[data-cm-step] .section-title{
    font-size:17px!important;
  }
}

/* ────────────────────────────────────────
   🧹 Emoji → SVG icon swap helper class
   (ปุ่มที่ใส่ class="cm-icon-{name}" จะได้ SVG inline)
──────────────────────────────────────── */
.cm-line-icon{
  width:15px;height:15px;
  fill:none;stroke:currentColor;stroke-width:1.9;
  stroke-linecap:round;stroke-linejoin:round;
  vertical-align:-2px;margin-right:6px;
  flex-shrink:0;
}
.btn .cm-line-icon{margin-right:6px}
