/* ============================================================
   Wonder — Modal Éditeur d'assemblage (Pro v2)
   Full-screen layout matching the handoff design
   ============================================================ */

#modalAssembly {
  display: none;
  position: fixed; inset: 0; z-index: 20006;
  background: rgba(14,20,17,.75);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  padding: 0;
  align-items: flex-start;
  justify-content: center;
}

.wt-asm-modal {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', -apple-system, sans-serif;
  background: #f6f6f3;
}

/* ── App header ── */
.wt-asm-app-hd {
  background: #fff;
  border-bottom: 1px solid #e8eae6;
  padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; position: sticky; top: 0; z-index: 10;
}
.wt-asm-app-hd-left { display: flex; align-items: center; gap: 12px; }
.wt-asm-app-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: #0e1411;
  display: flex; align-items: center; justify-content: center;
  color: #4ade80; font-size: 16px; flex-shrink: 0;
}
.wt-asm-app-title-block { display: flex; flex-direction: column; gap: 1px; }
.wt-asm-app-title { font-size: 17px; font-weight: 800; color: #0e1411; letter-spacing: -.4px; }
.wt-asm-app-sub { font-size: 12px; color: #6b7565; }
.wt-asm-app-hd-right { display: flex; align-items: center; gap: 12px; }
.wt-asm-badge-warn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 99px;
  background: #fef3c7; border: 1px solid #fde68a;
  font-size: 12px; font-weight: 600; color: #b45309;
}
.wt-asm-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: transparent; cursor: pointer; font-size: 20px; color: #6b7565;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.wt-asm-close:hover { background: #f6f6f3; color: #0e1411; }

/* ── Scrollable body — 2 cols ── */
.wt-asm-body {
  flex: 1;
  padding: 16px 24px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  max-width: 1600px; width: 100%; margin: 0 auto;
  box-sizing: border-box;
  align-items: start;
}
.wt-asm-col-left { display: flex; flex-direction: column; gap: 14px; }
.wt-asm-col-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ── Cards ── */
.wt-asm-card {
  background: #fff;
  border: 1px solid #e8eae6;
  border-radius: 14px;
  overflow: hidden;
}

/* ── Meta card (LEFT) ── */
.wt-asm-meta-pad { padding: 16px 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.wt-asm-meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}
.wt-asm-fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.wt-asm-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 700;
  color: #6b7565; letter-spacing: .08em; text-transform: uppercase;
}
.wt-asm-input, .wt-asm-select {
  padding: 8px 11px;
  border: 1.5px solid #e8eae6;
  border-radius: 9px;
  font-size: 13px; font-family: 'Inter', sans-serif;
  color: #0e1411; background: #fff;
  outline: none; box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
  width: 100%;
}
.wt-asm-input:focus, .wt-asm-select:focus {
  border-color: #14543a; box-shadow: 0 0 0 3px #e7efe9;
}
.wt-asm-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7565' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 28px; cursor: pointer;
}
.wt-asm-dims-row { display: flex; align-items: center; gap: 5px; min-width: 0; width: 100%; }
.wt-asm-dim-in {
  flex: 1; min-width: 0; padding: 8px 6px; text-align: center;
  border: 1.5px solid #e8eae6; border-radius: 9px;
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  font-weight: 600; color: #0e1411; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
  -moz-appearance: textfield;
}
.wt-asm-dim-in::-webkit-outer-spin-button,
.wt-asm-dim-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wt-asm-dim-in:focus { border-color: #14543a; box-shadow: 0 0 0 3px #e7efe9; }
.wt-asm-dim-sep { font-size: 12px; color: #6b7565; font-weight: 600; }

/* Color section */
.wt-asm-color-section { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.wt-asm-color-top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 6px;
}
.wt-asm-color-lbl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 700;
  color: #6b7565; letter-spacing: .08em; text-transform: uppercase;
  display: flex; align-items: center; gap: 5px;
}
.wt-asm-color-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wt-asm-color-name-chip {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: #0e1411;
}
.wt-asm-color-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.wt-asm-apercu { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #6b7565; }
.wt-asm-apercu-line {
  display: inline-block; width: 28px; height: 3px;
  border-radius: 2px; background: #14543a;
}

/* Palette — 8 cols × 4 rows, takes column width */
.wt-asm-palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
}
.wt-asm-swatch {
  width: 100%; aspect-ratio: 1; border-radius: 6px;
  border: 2px solid transparent; cursor: pointer;
  transition: transform .12s, border-color .12s;
  position: relative;
}
.wt-asm-swatch:hover { transform: scale(1.12); z-index: 2; }
.wt-asm-swatch.sel { border-color: #0e1411; box-shadow: 0 0 0 2px #fff inset; }
.wt-asm-swatch.sel::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; font-weight: 900;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.wt-asm-swatch.light.sel::after { color: #0e1411; text-shadow: none; }

/* Legacy aliases for renderColorGrid() */
.color-swatch {
  width: 100%; aspect-ratio: 1; border-radius: 6px;
  border: 2px solid transparent; cursor: pointer;
  transition: transform .12s, border-color .12s;
  position: relative;
}
.color-swatch:hover { transform: scale(1.12); z-index: 2; }
.color-swatch.selected { border-color: #0e1411; box-shadow: 0 0 0 2px #fff inset; }
.color-swatch.selected::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; font-weight: 900;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.color-swatch.light.selected::after { color: #0e1411; text-shadow: none; }

/* ── Composition card ── */
.wt-asm-comp-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px;
  background: #0e1411;
}
.wt-asm-comp-hd-title {
  font-size: 14px; font-weight: 700; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.wt-asm-comp-total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px; font-weight: 700; color: #4ade80;
}

/* Add row col headers */
.wt-asm-addrow-hdrs {
  display: grid;
  grid-template-columns: 1fr 90px 80px 90px 90px 80px 100px;
  gap: 6px;
  padding: 8px 20px 4px;
  background: #f6f6f3; border-bottom: 1px solid #e8eae6;
}
.wt-asm-addrow-hdrs span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 700;
  color: #6b7565; letter-spacing: .08em; text-transform: uppercase;
}

/* Add row inputs */
.wt-asm-addrow {
  display: grid;
  grid-template-columns: 1fr 90px 80px 90px 90px 80px 100px;
  gap: 6px;
  padding: 8px 20px 10px;
  background: #f6f6f3; border-bottom: 1.5px solid #c5d9cc;
  align-items: center;
}
.wt-asm-addrow-input, .wt-asm-addrow-select {
  padding: 8px 10px;
  border: 1.5px solid #e8eae6;
  border-radius: 8px;
  font-size: 13px; font-family: 'Inter', sans-serif;
  color: #0e1411; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%; box-sizing: border-box;
  -webkit-appearance: none; appearance: none;
}
.wt-asm-addrow-input:focus, .wt-asm-addrow-select:focus {
  border-color: #14543a; box-shadow: 0 0 0 2px #e7efe9;
}
.wt-asm-addrow-mono { font-family: 'JetBrains Mono', monospace; text-align: center; }
.wt-asm-addrow-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7565' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  padding-right: 22px; cursor: pointer;
}
.wt-asm-addbtn {
  padding: 9px 16px; border-radius: 9px; border: none;
  background: #14543a; color: #fff;
  font-size: 13px; font-weight: 700; font-family: 'Inter', sans-serif;
  cursor: pointer; transition: background .15s; white-space: nowrap;
  display: flex; align-items: center; gap: 4px;
}
.wt-asm-addbtn:hover { background: #0d3d2a; }

/* Alloc sub-row */
.wt-asm-alloc-pair { display: flex; gap: 4px; align-items: center; }
.wt-asm-alloc-pair .wt-asm-addrow-input { width: 58px; }
.wt-asm-alloc-pair .wt-asm-addrow-select { width: 66px; }

/* Suggestion dropdown */
#itemSuggestionsDropdown {
  border-radius: 0 0 8px 8px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.12) !important;
}

/* Table */
.wt-asm-table-wrap { overflow: auto; }
.wt-asm-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.wt-asm-table thead {
  background: #f6f6f3;
  border-bottom: 1.5px solid #e8eae6;
}
.wt-asm-table th {
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 700; color: #6b7565;
  letter-spacing: .07em; text-transform: uppercase;
  white-space: nowrap;
}
.wt-asm-table th.r, .wt-asm-table td.r { text-align: right; }
.wt-asm-table th.c, .wt-asm-table td.c { text-align: center; }
.wt-asm-table tbody tr { border-bottom: 1px solid #eef0ec; }
.wt-asm-table tbody tr:hover { background: #fafaf9; }
.wt-asm-table td { padding: 7px 12px; }

/* ── Quickwork card ── */
.wt-asm-qw-head {
  padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
}
.wt-asm-qw-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 99px;
  background: #fef3c7; border: 1px solid #fde68a;
  font-size: 11px; font-weight: 700; color: #b45309;
  white-space: nowrap;
}
.wt-asm-qw-desc { font-size: 13px; color: #6b7565; }
.wt-asm-qw-body { padding: 0 20px 16px; display: flex; flex-direction: column; gap: 0; }

/* ── Footer ── */
.wt-asm-ft {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px;
  border-top: 1px solid #e8eae6;
  background: #fff; z-index: 10;
}
.wt-asm-ft-info { font-size: 13px; color: #6b7565; display: flex; align-items: center; gap: 6px; }
.wt-asm-ft-actions { display: flex; gap: 10px; align-items: center; }

.wt-asm-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif;
  cursor: pointer; border: 1.5px solid transparent;
  transition: all .15s; white-space: nowrap;
}
.wt-asm-btn-ghost { background: #fff; color: #0e1411; border-color: #e8eae6; }
.wt-asm-btn-ghost:hover { background: #f6f6f3; }
.wt-asm-btn-lib { background: #0e1411; color: #fff; border-color: #0e1411; }
.wt-asm-btn-lib:hover { background: #1f2d27; }
.wt-asm-btn-install { background: #14543a; color: #fff; border-color: #14543a; }
.wt-asm-btn-install:hover { background: #0d3d2a; }
.wt-asm-btn-update { background: #5b21b6; color: #fff; border-color: #5b21b6; }
.wt-asm-btn-update:hover { background: #4c1d95; }
