/* line_items.css — added line items on the Project page (line_items.js).
 *
 * One pattern everywhere an item is added: rows in the card it bills in, the
 * same panel to add and to edit, Remove on the row, and "Extras on this job"
 * listing all of them. Loaded after style.css and scoped to #projV4, so it
 * reaches nothing but the desktop Project page (#projV4 is hidden on phones,
 * which keep the classic estimate panel).
 *
 * Colours are the app's own tokens. Accent as text uses --accent-ink, accent
 * as a fill uses --accent (#3a62e0, white on it 4.95:1). The amber for "no
 * price yet" carries its own ink per theme, because the ledger's #b9791f
 * clears only about 3:1 on white.
 */
#projV4 {
  --li-amber-ink: #8a5a06;     /* 6.6:1 on white, 6.0:1 on --surface2 */
  --li-amber-tint: rgba(230,162,60,.12);
  --li-flash: rgba(58,98,224,.10);
}
html:not([data-theme="light"]) #projV4 {
  --li-amber-ink: #f2b95c;     /* 8.9:1 on the dark --surface */
  --li-flash: rgba(147,176,255,.12);
}

/* ── A card's added items ─────────────────────────────────────────────── */
#projV4 .li-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
#projV4 .li-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text3); margin: 0 0 6px;
}
#projV4 .li-head,
#projV4 .li-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 92px 128px 96px 72px;
  gap: 12px; align-items: center;
}
#projV4 .li-head { padding: 0 10px 6px; border-bottom: 1px solid var(--border); }
#projV4 .li-hc { font-size: 11px; color: var(--text3); }
#projV4 .li-hc-1, #projV4 .li-hc-2, #projV4 .li-hc-3 { text-align: right; }

#projV4 .li-row {
  padding: 10px; margin: 0 -0px; border-bottom: 1px solid var(--border);
  border-radius: 0; cursor: pointer; outline: none;
  transition: background-color .15s ease-out;
}
#projV4 .li-row:hover { background: var(--surface2); }
#projV4 .li-row:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-ink); border-radius: 6px; }
#projV4 .li-row.li-flash { animation: li-flash 1.6s cubic-bezier(.16,1,.3,1); }
@keyframes li-flash { from { background: var(--li-flash); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { #projV4 .li-row.li-flash { animation: none; background: var(--li-flash); } }

#projV4 .li-name { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; }
#projV4 .li-name-t { font-size: 14px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
#projV4 .li-meta { flex-basis: 100%; font-size: 11.5px; color: var(--text3); }
#projV4 .li-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text2); border: 1px solid var(--border2); border-radius: 4px; padding: 0 5px;
}
#projV4 .li-qty, #projV4 .li-price, #projV4 .li-total {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
#projV4 .li-qty, #projV4 .li-price { font-size: 13px; color: var(--text2); }
#projV4 .li-total { font-size: 14px; font-weight: 600; color: var(--text); }
#projV4 .li-unpriced .li-price,
#projV4 .li-unpriced .li-total { color: var(--li-amber-ink); font-weight: 600; font-size: 12.5px; }
#projV4 .li-del {
  justify-self: end; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--text2);
  background: none; border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; cursor: pointer;
}
#projV4 .li-del:hover { color: var(--text); border-color: var(--border2); }
#projV4 .li-del:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; }

/* ── Add button ───────────────────────────────────────────────────────── */
#projV4 .li-add {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 12px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--accent-ink);
  background: none; border: 1px solid var(--border2); border-radius: 8px;
  padding: 8px 13px; cursor: pointer; transition: border-color .15s, background-color .15s;
}
#projV4 .li-add:hover { border-color: var(--accent-ink); background: var(--surface2); }
#projV4 .li-add:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
#projV4 .li-add svg { flex: 0 0 auto; }

/* ── Undo ─────────────────────────────────────────────────────────────── */
#projV4 .li-undo {
  display: flex; align-items: center; gap: 12px; margin-top: 10px;
  padding: 8px 10px 8px 12px; border-radius: 8px; background: var(--surface2);
  font-size: 13px; color: var(--text2);
}
#projV4 .li-undo-t { flex: 1; min-width: 0; }
#projV4 .li-undo-btn {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--accent-ink);
  background: none; border: 0; padding: 4px 6px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
#projV4 .li-undo-btn:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 1px; border-radius: 4px; }

/* ── The add / edit panel ─────────────────────────────────────────────── */
#projV4 .li-editor {
  margin: 10px 0 4px; padding: 14px 16px 12px;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 10px;
}
#projV4 .li-row + .li-editor, #projV4 .li-head + .li-editor { margin-top: 6px; }
#projV4 .li-grid {
  display: grid; gap: 10px 12px;
  grid-template-columns: minmax(0,1fr) 96px 104px 132px;
}
#projV4 .li-f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
/* Same label voice as every other field in a card (.pv4-fld > span). */
#projV4 .li-f > label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--text3); }
#projV4 .li-f input, #projV4 .li-f select {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border2); border-radius: 7px;
  padding: 8px 10px; min-height: 38px;
}
#projV4 .li-f-qty input, #projV4 .li-f-price input { text-align: right; font-variant-numeric: tabular-nums; }
#projV4 .li-f input:focus, #projV4 .li-f select:focus { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 3px rgba(58,98,224,.16); }
#projV4 .li-f input[aria-invalid="true"] { border-color: var(--red, #f43f5e); }
#projV4 .li-money { position: relative; }
#projV4 .li-money-s {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--text3); pointer-events: none;
}
#projV4 .li-money input { padding-left: 22px; }
#projV4 .li-err { font-size: 12px; font-weight: 500; color: #b4232f; }
html:not([data-theme="light"]) #projV4 .li-err { color: #ff8a9b; }
#projV4 .li-f-scope { margin-top: 10px; max-width: 280px; }

/* My Prices suggestions: a short list right under the name it completes. */
#projV4 .li-suggest { margin-top: 8px; }
#projV4 .li-sug-h { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 4px; }
#projV4 .li-sug-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
#projV4 .li-sug-row {
  display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: left;
  font: inherit; font-size: 13.5px; color: var(--text); background: none; border: 0;
  border-bottom: 1px solid var(--border); padding: 8px 11px; cursor: pointer;
}
#projV4 .li-sug-row:last-child { border-bottom: 0; }
#projV4 .li-sug-row:hover, #projV4 .li-sug-row:focus-visible { background: var(--surface2); outline: none; }
#projV4 .li-sug-row:focus-visible { box-shadow: inset 3px 0 0 var(--accent); }
#projV4 .li-sug-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#projV4 .li-sug-rate { flex: 0 0 auto; font-size: 12.5px; color: var(--text2); font-variant-numeric: tabular-nums; }
#projV4 .li-sug-noprice { color: var(--li-amber-ink); }

#projV4 .li-note { margin: 8px 0 0; font-size: 12px; color: var(--text2); }
#projV4 .li-save {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
#projV4 .li-save input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
#projV4 .li-save-note { margin: 12px 0 0; font-size: 12.5px; color: var(--text3); }
#projV4 .li-save[hidden], #projV4 .li-save-note[hidden], #projV4 .li-note[hidden], #projV4 .li-suggest[hidden], #projV4 .li-err[hidden] { display: none; }

#projV4 .li-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; }
#projV4 .li-primary {
  font: inherit; font-size: 13.5px; font-weight: 600; color: #fff;
  background: var(--accent); border: 1px solid var(--accent); border-radius: 8px;
  padding: 8px 15px; cursor: pointer; transition: background-color .15s;
}
#projV4 .li-primary:hover { background: var(--accent2, #2f50c4); border-color: var(--accent2, #2f50c4); }
#projV4 .li-cancel, #projV4 .li-remove {
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text2);
  background: none; border: 1px solid var(--border2); border-radius: 8px; padding: 8px 13px; cursor: pointer;
}
#projV4 .li-cancel:hover, #projV4 .li-remove:hover { color: var(--text); border-color: var(--text3); }
#projV4 .li-remove { margin-left: auto; }
#projV4 .li-primary:focus-visible, #projV4 .li-cancel:focus-visible, #projV4 .li-remove:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
#projV4 .li-math { font-size: 12.5px; color: var(--text2); font-variant-numeric: tabular-nums; }
#projV4 .li-editor-add .li-math { margin-left: auto; }

/* ── Extras on this job ───────────────────────────────────────────────── */
#projV4 #pv4Extras.li-sum { margin-bottom: 26px; }
#projV4 .li-sum-list { border-top: 1px solid var(--border); }
#projV4 .li-sum-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto 96px 56px;
  gap: 14px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--border);
}
#projV4 .li-sum-name { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
#projV4 .li-sum-name-t { font-size: 14px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
#projV4 .li-sum-where { font-size: 12px; color: var(--text3); }
#projV4 .li-sum-math { font-size: 12.5px; color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
#projV4 .li-sum-tot { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
#projV4 .li-sum-edit {
  justify-self: end; font: inherit; font-size: 13px; font-weight: 600; color: var(--accent-ink);
  background: none; border: 0; padding: 4px 2px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
#projV4 .li-sum-edit:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 4px; }
#projV4 .li-sum-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; }
#projV4 .li-sum-add-lbl { font-size: 12.5px; color: var(--text2); }
#projV4 .li-sum-chips { display: flex; flex-wrap: wrap; gap: 6px; }
#projV4 .li-chip {
  font: inherit; font-size: 12.5px; font-weight: 500; color: var(--text2);
  background: var(--surface); border: 1px solid var(--border2); border-radius: 999px;
  padding: 5px 11px; cursor: pointer; transition: border-color .15s, color .15s;
}
#projV4 .li-chip:hover { color: var(--text); border-color: var(--accent-ink); }
#projV4 .li-chip-on { color: var(--accent-ink); border-color: var(--accent-ink); }
#projV4 .li-chip:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
#projV4 .li-sum-host { margin-top: 14px; }

/* The takeoff's own "+ Add custom cost" (and its bare list) inside the
   Project page. It was meant to be hidden here (style.css ~2483) but a later
   rule in the same file gives every .tov2-add-link display:block, so the
   Joints section still offered a second, different way to add a cost. Those
   costs are listed and edited on the "Takeoff custom costs" card now. */
#projV4 #pv4TakeoffHost .tov2-add-link[data-tov2-extras-add],
#projV4 #pv4TakeoffHost [data-tov2-extras-list],
#projV4 #pv4TakeoffHost [data-tov2-extras-form] { display: none; }
