/* The board VIN: two tabs, the car picker, the switch "ИИ", the tree of the parts and the list under a node. Colors and sizes are the tokens. */

/* ---- The bar with the tabs and the switch ---- */
.vb { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.vb-body { min-width: 0; }
.vb-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.vb-bar.is-oil .vb-ai { display: none; }
.vb-tabs button { padding: 0 16px; }

/* ---- The switch ---- */
.switch { display: inline-flex; align-items: center; gap: 8px; height: var(--h-md); padding: 0 6px 0 12px; border-radius: 99px; background: var(--raised); color: var(--text-2); font-weight: 600; font-size: var(--fs-caption); letter-spacing: .04em; }
.switch:hover { background: var(--raised-hover); }
.switch-track { position: relative; width: 34px; height: 20px; border-radius: 99px; background: var(--line); transition: background var(--dur) var(--ease); }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform var(--dur) var(--ease), background var(--dur) var(--ease); }
.switch.is-on { color: var(--text); }
.switch.is-on .switch-track { background: var(--primary); }
.switch.is-on .switch-knob { transform: translateX(14px); background: var(--on-primary); }

/* ---- The car picker ---- */
.cp { display: grid; gap: 10px; }
.cp-seg { width: 100%; }
.cp-fields { display: grid; gap: 8px; }
.cp-fields.is-model { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cp-field { display: grid; gap: 4px; }
.cp-label { font-size: var(--fs-caption); color: var(--text-3); }
.cp-body .select, .cp-body .input { background: var(--surface); }

/* ---- The AI panel ---- */
.ai-panel .vin-label { justify-content: flex-start; }
.ai-pill { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--surface); color: var(--text-2); }
.ai-pill.is-busy { color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.ai-pill.is-off { color: var(--text-3); }
.ai-form { display: grid; gap: 10px; }
.ai-form[hidden], .ai-panel p[hidden] { display: none; }
.ai-status:empty { display: none; }
.ai-status .is-error, .vin-muted.is-error { color: var(--danger); }
.ai-wait { display: flex; align-items: center; gap: 8px; font-size: var(--fs-caption); color: var(--text-2); padding: 10px 12px; background: var(--surface); border-radius: var(--r-md); }
.ai-wait.is-line { align-items: flex-start; box-shadow: inset 0 0 0 1px var(--line); }
.ai-wait.is-line .vin-spin { margin-top: 4px; }
.ai-wait-text { display: grid; gap: 2px; flex: 1; min-width: 0; line-height: 1.4; }
.ai-wait-text strong { color: var(--text); font-weight: 600; }

/* ---- The board ---- */
/* the car and the AI stand side by side on top; the tree and the parts take the whole width under them */
.vin-board.pb { grid-template-columns: minmax(0, 1fr); }
.vin-board.pb .vin-side { grid-template-columns: repeat(2, minmax(0, 1fr)); position: static; align-items: start; }
.pb-main { align-content: start; }
.pb-head:empty, .pb-ai:empty { display: none; }
.pb-car { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pb-car .btn { margin-left: auto; }
.pb-split { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 16px; align-items: start; }
.pb-split[hidden] { display: none; }
.pb-tree { position: sticky; top: 0; max-height: calc(100vh - 150px); overflow: auto; background: var(--raised); border-radius: var(--r-lg); padding: 6px; }
.pb-list { min-width: 0; }

/* the answer of the AI */
.pb-ai-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 16px; background: var(--raised); border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent); }
.pb-ai-card.is-none { box-shadow: none; }
.pb-ai-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--surface); color: var(--text-2); }
.pb-ai-icon svg { width: 16px; height: 16px; }
.pb-ai-text { display: grid; gap: 8px; min-width: 0; }
.pb-ai-text p { line-height: 1.45; }
.pb-ai-ask { color: var(--text-2); }
.pb-ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pb-ai-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.pb-ai-chip svg { width: 12px; height: 12px; flex: none; }
.pb-ai-chip.is-first { background: var(--selected); color: var(--on-selected); }

/* ---- The tree ---- */
.pt { display: grid; gap: 1px; }
.pt-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto auto; align-items: center; gap: 6px; min-height: 30px; padding: 0 8px 0 calc(6px + var(--depth, 0) * 14px); border-radius: var(--r-sm); color: var(--text-2); cursor: pointer; user-select: none; }
.pt-row:hover { background: var(--raised-hover); color: var(--text); }
.pt-row.is-selected { background: var(--selected); color: var(--on-selected); }
.pt-row:focus-visible { outline: 1.5px solid var(--text-2); outline-offset: -1.5px; }
.pt-row[aria-expanded] { color: var(--text); }
.pt-chev { display: grid; place-items: center; width: 16px; height: 16px; color: var(--text-3); }
.pt-chev svg { width: 12px; height: 12px; transition: transform var(--dur) var(--ease); }
.pt-row.is-open > .pt-chev svg { transform: rotate(90deg); }
.pt-name { overflow-wrap: anywhere; line-height: 1.3; padding: 5px 0; font-size: var(--fs-body); }
.pt-count { font-size: 11px; color: var(--text-3); }
.pt-row.is-selected .pt-count { color: inherit; opacity: .7; }
.pt-ai { display: none; color: var(--text); }
.pt-ai svg { width: 12px; height: 12px; }
.pt-row.is-ai .pt-ai { display: inline-grid; }
.pt-row.is-ai:not(.is-selected) { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--text); }
.pt-row.has-ai:not(.is-open) .pt-chev::after { content: ""; position: absolute; width: 5px; height: 5px; margin: -9px -9px 0 0; border-radius: 50%; background: var(--text); }
.pt-chev { position: relative; }
.pt-kids[hidden] { display: none; }

/* ---- The parts ---- */
.pl { display: grid; gap: 10px; }
.pl-head { display: grid; gap: 8px; }
.pl-crumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; font-size: var(--fs-caption); color: var(--text-3); }
.pl-crumb + .pl-crumb::before { content: "›"; margin-right: 4px; }
.pl-crumb.is-last { color: var(--text); font-size: var(--fs-title); font-weight: 600; }
.pl-bar .vin-stat:empty { display: none; }
.pl-bar { display: flex; align-items: center; gap: 10px; }
.pl-filter { margin-left: auto; width: min(240px, 100%); }
.pl-body { display: grid; gap: 14px; }
.pl-group { display: grid; gap: 6px; }
.pl-group-name { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-caption); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.pl-rows { display: grid; gap: 4px; }
.pl-row { display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 40px; padding: 4px 10px; background: var(--raised); border-radius: var(--r-md); }
.pl-row .copy { justify-self: start; font-weight: 600; }
.pl-name { line-height: 1.35; overflow-wrap: anywhere; font-size: var(--fs-body); }
.pl-tags { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.pl-orig { color: var(--text); }
.pl-empty { padding: 48px 16px; }
.pl-rows > .vin-card.is-skeleton { min-height: 40px; }

/* ---- Narrow screens ---- */
@media (max-width: 1100px) {
  .pb-split { grid-template-columns: minmax(0, 1fr); }
  .pb-tree { position: static; max-height: 320px; }
}
@media (max-width: 899px) { .cp-fields.is-model { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .cp-fields.is-model { grid-template-columns: minmax(0, 1fr); }
  .pl-row { grid-template-columns: minmax(0, 1fr) auto; }
  .pl-name { grid-column: 1 / -1; grid-row: 2; }
  .pl-tags { grid-column: 2; grid-row: 1; }
  .pl-filter { width: 100%; }
  .pl-bar { flex-wrap: wrap; }
}
