/*
 * Product tracking screens: variants (option sets in Options > Products, the Variants card of the product form, the stock matrix), batches / expiry, serial numbers.
 * Loaded automatically (templates/boot-material/css/ux/*.css). Markup: includes/functions/tracking_ui.php + includes/scripts/ux/50-tracking-*.js.
 * Uses the design tokens of fm-ui.css (--fm-*). Everything is mobile first: the variant matrix turns into stacked cards below 700px.
 */

/* ---------- shared bits ---------- */
.fmtv-muted { color: var(--fm-muted, #6b7689); }
.fmtv-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--fm-line, #e4e8f0); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; line-height: 1.3; user-select: none; transition: background .12s, border-color .12s; }
.fmtv-chip:hover { border-color: var(--fm-primary-100, #c9e8f7); background: var(--fm-primary-50, #e9f6fd); }
.fmtv-chip input { position: absolute; opacity: 0; pointer-events: none; }
.fmtv-chip.is-on { background: var(--fm-primary-50, #e9f6fd); border-color: var(--fm-accent, #0ea5e9); color: var(--fm-primary-600, #075985); font-weight: 600; }
.fmtv-chip:focus-within { outline: 3px solid rgba(14, 165, 233, .35); outline-offset: 1px; }
.fmtv-sw { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15); flex: 0 0 14px; }
.fmtv-count { font-size: 12px; font-weight: 600; color: var(--fm-primary-600, #075985); background: var(--fm-primary-50, #e9f6fd); border-radius: 999px; padding: 1px 9px; margin-left: 6px; vertical-align: middle; }
.fmpl-vchip { display: inline-flex; align-items: center; gap: 4px; color: var(--fm-primary-600, #075985); background: var(--fm-primary-50, #e9f6fd); border-radius: 999px; padding: 0 8px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }

/* ---------- Variants card ---------- */
.fmtv-intro { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; background: var(--fm-bg, #f2f7fb); border-radius: 14px; padding: 14px 16px; }
.fmtv-intro p { margin: 0; flex: 1 1 260px; color: var(--fm-ink-2, #3a4560); }
.fmtv-opt { border: 1px solid var(--fm-line, #e4e8f0); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.fmtv-opt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.fmtv-opt-head .form-select { max-width: 220px; }
.fmtv-opt-head .fmtv-all { margin-left: auto; font-size: 12.5px; }
.fmtv-vals { display: flex; flex-wrap: wrap; gap: 6px; }
.fmtv-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.fmtv-bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 10px 0; padding: 10px 12px; background: var(--fm-bg, #f2f7fb); border-radius: 12px; }
.fmtv-bulk label { font-size: 12px; font-weight: 600; color: var(--fm-ink-2, #3a4560); display: block; }
.fmtv-bulk .form-control { width: 110px; padding: 5px 8px; }
.fmtv-dirty { color: var(--fm-warning, #b45309); font-size: 12.5px; font-weight: 600; }

.fmtv-matrix { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.fmtv-matrix th { text-align: left; color: var(--fm-muted, #6b7689); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--fm-line, #e4e8f0); white-space: nowrap; }
.fmtv-matrix td { padding: 6px 6px; border-bottom: 1px solid var(--fm-line-2, #eef1f6); vertical-align: middle; }
.fmtv-matrix .form-control { padding: 5px 8px; min-width: 70px; font-size: 13px; }
.fmtv-matrix input[data-f=sku] { min-width: 130px; }
.fmtv-matrix input[data-f=barcode] { min-width: 120px; }
.fmtv-matrix tr.is-off td { opacity: .55; }
.fmtv-matrix tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--fm-accent, #0ea5e9); }
.fmtv-lab { font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 7px; }
.fmtv-lab small { font-weight: 500; color: var(--fm-muted, #6b7689); }
.fmtv-stock { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.fmtv-imgbtn { border: 1px dashed var(--fm-line, #e4e8f0); border-radius: 8px; width: 34px; height: 34px; background: #fff; display: inline-flex; align-items: center; justify-content: center; color: var(--fm-muted, #6b7689); cursor: pointer; padding: 0; overflow: hidden; }
.fmtv-imgbtn img { width: 100%; height: 100%; object-fit: cover; }
.fmtv-imgpop { position: absolute; z-index: 80; background: #fff; border: 1px solid var(--fm-line, #e4e8f0); border-radius: 12px; box-shadow: var(--fm-shadow-lg, 0 12px 32px rgba(20, 30, 60, .16)); padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 260px; }
.fmtv-imgpop button { border: 2px solid transparent; border-radius: 8px; padding: 0; width: 48px; height: 48px; overflow: hidden; background: #f3f4f6; cursor: pointer; }
.fmtv-imgpop button img { width: 100%; height: 100%; object-fit: cover; }
.fmtv-imgpop button:hover { border-color: var(--fm-accent, #0ea5e9); }

/* stock matrix in the Inventory card */
.fmtv-stock .is-zero, .fmtv-matrix .is-zero { color: var(--fm-muted, #6b7689); }
.fmtv-stock tr.fmtv-total td { border-top: 2px solid var(--fm-line, #e4e8f0); background: var(--fm-bg, #f2f7fb); }
.fmtv-stock tr.is-off td { opacity: .65; }

/* ---------- phone: the matrix becomes one card per variant ---------- */
@media (max-width: 700px) {
	.fmtv-matrix thead { display: none; }
	.fmtv-matrix, .fmtv-matrix tbody { display: block; }
	.fmtv-matrix tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--fm-line, #e4e8f0); border-radius: 14px; background: #fff; }
	.fmtv-matrix td { display: block; border: 0; padding: 0; }
	.fmtv-matrix td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--fm-muted, #6b7689); margin-bottom: 3px; }
	.fmtv-matrix td.fmtv-c-label { grid-column: 1 / -1; }
	.fmtv-matrix .form-control { width: 100%; min-width: 0; }
	.fmtv-matrix td.fmtv-c-wide { grid-column: 1 / -1; }
	.fmtv-bulk .form-control { width: 90px; }
	.fmtv-stock { font-size: 13px; }
}

/* ---------- Options > Products (option sets) ---------- */
.fmto-wrap { max-width: 980px; margin: 0 auto 40px; }
.fmto-card { background: #fff; border: 1px solid var(--fm-line, #e4e8f0); border-radius: 16px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--fm-shadow-sm, 0 1px 2px rgba(20, 30, 60, .06)); }
.fmto-card h2 { font: 700 18px 'Plus Jakarta Sans', Inter, sans-serif; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.fmto-card > p { color: var(--fm-muted, #6b7689); margin: 0 0 14px; }
.fmto-set { border: 1px solid var(--fm-line, #e4e8f0); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; background: var(--fm-bg, #f2f7fb); }
.fmto-set-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fmto-set-head h3 { font: 700 15px Inter, sans-serif; margin: 0; }
.fmto-set-head .fmto-sp { margin-left: auto; display: flex; gap: 6px; }
.fmto-vals { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fmto-val { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--fm-line, #e4e8f0); border-radius: 999px; padding: 3px 11px; font-size: 13px; }
.fmto-edit-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 90px 56px 34px; gap: 8px; align-items: center; margin-bottom: 6px; }
.fmto-edit-row .form-control { padding: 6px 9px; }
.fmto-edit-row input[type=color] { width: 56px; height: 34px; padding: 2px; border: 1px solid var(--fm-line, #e4e8f0); border-radius: 8px; background: #fff; }
.fmto-edit-row .fmto-grip { color: var(--fm-muted, #6b7689); text-align: center; cursor: grab; }
.fmto-form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.fmto-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.fmto-field { margin-bottom: 14px; }
.fmto-field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--fm-ink-2, #3a4560); }
.fmto-field small { display: block; color: var(--fm-muted, #6b7689); font-size: 12px; margin-top: 4px; }
.fmto-empty { text-align: center; padding: 26px 12px; color: var(--fm-muted, #6b7689); }
@media (max-width: 700px) {
	.fmto-grid2 { grid-template-columns: 1fr; }
	.fmto-edit-row { grid-template-columns: minmax(0, 1fr) 70px 50px 32px; }
	.fmto-edit-row .fmto-grip { display: none; }
}

/* ---------- batches / expiry ---------- */
.fmtb-chip { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.fmtb-ok { background: var(--fm-success-bg, #e7f6ec); color: var(--fm-success, #15803d); }
.fmtb-soon { background: var(--fm-warning-bg, #fef3dc); color: var(--fm-warning, #b45309); }
.fmtb-exp { background: var(--fm-danger-bg, #fdeaea); color: var(--fm-danger, #b91c1c); }
.fmtb-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.fmtb-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.fmtb-stats > div { background: var(--fm-bg, #f2f7fb); border-radius: 12px; padding: 8px 14px; }
.fmtb-stats small { display: block; color: var(--fm-muted, #6b7689); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.fmtb-stats b { font: 700 18px 'Plus Jakarta Sans', Inter, sans-serif; }
.fmtb-h { font: 700 14px Inter, sans-serif; margin: 16px 0 6px; }
.fmtt-sw { margin-bottom: 8px; }
.fmtt-sub { margin: 0 0 8px 56px; }
.fmtt-table td small { font-size: 11.5px; }
.fmtd-extra { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--fm-line, #e4e8f0); border-radius: 12px; background: var(--fm-bg, #f2f7fb); }
.fmtd-extra .form-label { font-size: 12.5px; font-weight: 600; margin-bottom: 3px; }

/* ---------- document form: receive drawer batches, batch picker on a line ---------- */
.fo-trk { margin-top: 6px; max-width: 260px; }
.fo-recv-trk > td { background: var(--fm-bg, #f2f7fb); padding: 8px 12px !important; }
.fo-rtb { margin-bottom: 8px; }
.fo-rtb-title { font-size: 12.5px; font-weight: 600; color: var(--fm-ink-2, #3a4560); margin-bottom: 4px; }
.fo-rtb-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 90px 32px; gap: 6px; margin-bottom: 4px; align-items: center; }
.fo-rtb-row .form-control { padding: 5px 8px; font-size: 13px; }
@media (max-width: 700px) { .fo-rtb-row { grid-template-columns: 1fr 1fr; } .fo-rtb-row [data-rtb=qty] { grid-column: 1 / 2; } }

/* ---------- serial numbers ---------- */
.fo-ser { margin: 6px 0 10px; }
.fo-ser-title { font-size: 12.5px; font-weight: 600; color: var(--fm-ink-2, #3a4560); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.fo-ser-count { margin-left: auto; font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 999px; background: var(--fm-neutral-bg, #eef1f6); color: var(--fm-muted, #6b7689); }
.fo-ser-count.is-ok { background: var(--fm-success-bg, #e7f6ec); color: var(--fm-success, #15803d); }
.fo-ser-count.is-bad { background: var(--fm-warning-bg, #fef3dc); color: var(--fm-warning, #b45309); }
.fo-ser textarea { font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.fo-ser-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.fo-ser-tools .form-control { max-width: 220px; padding: 5px 8px; font-size: 13px; }
.fmts-row { cursor: pointer; }
.fmts-row:hover, .fmts-row:focus-visible { background: var(--fm-primary-50, #e9f6fd); outline: none; }
