/* Product options (variants) and shipping prices (docs/variants-shipping.md):
   views/product_options.js (the product editor's options and combinations), views/shipping.js (Store ›
   Shipping prices), views/variants.js (an order line's options, the delivery type), the order edit
   dialog's combination picker. The call center site links it too (order lines, order edit). */

/* ---- shared --------------------------------------------------------------------------------------- */
.vs-swatch {
  display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 22%, transparent); vertical-align: -2px;
}
.vs-switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 0; cursor: pointer;
  width: 36px; height: 21px; border-radius: 999px; background: var(--line-strong); transition: background .15s ease;
}
.vs-switch::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: inset-inline-start .15s ease;
}
.vs-switch:checked { background: var(--accent); }
.vs-switch:checked::after { inset-inline-start: 18px; }
.vs-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vs-switch:disabled { cursor: default; opacity: .5; }
.vs-switch.sm { width: 30px; height: 18px; }
.vs-switch.sm::after { width: 12px; height: 12px; }
.vs-switch.sm:checked::after { inset-inline-start: 15px; }
@media (prefers-reduced-motion: reduce) { .vs-switch, .vs-switch::after { transition: none; } }

/* hints outside a .field (app.css styles those) */
:is(.vs-options, .sg-form, .sg-move) .hint, .vs-opening-note { font-size: 12px; color: var(--muted); }

/* an order line's options ("Red · M") */
.item-opts { font-size: 12.5px; font-weight: 550; color: var(--ink-2); overflow-wrap: anywhere; }
/* the delivery type on the order page */
.dlv-type { display: inline-flex; align-items: center; gap: 6px; }
.dlv-type.dlv-desk { color: var(--accent); }

/* ---- product editor: options --------------------------------------------------------------------- */
.vs-options { gap: 10px; }
.vs-options.invalid { border-color: var(--crit); }
.vs-options-h { gap: 8px; }
.vs-opt-list { display: flex; flex-direction: column; gap: 10px; }
.vs-opt-list:empty { display: none; }
.vs-opt {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.vs-opt-h { display: flex; align-items: center; gap: 8px; min-width: 0; }
.vs-opt-n {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 650;
}
.vs-opt-name-wrap { min-width: 0; max-width: 340px; }
.vs-opt-name-wrap .input { width: 100%; font-weight: 600; }
.vs-opt-tools { gap: 2px; flex: none; }

/* suggestions under an input (names and values) */
.vs-combo { position: relative; min-width: 0; }
.vs-combo > .input { width: 100%; }
.vs-combo-list {
  position: absolute; z-index: 30; inset-inline: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto;
  padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-lg);
}
.vs-combo-opt { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; cursor: pointer; min-width: 0; }
.vs-combo-opt > .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-combo-opt > .muted { flex: none; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-combo-opt:hover, .vs-combo-opt[aria-selected="true"] { background: var(--accent-soft); }
.vs-combo-opt[aria-disabled="true"] { opacity: .5; cursor: default; }
.vs-combo-opt.is-custom { color: var(--accent); font-weight: 550; }
.vs-combo-plus { flex: none; width: 14px; text-align: center; }

/* an option's values: a small editable table (value, swatch, price, what it comes to, remove / add) */
.vs-opt { container: vs-opt / inline-size; }
.vs-vtable {
  width: 100%; border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.vs-vtable th {
  padding: 6px 10px; text-align: start; font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.vs-vtable thead th:first-child { border-start-start-radius: var(--radius-sm); }
.vs-vtable thead th:last-child { border-start-end-radius: var(--radius-sm); }
.vs-vtable td { padding: 5px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.vs-vtable tbody tr:last-child td { border-bottom: 0; }
.vs-vtable tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.vs-vtable tfoot td { background: var(--surface-2); border-top: 1px dashed var(--line-strong); border-bottom: 0; }
.vs-vtable tbody:empty + tfoot td { border-top: 0; }
.vs-vtable tfoot td:first-child { border-end-start-radius: var(--radius-sm); }
.vs-vtable tfoot td:last-child { border-end-end-radius: var(--radius-sm); }
.vs-vtable .input { height: 32px; }
.vs-vtable .vs-color { height: 32px; width: 36px; }
.vs-vt-value { width: 100%; min-width: 140px; }
.vs-vt-in { width: 100%; font-weight: 550; }
.vs-vt-sw, .vs-vt-price, .vs-vt-total, .vs-vt-x { width: 1%; white-space: nowrap; }
.vs-vtable .vs-vt-total, .vs-vtable .vs-vt-x { text-align: end; }
.vs-vt-rm { color: var(--muted); }
.vs-vt-rm:hover { color: var(--crit-ink); background: var(--crit-soft); }
.vs-vt-ro { gap: 6px; flex-wrap: nowrap; }
.vs-vt-more { display: flex; }
.vs-is-add { color: var(--good-ink); font-weight: 600; }
.vs-is-set { color: var(--accent); font-weight: 600; }

/* a value's price: "+ Extra" / "= Own price", the amount, and what the buyer pays with it */
.vs-pricef { display: flex; align-items: center; gap: 6px; }
.vs-pmode { flex: none; }
.vs-pmode button { white-space: nowrap; }
.vs-amount { width: 130px; min-width: 0; }
.vs-amount > b { padding-inline: 10px 2px; }
.vs-total { font-weight: 650; color: var(--ink); white-space: nowrap; }
.vs-total.is-base { font-weight: 450; color: var(--muted); }
.vs-color { width: 40px; height: 34px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; flex: none; }

/* a narrow card: each value is a small block (swatch, value, x; then the price and what it comes to) */
@container vs-opt (max-width: 600px) {
  .vs-vtable thead { display: none; }
  .vs-vtable, .vs-vtable tbody, .vs-vtable tfoot { display: block; }
  .vs-vtable tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "sw value x" "price price total";
    gap: 6px 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line);
  }
  .vs-vtable tbody tr:last-child { border-bottom: 0; }
  .vs-vtable td, .vs-vtable tfoot td, .vs-vtable tbody tr:hover td { display: block; width: auto; min-width: 0; padding: 0; border: 0; background: none; }
  .vs-vtable tfoot tr { background: var(--surface-2); border-top: 1px dashed var(--line-strong); border-bottom: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
  .vs-vtable tbody:empty + tfoot tr { border-top: 0; border-radius: var(--radius-sm); }
  .vs-vt-sw { grid-area: sw; }
  .vs-vt-value { grid-area: value; }
  .vs-vt-x { grid-area: x; }
  .vs-vt-price { grid-area: price; }
  .vs-vt-total { grid-area: total; }
  .vs-vt-price .vs-pricef { flex-wrap: wrap; }
}

.vs-adders { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.vs-adders-t { margin-inline-end: 4px; }
.vs-adder { max-width: 220px; }
.vs-adder span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-err { font-size: 12.5px; color: var(--crit-ink); }

/* the combinations */
.vs-grid-wrap { display: flex; flex-direction: column; gap: 8px; }
.vs-grid-wrap:empty { display: none; }
.vs-grid-h { gap: 6px; align-items: center; }
.vs-grid-h .section-t { margin: 0; }
.vs-table-wrap { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); max-height: 460px; overflow: auto; }
.vs-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); }
.vs-table td { padding: 7px 12px; }
.vs-table tr:last-child td { border-bottom: 0; }
.vs-table tr.is-off td:not(.vs-on) { opacity: .55; }
.vs-combo-v { gap: 4px; flex-wrap: nowrap; min-width: 0; }
.vs-combo-v b { font-weight: 600; white-space: nowrap; }
.vs-new { font-size: 11px; margin-inline-start: 4px; }
.vs-stock { gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.vs-stock .badge { font-size: 11px; }
.vs-price { align-items: flex-end; gap: 0; }
.vs-on, .vs-on-h { text-align: center; width: 1%; white-space: nowrap; }
.vs-too-many { margin: 0; }

/* product editor: the shipping group, the opening stock note */
.vs-ship-row { gap: 10px; align-items: center; }
.vs-ship-row .select { width: 100%; }
.vs-ship-manage { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.vs-ship-sum { overflow-wrap: anywhere; }
.vs-opening-note { margin: 0; display: flex; gap: 6px; align-items: baseline; }

@media (max-width: 640px) {
  .vs-opt-name-wrap { max-width: none; }
  .vs-table-wrap { max-height: none; }
  /* combinations as stacked rows: the combination, then label / value pairs */
  .vs-table thead { display: none; }
  .vs-table, .vs-table tbody, .vs-table tr, .vs-table td { display: block; width: auto; }
  .vs-table tr { padding: 8px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .vs-table tr:last-child { border-bottom: 0; }
  .vs-table td, .vs-table td.num { padding: 0; border: 0; text-align: start; }
  .vs-table td.vs-combo-c { grid-column: 1 / -1; }
  .vs-table td:not(.vs-combo-c)::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); }
  .vs-table .vs-stock, .vs-table .vs-price { justify-content: flex-start; align-items: flex-start; }
  .vs-on { width: auto; }
  .vs-ship-row { flex-wrap: wrap; }
}

/* ---- order edit: the combination picker ---------------------------------------------------------------- */
.oe-opts { display: block; min-width: 0; }
.oe-variant { height: 30px; max-width: 100%; font-size: 12.5px; margin-top: 2px; }

/* ---- shipping prices ------------------------------------------------------------------------------- */
.sg-form { gap: 16px; }
.sg-types { align-items: stretch; }
.sg-type {
  display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.sg-type.is-off .field { opacity: .55; }
.sg-type-h { gap: 10px; align-items: center; cursor: pointer; }
.sg-type .prefix { max-width: 220px; }

.sg-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.sg-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sg-tools { gap: 8px; align-items: center; }
.sg-search { width: 240px; max-width: 100%; }
.sg-bulk { gap: 4px 6px; align-items: center; }
.sg-sel { margin-inline-end: 4px; color: var(--ink-2); }
.sg-bulk-acts { gap: 6px; }

.sg-table { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); max-height: 620px; overflow: auto; }
.sg-row {
  display: grid; grid-template-columns: 28px minmax(140px, 1.2fr) 74px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: center;
  padding: 6px 10px; border-bottom: 1px solid var(--line); border-inline-start: 3px solid transparent;
}
.sg-rows .sg-row:last-child { border-bottom: 0; }
.sg-row[hidden] { display: none; }
.sg-head {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted);
  padding-top: 8px; padding-bottom: 8px;
}
.sg-row.is-selected { background: var(--accent-soft); }
.sg-row.is-off { border-inline-start-color: var(--crit); }
.sg-row.is-off .sg-name b { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.sg-row.is-partial { border-inline-start-color: var(--warn); }
.sg-pick input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.sg-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sg-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sg-code { flex: none; width: 24px; color: var(--muted); font-size: 12px; }
.sg-tag { flex: none; font-size: 11px; }
.sg-tag[hidden] { display: none; }
.sg-ships { display: flex; align-items: center; }
.sg-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sg-cell-k { display: none; }
.sg-price { flex: 1; min-width: 0; }
.sg-price .input { height: 30px; }
.sg-price .input.bad { color: var(--crit-ink); }
.sg-cell.is-custom .sg-price { border-color: var(--accent); }
.sg-cell.is-off .sg-price { opacity: .5; }
.sg-foot { padding-top: 2px; }
.sg-empty { margin: 4px 0 0; }

/* the map */
.sg-map { position: sticky; top: 8px; display: flex; flex-direction: column; gap: 8px; }
.sg-map[hidden] { display: none; }
.sg-map-svg { width: 100%; height: auto; display: block; direction: ltr; }
.sg-w { stroke: var(--surface); stroke-width: 3; cursor: pointer; transition: fill .12s; }
.sg-w.st-ok { fill: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.sg-w.st-partial { fill: color-mix(in srgb, var(--warn) 60%, var(--surface)); }
.sg-w.st-off { fill: var(--surface-3); }
.sg-w.is-sel { stroke: var(--ink); stroke-width: 7; paint-order: stroke; }
.sg-w:hover { filter: brightness(.92); }
.sg-legend { gap: 4px 12px; font-size: 12px; color: var(--ink-2); }
.sg-legend .row { gap: 5px; }
.sg-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.sg-key.st-ok { background: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.sg-key.st-partial { background: color-mix(in srgb, var(--warn) 60%, var(--surface)); }
.sg-key.st-off { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.sg-key.is-sel { box-shadow: inset 0 0 0 2px var(--ink); }
@media (prefers-reduced-motion: reduce) { .sg-w { transition: none; } }

@media (max-width: 1100px) {
  .sg-layout { grid-template-columns: minmax(0, 1fr); }
  .sg-map { position: relative; top: 0; max-width: 420px; }  /* positioned: its sr-only caption stays inside */
}
@media (max-width: 760px) {
  .sg-search { width: 100%; }
  .sg-table { max-height: none; }
  .sg-head { display: none; }
  /* each wilaya as a small card: name and its switch, then the two prices */
  .sg-row { grid-template-columns: 24px minmax(0, 1fr) auto; grid-template-areas: "pick name ships" "home home home" "desk desk desk"; gap: 6px 8px; }
  .sg-row > .sg-pick { grid-area: pick; }
  .sg-row > .sg-name { grid-area: name; }
  .sg-row > .sg-ships { grid-area: ships; }
  .sg-row > .sg-home { grid-area: home; }
  .sg-row > .sg-desk { grid-area: desk; }
  .sg-cell-k { display: block; flex: none; width: 64px; font-size: 12px; color: var(--muted); }
  .sg-name { flex-wrap: wrap; row-gap: 2px; }
  .sg-name b { white-space: normal; }
  .sg-ships .sg-cell-k { display: none; }
}
