/*
 * NEMProductsEditor styles (Phase 2A).
 *
 * Inherits the host page's CSS variables (--ink, --muted, --line,
 * --brand, --bg, --bg-2, --radius, --radius-lg). Mobile-first; tap
 * targets aim for 44x44 on primary controls and the slider thumb is
 * 28px. Body text minimum 14.5px so iOS doesn't auto-zoom inputs.
 */

.nem-products-editor{
  display:block;
  width:100%;
}

/* ---------- Round 3 #1: filter chip group + collapsed summary ---------- */

.nem-products-filter{
  display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px;
}
.nem-products-filter-chip{
  padding:7px 14px;border-radius:999px;
  border:1.5px solid var(--line-2);
  background:var(--bg,#FAFAF7);color:var(--muted,#5B6660);
  font-family:inherit;font-size:12.5px;font-weight:500;
  cursor:pointer;transition:border-color .15s, color .15s, background .15s;
}
.nem-products-filter-chip:hover{
  border-color:var(--ink,#1F4A2E);color:var(--ink,#1F4A2E);
}
.nem-products-filter-chip.active{
  background:var(--ink,#1F4A2E);color:var(--bg,#FAFAF7);border-color:var(--ink,#1F4A2E);
}
.nem-products-empty-filter{
  padding:24px 16px;text-align:center;
  color:var(--muted,#5B6660);font-size:13.5px;
  border:1px dashed var(--line-2);border-radius:var(--radius,8px);
  background:var(--bg-2,#F4F2EA);
}

/* Collapsed summary header — always visible at the top of every card.
   Click anywhere on the summary toggles data-expanded on the card,
   which switches .nem-card-expanded-content between display:none and
   display:block. Round 7: thumbnail tile dropped; the 5px top color
   stripe on .nem-card already differentiates categories at a glance,
   so the row is slimmed down to name + stats + chevron. */
.nem-card-summary{
  display:flex;align-items:center;gap:12px;
  padding:10px 14px;cursor:pointer;
  transition:background .15s;
}
.nem-card-summary:hover{background:var(--bg-2,#F4F2EA)}
.nem-card-summary-meta{flex:1;min-width:0}
.nem-card-summary-name{
  font-size:15px;font-weight:600;color:var(--ink,#1F1D17);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  margin-bottom:2px;
}
.nem-card-summary-stats{
  font-family:'JetBrains Mono',monospace;
  font-size:12px;color:var(--muted,#5B6660);
}
.nem-card-expand{
  font-size:18px;color:var(--muted,#5B6660);
  transition:transform .2s;display:inline-block;line-height:1;flex-shrink:0;
}
.nem-card[data-expanded="true"] .nem-card-expand{ transform:rotate(180deg) }
.nem-card[data-expanded="true"] .nem-card-summary{
  border-bottom:1px solid var(--line);
}

/* Default: expanded content hidden. data-expanded="true" reveals it.
   Round 7: card padding moved here so it only appears around the
   expanded body, not around the slim collapsed summary. */
.nem-card-expanded-content{display:none;padding:14px 16px 16px}
.nem-card[data-expanded="true"] .nem-card-expanded-content{display:block}

/* ---------- list + add button ---------- */

.nem-products-list{
  display:flex;
  flex-direction:column;
  gap:14px;
  margin-bottom:14px;
}

.nem-btn{
  display:inline-flex;align-items:center;justify-content:center;
  min-height:44px;
  padding:11px 18px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  color:var(--ink);
  font-family:inherit;font-size:14.5px;font-weight:500;
  cursor:pointer;
  transition:border-color .15s ease, background .15s ease;
}
.nem-btn:hover{
  border-color:var(--ink);
  background:var(--bg-2);
}
.nem-btn:focus-visible{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.18);
}

.nem-btn-add-product{
  width:100%;
  border-style:dashed;
  color:var(--muted);
  font-weight:500;
}
.nem-btn-add-product:hover{
  color:var(--ink);
  border-style:solid;
}

.nem-btn-add-height{
  margin-top:10px;
  padding:11px 14px;
  min-height:44px;
  font-size:13.5px;
  color:var(--muted);
  border-style:dashed;
}
.nem-btn-add-height:hover{
  color:var(--ink);
  border-style:solid;
}

.nem-btn-icon{
  width:36px;height:36px;
  min-width:36px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  color:var(--muted);
  font-size:20px;line-height:1;
  cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;
  padding:0;
  transition:border-color .15s ease, color .15s ease, background .15s ease;
}
.nem-btn-icon:hover{
  border-color:var(--danger,#B9442F);
  color:var(--danger,#B9442F);
  background:#fff;
}
.nem-btn-icon:focus-visible{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.18);
}
/* Visually disabled state — used for the remove-product × when only
   one product remains. The click handler still gates the action, but
   without a visible cue customers mash the button (Clarity: ~500 dead
   clicks on × over 14 days). Pair with title="..." for the tooltip. */
.nem-btn-icon.is-disabled,
.nem-btn-icon[aria-disabled="true"]{
  opacity:.4;
  cursor:not-allowed;
}
.nem-btn-icon.is-disabled:hover,
.nem-btn-icon[aria-disabled="true"]:hover{
  border-color:var(--line-2);
  color:var(--muted);
  background:#fff;
}
/* Round 2 #5: Duplicate isn't destructive, so override the red
   hover that the shared icon-button rule above gives the delete
   button. Ink color reads as a neutral action. The duplicate glyph
   (U+29C9) sits a bit higher than the delete x; nudge the size and
   line-height to land it on the same baseline visually. */
.nem-duplicate-product{
  font-size:18px;
}
.nem-duplicate-product:hover{
  border-color:var(--ink);
  color:var(--ink);
}

/* ---------- card ---------- */

.nem-card{
  position:relative;
  border:1px solid var(--line);
  border-radius:var(--radius-lg,12px);
  background:var(--bg,#FAFAF7);
  /* Round 7: card padding dropped. The summary handles its own
     padding (slim collapsed row); the expanded content pads itself. */
  --nem-cat-color:var(--brand,#1F4A2E);
}
/* Category color stripe at the top of each card. Reads --nem-cat-color
   set per category via data-cat attribute below. Subtle but
   instantly distinguishable when a card list has mixed types. */
.nem-card::before{
  content:"";
  position:absolute;
  top:0;left:0;right:0;
  height:5px;
  background:var(--nem-cat-color);
  border-radius:var(--radius-lg,12px) var(--radius-lg,12px) 0 0;
}
.nem-card[data-cat="Wood"]       { --nem-cat-color:#A0683D; } /* warm cedar brown */
.nem-card[data-cat="Vinyl"]      { --nem-cat-color:#95A5B5; } /* cool gray-blue */
.nem-card[data-cat="Chain Link"] { --nem-cat-color:#7A8590; } /* steel gray */
.nem-card[data-cat="Metal"]      { --nem-cat-color:#5A6470; } /* iron / charcoal */
.nem-card[data-cat="Other"]      { --nem-cat-color:var(--brand,#1F4A2E); }
/* Card splits into editor (left) + homeowner preview (right) on
   wide viewports; stacks vertically on narrow ones. */
.nem-card-grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(180px,220px);
  gap:18px;
  align-items:start;
}
.nem-card-body{
  display:flex;flex-direction:column;gap:14px;
  min-width:0;
}

.nem-card-header{
  display:flex;align-items:center;gap:10px;
}
.nem-name-input{
  flex:1 1 auto;min-width:0;
  padding:11px 14px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  font-family:inherit;font-size:16px;font-weight:600;
  color:var(--ink);
}
.nem-name-input:focus{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.12);
}

.nem-row{
  display:flex;flex-direction:column;gap:6px;
}
.nem-label{
  font-size:12px;font-weight:600;letter-spacing:.04em;
  text-transform:uppercase;
  color:var(--muted);
}

/* category dropdown */
.nem-category-select{
  width:100%;
  padding:11px 14px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  font-family:inherit;font-size:14.5px;
  color:var(--ink);
  cursor:pointer;
}
.nem-category-select:focus{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.12);
}

/* "Other" category custom-name text input. Shown when category is
   not one of the standard four. */
.nem-row-category-other{
  margin-top:-4px;
}
.nem-category-other-input{
  width:100%;
  padding:11px 14px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  font-family:inherit;font-size:14.5px;
  color:var(--ink);
}
.nem-category-other-input:focus{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.12);
}

/* ---------- heights section ---------- */

.nem-heights{
  display:flex;flex-direction:column;
  background:#fff;
  border:1px solid var(--line);
  border-radius:var(--radius,8px);
  padding:12px 14px;
}
.nem-heights-title{
  font-size:13px;font-weight:600;
  color:var(--ink-2);
  margin-bottom:10px;
}
.nem-heights-list{
  display:flex;flex-direction:column;
  gap:14px;
}

.nem-height-row{
  display:flex;align-items:center;gap:10px;
  flex-wrap:wrap;row-gap:10px;
}
/* Round 7: slider dropped, "to" separator now always inline between
   the lo and hi number inputs. */
.nem-default-radio{order:1;}
.nem-height-label{order:2;}
.nem-price-lo{order:3;}
.nem-to-separator{order:4;}
.nem-price-hi{order:5;}
.nem-remove-height{order:6;margin-left:auto;}
.nem-default-radio{
  width:20px;height:20px;
  margin:0;
  flex:0 0 auto;
  cursor:pointer;
  accent-color:var(--brand,#1F4A2E);
}
.nem-height-label{
  font-size:14px;font-weight:600;
  color:var(--ink);
  min-width:32px;
  flex:0 0 auto;
}
/* Custom (non-4/6/8) heights render as a small inline editor:
   [ 10 ] ft. Same vertical footprint as the static label so the
   row layout stays put. */
.nem-height-edit{
  flex:0 0 auto;
  display:inline-flex;align-items:center;gap:3px;
}
.nem-height-num{
  width:42px;
  padding:6px 4px;
  border:1px solid var(--line-2);
  border-radius:6px;
  background:#fff;
  font-family:inherit;font-size:14px;font-weight:600;
  color:var(--ink);
  text-align:center;
  -moz-appearance:textfield;
}
.nem-height-num::-webkit-outer-spin-button,
.nem-height-num::-webkit-inner-spin-button{
  -webkit-appearance:none;margin:0;
}
.nem-height-num:focus{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.12);
}
.nem-height-suffix{
  font-size:13px;font-weight:600;color:var(--muted);
}
.nem-price{
  width:54px;flex:0 0 auto;
  padding:8px 6px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  font-family:inherit;font-size:14px;font-weight:500;
  color:var(--ink);
  text-align:center;
  -moz-appearance:textfield;
}
.nem-price::-webkit-outer-spin-button,
.nem-price::-webkit-inner-spin-button{
  -webkit-appearance:none;margin:0;
}
.nem-price:focus{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.12);
}

/* ---------- per-product gate-pricing overrides ---------- */
/* Collapsed by default; auto-opens for products that already have
   at least one override set. Sits inside the heights box right
   below the "+ Add height" button so the relationship to the
   product's heights is obvious. */

.nem-gates-disclosure{
  margin-top:14px;
  border-top:1px dashed var(--line);
  padding-top:12px;
}
.nem-gates-summary{
  cursor:pointer;
  font-size:13px;font-weight:600;
  color:var(--ink-2);
  user-select:none;
  list-style:revert;
}
.nem-gates-summary:hover{ color:var(--ink); }
.nem-gates-hint{
  font-size:12.5px;color:var(--muted);
  margin:8px 0 10px;line-height:1.4;
}
.nem-gates-table{
  display:flex;flex-direction:column;gap:6px;
}
.nem-gates-row{
  display:grid;
  grid-template-columns:64px 1fr 1fr;
  align-items:center;gap:8px;
}
.nem-gates-row-head{
  font-size:12px;font-weight:600;
  color:var(--muted);
  text-transform:none;
}
.nem-gates-row-head .nem-gates-single,
.nem-gates-row-head .nem-gates-double{ text-align:left; }
.nem-gates-h{
  font-size:13px;font-weight:600;color:var(--ink);
}
.nem-gates-input{
  width:100%;
  padding:8px 10px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  font-family:inherit;font-size:14px;
  color:var(--ink);
  -moz-appearance:textfield;
}
.nem-gates-input::-webkit-outer-spin-button,
.nem-gates-input::-webkit-inner-spin-button{
  -webkit-appearance:none;margin:0;
}
.nem-gates-input:focus{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.12);
}
.nem-gates-input::placeholder{
  color:var(--muted);
  font-style:italic;
  font-size:12.5px;
}

/* ---------- description ---------- */

.nem-desc-input{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  font-family:inherit;font-size:14.5px;
  color:var(--ink);
  resize:vertical;
  min-height:60px;
}
.nem-desc-input:focus{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.12);
}

/* ---------- specs ---------- */

.nem-specs-input{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  font-family:inherit;font-size:14px;line-height:1.4;
  color:var(--ink);
  resize:vertical;
  min-height:120px;
}
.nem-specs-input:focus{
  outline:none;
  border-color:var(--ink);
  box-shadow:0 0 0 3px rgba(31,74,46,.12);
}

/* ---------- photo ---------- */

.nem-photo-controls{
  display:flex;align-items:center;gap:12px;
  flex-wrap:wrap;
}
.nem-photo-file{display:none;}
.nem-btn-photo{
  flex:0 0 auto;
}
.nem-photo-thumb{
  width:64px;height:64px;
  border-radius:var(--radius,8px);
  object-fit:cover;
  border:1px solid var(--line-2);
  background:var(--bg-2,#F3F2EC);
}

/* ---------- enabled toggle ---------- */

.nem-toggle{
  display:flex;align-items:center;gap:10px;
  font-size:14px;
  color:var(--ink-2);
  cursor:pointer;
  padding:6px 0;
  user-select:none;
}
.nem-toggle input[type=checkbox]{
  width:20px;height:20px;
  margin:0;
  accent-color:var(--brand,#1F4A2E);
  cursor:pointer;
  flex:0 0 auto;
}

/* ---------- "to" separator between lo and hi inputs ---------- */

.nem-to-separator{
  flex:0 0 auto;
  font-size:13px;font-weight:500;
  color:var(--muted);
  padding:0 2px;
}

/* ---------- preview pane ---------- */

.nem-preview{
  display:flex;flex-direction:column;gap:8px;
  position:sticky;top:8px;
}
.nem-preview-label{
  font-size:11px;font-weight:600;letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--muted);
}
.nem-preview-card{
  border:1px solid var(--line-2);
  border-radius:var(--radius,8px);
  background:#fff;
  padding:12px;
  display:flex;flex-direction:column;gap:8px;
}
.nem-preview-card.nem-preview-disabled{
  opacity:.55;
}
.nem-preview-photo{
  width:100%;height:104px;
  border-radius:var(--radius,8px);
  overflow:hidden;
  background:var(--bg-2,#F3F2EC);
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  transition:background .15s ease, box-shadow .15s ease;
}
.nem-preview-photo:hover{
  background:var(--bg-3,#ECEAE0);
}
.nem-preview-photo:focus-visible{
  outline:none;
  box-shadow:0 0 0 3px rgba(31,74,46,.18);
}
.nem-preview-photo img{
  width:100%;height:100%;object-fit:cover;display:block;
}
.nem-preview-photo-placeholder span{
  color:var(--subtle,#8A938C);
  font-size:11px;font-weight:500;
  letter-spacing:.04em;text-transform:uppercase;
}
.nem-preview-name{
  font-weight:600;font-size:14px;color:var(--ink);
  letter-spacing:-.01em;
  word-break:break-word;
}
.nem-preview-desc{
  color:var(--muted);font-size:12.5px;line-height:1.4;
  word-break:break-word;
}
/* Mirror estimate.html .fc-specs — dot-bulleted list under desc. */
.nem-preview-specs{
  margin-top:8px;padding-top:8px;
  border-top:1px solid var(--line-2);
}
.nem-preview-spec{
  font-size:11.5px;color:var(--muted);padding:2px 0;
  display:flex;align-items:flex-start;gap:6px;
}
.nem-preview-spec::before{
  content:'';flex-shrink:0;
  width:4px;height:4px;background:var(--ink);
  border-radius:50%;
  margin-top:6px;display:inline-block;
}
.nem-preview-heights{
  display:flex;align-items:center;gap:6px;
  flex-wrap:wrap;
  margin-top:2px;
}
.nem-preview-heights-label{
  font-size:11px;font-weight:600;letter-spacing:.04em;
  text-transform:uppercase;color:var(--muted);
  margin-right:4px;
}
.nem-preview-height-btn{
  padding:5px 10px;
  border:1px solid var(--line-2);
  border-radius:6px;
  background:#fff;
  font-family:inherit;font-size:12px;font-weight:500;
  color:var(--ink);
  cursor:pointer;
}
.nem-preview-height-btn.selected{
  background:var(--ink);color:var(--bg);border-color:var(--ink);
}

/* ---------- responsive ---------- */

@media (max-width:720px){
  /* Stack editor body and preview vertically on narrow screens. */
  .nem-card-grid{grid-template-columns:1fr;}
  .nem-preview{position:static;}
}
@media (max-width:480px){
  .nem-card-expanded-content{padding:12px 14px 14px}
}
