/* ═══════════════════════════════════════════════════════
   CraftyWorth Customize Window
   Amazon-like customization UX on product page
═══════════════════════════════════════════════════════ */

/* Wrapper around trigger + expand */
.cwv2-cust-shell{
  margin:14px 0 18px;
}

/* Trigger card */
.cwv2-cust-trigger{
  border:2px solid var(--cw-accent,#E8651A);
  border-radius:14px;
  padding:16px 18px;
  background:linear-gradient(135deg,#fffbf7,#fff);
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:14px;
  transition:border-color .18s,box-shadow .18s,border-radius .2s;
  position:relative;
  user-select:none;
}
.cwv2-cust-trigger:hover{
  border-color:var(--cw-primary,#A0293E);
  box-shadow:0 4px 20px rgba(160,41,62,.12);
}
.cwv2-cust-trigger:focus-visible{
  outline:2px solid var(--cw-primary,#A0293E);
  outline-offset:2px;
}
.cwv2-cust-trigger.is-open{
  border-color:var(--cw-primary,#A0293E);
  background:linear-gradient(135deg,#fff5f5,#fff);
  border-radius:14px 14px 0 0;
  border-bottom-color:transparent;
}
.cwv2-cust-trigger__thumb{
  width:52px;height:52px;
  border-radius:8px;
  overflow:hidden;
  flex-shrink:0;
  background:var(--cw-surface,#FEF7F0);
  border:1px solid var(--cw-line,#EAD9CC);
  display:flex;align-items:center;justify-content:center;
}
.cwv2-cust-trigger__thumb img{width:100%;height:100%;object-fit:cover;display:block;}
.cwv2-cust-trigger__body{flex:1;min-width:0;}
.cwv2-cust-trigger__title{
  font-size:14px;font-weight:700;
  color:var(--cw-ink,#1A1A1A);
  display:block;margin-bottom:3px;
  line-height:1.25;
}
.cwv2-cust-trigger__sub{
  font-size:12px;color:var(--cw-ink-3,#888);
  line-height:1.4;
  display:block;
}
.cwv2-cust-trigger__arrow{
  width:32px;height:32px;
  border-radius:50%;
  background:var(--cw-accent,#E8651A);
  color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-size:16px;
  flex-shrink:0;
  transition:transform .22s ease,background .18s;
}
.cwv2-cust-trigger.is-open .cwv2-cust-trigger__arrow{
  transform:rotate(180deg);
  background:var(--cw-primary,#A0293E);
}

/* Expand section — collapsed by default */
.cwv2-cust-expand{
  display:none;
}
.cwv2-cust-expand.is-open{
  display:block;
  animation:cwExpandIn .28s ease;
}
@keyframes cwExpandIn{
  from{opacity:0;transform:translateY(-8px);}
  to{opacity:1;transform:translateY(0);}
}
.cwv2-cust-expand__inner{
  border:2px solid var(--cw-primary,#A0293E);
  border-top:none;
  border-radius:0 0 14px 14px;
  padding:18px;
  background:#fff;
}

/* The original .cw-engine-wrap inside our expand should lose its own borders */
.cwv2-cust-expand .cw-engine-wrap{
  border:none;
  background:transparent;
  padding:0;
  margin:0;
  box-shadow:none;
}
.cwv2-cust-expand .cw-engine-wrap::before,
.cwv2-cust-expand .cw-engine-wrap::after{
  display:none;
}
.cwv2-cust-expand .cw-engine-title{
  display:none; /* replaced by our step header */
}

/* Step header inside panel */
.cwv2-cust-step-head{
  display:flex;align-items:center;gap:10px;
  margin-bottom:16px;
  padding-bottom:12px;
  border-bottom:1px solid var(--cw-line,#EAD9CC);
}
.cwv2-cust-step-num{
  width:28px;height:28px;
  border-radius:50%;
  background:var(--cw-accent,#E8651A);
  color:#fff;
  font-size:13px;font-weight:700;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.cwv2-cust-step-title{
  font-size:14px;font-weight:700;
  color:var(--cw-ink,#1A1A1A);
}
.cwv2-cust-step-sub{
  font-size:11px;color:var(--cw-ink-3,#888);
  margin-left:auto;
}

/* Summary card (shown after saving) */
.cwv2-cust-summary{
  background:linear-gradient(135deg,#f0fdf4,#fff);
  border:1.5px solid #22c55e;
  border-radius:12px;
  padding:12px 16px;
  display:none;
  align-items:flex-start;
  gap:10px;
  margin-top:10px;
}
.cwv2-cust-summary.show{display:flex;}
.cwv2-cust-summary__icon{font-size:20px;flex-shrink:0;margin-top:1px;line-height:1;}
.cwv2-cust-summary__body{flex:1;min-width:0;}
.cwv2-cust-summary__title{
  font-size:13px;font-weight:700;color:#166534;
  display:block;margin-bottom:4px;
}
.cwv2-cust-summary__list{
  font-size:12px;color:#15803d;
  line-height:1.6;
  margin:0;padding:0;list-style:none;
  word-break:break-word;
}
.cwv2-cust-summary__list li{margin:0;}
.cwv2-cust-summary__edit{
  font-size:12px;color:var(--cw-primary,#A0293E);
  text-decoration:underline;cursor:pointer;
  margin-top:6px;display:inline-block;
  background:none;border:none;padding:0;font-family:inherit;
}
.cwv2-cust-summary__edit:hover{opacity:.8;}

/* Done button inside expand */
.cwv2-cust-done{
  width:100%;
  margin-top:16px;
  height:44px;
  border-radius:999px;
  background:var(--cw-primary,#A0293E);
  color:#fff;
  border:none;
  font-size:14px;font-weight:700;
  cursor:pointer;
  font-family:inherit;
  transition:opacity .15s,transform .15s;
}
.cwv2-cust-done:hover{opacity:.92;}
.cwv2-cust-done:active{transform:scale(.98);}

/* Mobile responsive */
@media(max-width:768px){
  .cwv2-cust-trigger{padding:12px 14px;gap:12px;}
  .cwv2-cust-trigger__thumb{width:44px;height:44px;}
  .cwv2-cust-trigger__title{font-size:13px;}
  .cwv2-cust-trigger__sub{font-size:11px;}
  .cwv2-cust-trigger__arrow{width:28px;height:28px;font-size:14px;}
  .cwv2-cust-expand__inner{padding:14px;}
  .cwv2-cust-done{height:48px;font-size:15px;}
}

/* ═══════════════════════════════════════
   Print-Area Preview — Two-column layout
═══════════════════════════════════════ */
.cwv2-layout{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:20px;
  align-items:start;
  margin-bottom:16px;
}
.cwv2-preview-col{position:relative;}
.cwv2-preview-hint{
  font-size:10px;color:#94a3b8;text-align:center;margin:6px 0 0;
}
.cwv2-fields-col{display:flex;flex-direction:column;gap:0;}

/* Preview stage — product mockup container */
.cwv2-preview-stage{
  position:relative;
  width:100%;
  aspect-ratio:1/1;
  border-radius:12px;
  overflow:hidden;
  background:var(--cw-surface,#FEF7F0);
  border:1px solid var(--cw-line,#EAD9CC);
}
.cwv2-preview-mockup{
  width:100%;height:100%;object-fit:cover;display:block;
  border-radius:12px;
}
.cwv2-preview-mockup--placeholder{
  width:100%;height:100%;
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  gap:8px;color:#94a3b8;
}
.cwv2-preview-mockup--placeholder span{font-size:48px;}
.cwv2-preview-mockup--placeholder small{font-size:12px;}

/* Zone boxes — absolute positioned on mockup */
.cwv2-zone{
  position:absolute;
  border:2px dashed rgba(232,101,26,.6);
  border-radius:6px;
  overflow:hidden;
  transition:border-color .2s;
  cursor:default;
  box-sizing:border-box;
}
.cwv2-zone.has-content{
  border-color:rgba(232,101,26,.3);
  border-style:solid;
}
.cwv2-zone--placeholder{
  border-color:rgba(160,41,62,.3);
}
.cwv2-zone:hover{border-color:rgba(232,101,26,1);}

.cwv2-zone__label{
  position:absolute;
  top:50%;left:50%;
  transform:translate(-50%,-50%);
  font-size:10px;font-weight:700;
  color:rgba(232,101,26,.9);
  text-align:center;
  white-space:nowrap;
  background:rgba(255,255,255,.85);
  padding:3px 8px;border-radius:999px;
  pointer-events:none;
  transition:opacity .2s;
  max-width:90%;overflow:hidden;text-overflow:ellipsis;
}
.cwv2-zone.has-content .cwv2-zone__label{opacity:0;}
.cwv2-zone:hover .cwv2-zone__label{opacity:1!important;}

.cwv2-zone__content{
  width:100%;height:100%;
  display:flex;align-items:center;justify-content:center;
}

/* Image zone content */
.cwv2-zone--image .cwv2-zone__content img,
.cwv2-zone--logo .cwv2-zone__content img{
  width:100%;height:100%;
  object-fit:cover;
  border-radius:4px;
}

/* Text zone content */
.cwv2-zone--text .cwv2-zone__content{
  align-items:center;justify-content:center;
  padding:4px 8px;
  font-size:clamp(9px,1.5vw,14px);
  font-weight:600;
  color:var(--cw-ink,#1A1A1A);
  text-align:center;
  word-break:break-word;
  line-height:1.2;
  overflow:hidden;
}

/* Mode selector */
.cwv2-mode-selector{
  margin-bottom:16px;
  padding:14px;
  background:var(--cw-surface,#FEF7F0);
  border:1px solid var(--cw-line,#EAD9CC);
  border-radius:10px;
}
.cwv2-mode-selector__title{
  font-size:11px;font-weight:700;
  text-transform:uppercase;letter-spacing:.07em;
  color:#64748b;margin:0 0 10px;
}
.cwv2-mode-options{display:flex;flex-direction:column;gap:6px;}
.cwv2-mode-opt{
  display:flex;align-items:flex-start;gap:10px;
  padding:9px 12px;
  background:#fff;
  border:2px solid transparent;
  border-radius:8px;
  cursor:pointer;
  transition:border-color .15s;
}
.cwv2-mode-opt input[type="radio"]{
  margin-top:2px;flex-shrink:0;
  accent-color:var(--cw-primary,#A0293E);
}
.cwv2-mode-opt.is-selected{border-color:var(--cw-primary,#A0293E);}
.cwv2-mode-opt__body strong{
  display:block;font-size:13px;font-weight:700;
  color:var(--cw-ink,#1A1A1A);
}
.cwv2-mode-opt__body span{
  font-size:11px;color:#64748b;
}

/* Group builder */
.cwv2-group-builder{
  margin-top:12px;padding:12px;
  background:#fff;border:1px solid #e5e7eb;
  border-radius:8px;
}
.cwv2-group-builder__hint{
  font-size:11px;color:#64748b;margin:0 0 8px;
}
.cwv2-group-row{
  display:grid;grid-template-columns:1fr 70px 32px;
  gap:6px;margin-bottom:6px;
}
.cwv2-group-row input{
  height:34px;border:1px solid #d1d5db;border-radius:6px;
  padding:0 8px;font-size:12px;font-family:inherit;width:100%;box-sizing:border-box;
}
.cwv2-group-row button{
  height:34px;border:1px solid #fca5a5;background:#fff;
  border-radius:6px;color:#dc2626;cursor:pointer;font-size:16px;
}
.cwv2-add-group-btn{
  font-size:12px;padding:5px 12px;
  background:#f8fafc;border:1px solid #d1d5db;
  border-radius:6px;cursor:pointer;font-family:inherit;margin-top:4px;
}

/* CSV upload */
.cwv2-csv-upload{
  margin-top:12px;padding:12px;
  background:#fff;border:1px solid #e5e7eb;border-radius:8px;
}
.cwv2-csv-upload__label{
  display:block;font-size:11px;font-weight:700;
  text-transform:uppercase;letter-spacing:.06em;
  color:#64748b;margin-bottom:6px;
}
.cwv2-csv-upload input[type="file"]{
  width:100%;font-size:12px;
}
.cwv2-csv-upload__hint{
  font-size:11px;color:#94a3b8;margin:6px 0 0;
}

/* Mobile responsive */
@media(max-width:768px){
  .cwv2-layout{
    grid-template-columns:1fr;
    gap:14px;
  }
  .cwv2-preview-col{order:-1;}
  .cwv2-preview-stage{aspect-ratio:4/3;max-height:200px;}
  .cwv2-zone__label{font-size:9px;}
}
@media(max-width:480px){
  .cwv2-preview-stage{max-height:160px;}
}
