/* ============================================================
   Design Master styles
   Reuses the .rm-* component classes from rawmaterial.css (those
   rules are global, not scoped) — this file just re-declares the
   --rm-* custom properties under #designmaster-root, since
   rawmaterial.css only defines them under #rawmaterial-root's scope.
   ============================================================ */

#designmaster-root {
  --rm-plum: #3A2436;
  --rm-gold: #CFC0A2;
  --rm-gold-soft: #F1EAD9;
  --rm-ink: #121014;
  --rm-ink-soft: #6B6570;
  --rm-line: #EAE6E9;
  --rm-panel: #FBFAFB;
  --rm-danger: #B5453A;
  font-family: 'Work Sans', sans-serif;
  color: var(--rm-ink);
  background: var(--rm-panel);
  padding: 24px 20px 40px;
}
#designmaster-root * { box-sizing: border-box; }
#designmaster-root h1, #designmaster-root h2, #designmaster-root h3 { font-family: 'Space Grotesk', sans-serif; margin: 0; }

/* Makes it unmistakable which existing row Save will overwrite while a
   form is in Edit mode — pairs with the dynamic "Update" button label
   and the "X updated." vs "X added." message text in designmaster.js.
   Without this, clicking Edit just to look at a row and then typing a
   different value reads as adding a new entry, but silently overwrites
   the row instead (the bug reported 2026-08-30). */
#designmaster-root .rm-row-editing td { background: var(--rm-gold-soft); }
#designmaster-root .rm-row-editing td:first-child { box-shadow: inset 3px 0 0 var(--rm-plum); }
#designmaster-root .rm-btn-updating { background: var(--rm-gold); color: var(--rm-plum); }

/* ============================================================
   Designs tab redesign (2026-08-30) — list + full-page Add/Edit.
   Ported from the "Design Master Redesign" mockup canvas, reusing
   the same --rm-* tokens declared above. Scoped under
   #designmaster-root throughout so nothing here can bleed into
   Raw Material Master or any other module that shares .rm-* names.
   ============================================================ */

/* ---- List toolbar ---- */
#designmaster-root .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
#designmaster-root .toolbar-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#designmaster-root .filter-wrap { position: relative; }
#designmaster-root .filter-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--rm-ink-soft); pointer-events: none; }
#designmaster-root .filter-search { width: 260px; padding-left: 34px; }

/* ---- Designs list table extras ---- */
#designmaster-root .thumb { width: 38px; height: 38px; border-radius: 8px; background: var(--rm-gold-soft); display: flex; align-items: center; justify-content: center; color: var(--rm-plum); flex-shrink: 0; overflow: hidden; }
#designmaster-root .thumb svg { width: 17px; height: 17px; }
#designmaster-root .cell-name { font-weight: 600; font-size: 13px; color: var(--rm-ink); }
#designmaster-root .cell-code { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 12.5px; color: var(--rm-plum); }
#designmaster-root .cell-sub { font-size: 11.5px; color: var(--rm-ink-soft); }
#designmaster-root .var-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 6px; background: var(--rm-panel); border: 1px solid var(--rm-line); font-size: 11.5px; font-weight: 600; color: var(--rm-ink); }
#designmaster-root .row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }

/* ---- Full-page Add/Edit header ---- */
#designmaster-root .page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
#designmaster-root .back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--rm-plum); font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 13.5px; cursor: pointer; background: none; border: none; padding: 0; }
#designmaster-root .back-link svg { width: 17px; height: 17px; }
#designmaster-root .eyebrow { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--rm-ink-soft); margin: 0 0 3px; }
#designmaster-root .page-title { font-size: 22px; font-weight: 700; color: var(--rm-plum); font-family: 'Space Grotesk', sans-serif; }
#designmaster-root .head-actions { display: flex; gap: 10px; }
#designmaster-root .rm-btn-secondary { background: #fff; color: var(--rm-plum); height: 36px; padding: 0 18px; font-size: 13px; border: 1px solid var(--rm-line); cursor: pointer; }
#designmaster-root .rm-btn-primary svg { width: 15px; height: 15px; }

/* ---- Two-column full-page layout ---- */
#designmaster-root .grid2 { display: grid; grid-template-columns: 320px 1fr; gap: 22px; align-items: start; }
/* Grid items default to min-width:auto, which sizes them to their
   content's max-content width (e.g. the 560px-min-width sheet-table)
   and defeats .sheet-wrap's own overflow-x:auto — this is what let the
   full-page form overflow the viewport on mobile. */
#designmaster-root .grid2 > * { min-width: 0; }
#designmaster-root .grid2 .rm-field { margin-bottom: 14px; }
#designmaster-root .grid2 .rm-card { margin-bottom: 0; }

/* ---- Photo upload + code pill ---- */
#designmaster-root .photo-box { width: 100%; aspect-ratio: 1/1; border-radius: 10px; border: 1.5px dashed var(--rm-line); background: var(--rm-panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--rm-ink-soft); margin-bottom: 16px; cursor: pointer; overflow: hidden; }
#designmaster-root .photo-box svg { width: 26px; height: 26px; }
#designmaster-root .photo-box .lbl { font-size: 12.5px; font-weight: 600; color: var(--rm-plum); }
#designmaster-root .photo-box .sub { font-size: 10.5px; }
#designmaster-root .code-pill { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 10px; border-radius: 8px; background: var(--rm-gold-soft); color: var(--rm-plum); font-family: 'Space Grotesk', sans-serif; font-size: 11.5px; font-weight: 600; margin-bottom: 16px; text-align: center; }
#designmaster-root .code-pill svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ---- Collections tag-input ---- */
#designmaster-root .rm-textarea { width: 100%; height: 60px; border-radius: 8px; border: 1px solid var(--rm-line); padding: 8px 10px; font-family: inherit; font-size: 13px; background: #fff; color: var(--rm-ink); resize: none; box-sizing: border-box; }
#designmaster-root .collections-box { border: 1px solid var(--rm-line); border-radius: 8px; padding: 7px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#designmaster-root .coll-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--rm-gold-soft); color: var(--rm-plum); font-size: 11.5px; font-weight: 600; padding: 4px 6px 4px 10px; border-radius: 6px; }
#designmaster-root .coll-chip svg { width: 11px; height: 11px; cursor: pointer; }
#designmaster-root .coll-input { border: none; outline: none; font-family: inherit; font-size: 12.5px; flex: 1; min-width: 90px; color: var(--rm-ink); background: transparent; }
#designmaster-root .coll-suggest { margin-top: 6px; border: 1px solid var(--rm-line); border-radius: 8px; background: #fff; box-shadow: 0 8px 20px rgba(18,16,20,.08); overflow: hidden; }
#designmaster-root .coll-suggest-item { padding: 8px 12px; font-size: 12.5px; color: var(--rm-ink); border-bottom: 1px solid var(--rm-line); cursor: pointer; }
#designmaster-root .coll-suggest-item:last-child { border-bottom: none; }
#designmaster-root .coll-suggest-item:hover { background: var(--rm-panel); }
#designmaster-root .coll-suggest-item .hint { color: var(--rm-ink-soft); font-size: 10.5px; margin-left: 6px; }
#designmaster-root .coll-suggest-item.new { color: var(--rm-plum); font-weight: 600; }

/* ---- Stat cards ---- */
#designmaster-root .stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
#designmaster-root .stat-card { background: #fff; border: 1px solid var(--rm-line); border-radius: 12px; padding: 14px 16px; border-top: 3px solid var(--rm-gold); }
#designmaster-root .stat-card .num { font-size: 21px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; color: var(--rm-plum); line-height: 1.1; }
#designmaster-root .stat-card .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--rm-ink-soft); margin-top: 5px; }
#designmaster-root .stat-card .sub { font-size: 11px; color: var(--rm-ink-soft); margin-top: 2px; }

/* ---- "Manage all variations" banner ---- */
#designmaster-root .dm-variations-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; padding: 14px 18px; flex-wrap: wrap; }
#designmaster-root .dm-variations-banner span { font-size: 13px; color: var(--rm-ink-soft); }

/* ---- Spreadsheet-style Metal/Diamond line grids ---- */
#designmaster-root .sheet-section { margin-bottom: 20px; }
#designmaster-root .sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#designmaster-root .sheet-title { font-size: 12.5px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; color: var(--rm-ink); text-transform: uppercase; letter-spacing: .03em; }
#designmaster-root .sheet-add { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--rm-plum); font-family: 'Space Grotesk', sans-serif; cursor: pointer; }
#designmaster-root .sheet-add svg { width: 13px; height: 13px; }
#designmaster-root .sheet-wrap { border: 1px solid var(--rm-line); border-radius: 10px; overflow-x: auto; background: #fff; }
#designmaster-root .sheet-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 560px; }
#designmaster-root .sheet-table th { background: var(--rm-gold-soft); text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--rm-ink-soft); padding: 8px 10px; border: 1px solid var(--rm-line); font-family: 'Space Grotesk', sans-serif; font-weight: 700; }
#designmaster-root .sheet-table td { padding: 0; border: 1px solid var(--rm-line); vertical-align: middle; }
#designmaster-root .cell-in { display: block; width: 100%; height: 34px; padding: 0 10px; border: none; font-family: inherit; font-size: 12.5px; color: var(--rm-ink); background: transparent; line-height: 34px; }
#designmaster-root select.cell-in, #designmaster-root input.cell-in { line-height: normal; }
#designmaster-root .cell-in:focus { outline: 2px solid var(--rm-plum); outline-offset: -2px; }
#designmaster-root .cell-num { text-align: right; }
#designmaster-root .cell-rownum { width: 32px; text-align: center; color: var(--rm-ink-soft); font-size: 11px; background: var(--rm-panel); }
#designmaster-root .cell-check { text-align: center; }
#designmaster-root .cell-check input { accent-color: var(--rm-plum); }
#designmaster-root .cell-del { width: 34px; text-align: center; color: var(--rm-ink-soft); cursor: pointer; }
#designmaster-root .cell-del svg { width: 14px; height: 14px; }
#designmaster-root .cell-del:hover { color: var(--rm-danger); }
#designmaster-root .add-row { padding: 9px 10px !important; text-align: center; color: var(--rm-ink-soft); font-size: 12px; border-style: dashed !important; background: var(--rm-panel); cursor: pointer; }
#designmaster-root .add-row svg { width: 12px; height: 12px; vertical-align: -2px; margin-right: 4px; }
#designmaster-root .calc-strip { display: flex; gap: 26px; flex-wrap: wrap; padding: 13px 16px; background: var(--rm-gold-soft); border-radius: 8px; font-size: 13px; }
#designmaster-root .calc-strip .k { color: var(--rm-ink-soft); margin-right: 6px; }
#designmaster-root .calc-strip .v { font-weight: 700; color: var(--rm-plum); font-family: 'Space Grotesk', sans-serif; }

/* ---- Mobile ---- */
@media (max-width: 900px) {
  #designmaster-root .grid2 { grid-template-columns: 1fr; }
  #designmaster-root .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  #designmaster-root .toolbar { flex-direction: column; align-items: stretch; }
  #designmaster-root .toolbar-left { flex-direction: column; align-items: stretch; }
  #designmaster-root .filter-search { width: 100%; }
  #designmaster-root .stat-row { grid-template-columns: 1fr 1fr; }
  #designmaster-root .head-actions { width: 100%; }
  #designmaster-root .head-actions .rm-btn { flex: 1; justify-content: center; }
}
