/* =====================================================================
   Prime Car — Showroom tables (2026-10-22). Rows become soft cards on the
   card surface, columns size to their content (no fixed % squeeze),
   identity cells keep their lines instead of clipping, and on phones every
   plain table (not only .lv-t) becomes labelled cards — showroom.js cardify().
   ===================================================================== */
[data-theme="showroom"] table.lv-t,
[data-theme="showroom"] .table { table-layout: auto; border-collapse: separate; border-spacing: 0 6px; }
[data-theme="showroom"] .lv-wrap, [data-theme="showroom"] .table-scroll { padding: 0 14px 8px; }
[data-theme="showroom"] .lv-t th,
[data-theme="showroom"] .table thead th { background: transparent; border: 0; padding: 12px 16px 4px; font-size: 12px; font-weight: 600; color: var(--pc-muted); white-space: nowrap; letter-spacing: 0; text-transform: none; }
[data-theme="showroom"] .lv-t td,
[data-theme="showroom"] .table tbody td { background: var(--pc-surface-2); border: 0; padding: 12px 14px; height: 64px; line-height: 1.45; transition: background .15s; }
/* physical corners: a dir="ltr" cell (dates, numbers) would flip logical ones */
:root[data-theme="showroom"][dir="rtl"] :is(.lv-t, .table) tbody tr > :first-child,
:root[data-theme="showroom"][dir="ltr"] :is(.lv-t, .table) tbody tr > :last-child { border-top-right-radius: 18px; border-bottom-right-radius: 18px; }
:root[data-theme="showroom"][dir="rtl"] :is(.lv-t, .table) tbody tr > :last-child,
:root[data-theme="showroom"][dir="ltr"] :is(.lv-t, .table) tbody tr > :first-child { border-top-left-radius: 18px; border-bottom-left-radius: 18px; }
/* a row header (<th> in tbody) belongs to the row card */
[data-theme="showroom"] :is(.lv-t, .table) tbody th { background: var(--pc-surface-2); border: 0; padding: 12px 14px; font-weight: 600; text-align: start; color: var(--pc-ink); }
[data-theme="showroom"] .lv-t tbody tr:hover,
[data-theme="showroom"] .table tbody tr:hover { background: transparent; }
[data-theme="showroom"] .lv-t tbody tr:hover td,
[data-theme="showroom"] .table tbody tr:hover td { background: var(--pc-primary-050); }
[data-theme="showroom"] .lv-t tbody tr:hover td:first-child::before { display: none; }
[data-theme="showroom"] .table tfoot td { padding: 12px 16px; border: 0; font-weight: 700; }
/* column widths come from the content: ids, dates and numbers never wrap, names get room */
[data-theme="showroom"] .lv-t th[style*="width"], [data-theme="showroom"] .table th[style*="width"] { width: auto !important; }
[data-theme="showroom"] .lv-t td.c-meta, [data-theme="showroom"] .lv-t td.c-num, [data-theme="showroom"] .lv-t td.c-time,
[data-theme="showroom"] .lv-t td.c-status, [data-theme="showroom"] .lv-t td.c-act,
[data-theme="showroom"] .table td.num, [data-theme="showroom"] .table td.mono { white-space: nowrap; width: 1%; }
[data-theme="showroom"] .lv-t td.c-name { min-width: 260px; }
[data-theme="showroom"] .lv-t td.c-owner { min-width: 150px; }
[data-theme="showroom"] .idn .t b,
[data-theme="showroom"] .idn .t span { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
[data-theme="showroom"] .idn .t span { margin-top: 2px; }
[data-theme="showroom"] .owner .nm, [data-theme="showroom"] .lv-t .truncate { white-space: normal; overflow: visible; text-overflow: clip; }
[data-theme="showroom"] .lv-act { width: 38px; height: 38px; border-radius: 50%; background: var(--pc-surface); border-color: var(--pc-line-strong); }
[data-theme="showroom"] .lv-foot { border-top: 0; }

/* car identity: the car itself, painted, instead of a generic icon */
[data-theme="showroom"] .idn__ic--paint { width: 64px; height: 40px; border-radius: 12px; background: var(--pc-surface); box-shadow: none; padding: 4px 3px 2px; }
[data-theme="showroom"] .idn__car { display: block; width: 100%; height: 100%; overflow: visible; }
:root[data-theme="showroom"][dir="ltr"] .idn__car { transform: scaleX(-1); }
[data-theme="showroom"] .car-ident .t b small.car-ident__meta { display: block; margin-top: 1px; font-size: 12px; font-weight: 500; }
[data-theme="showroom"] .car-ident__sub { display: flex !important; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
[data-theme="showroom"] .car-ident__st { margin: 0; padding: 2px 9px; font-size: 11px; white-space: nowrap; }
[data-theme="showroom"] .car-ident__vin { font-family: var(--pc-mono); font-size: 11.5px; color: var(--pc-body); }

/* toolbar: search gets room, buttons never squeeze */
[data-theme="showroom"] .lv-head { flex-wrap: wrap; row-gap: 12px; }
[data-theme="showroom"] .lv-tools { flex-wrap: wrap; row-gap: 8px; }
[data-theme="showroom"] .lv-tools .srch { flex: 1 1 280px; min-width: 240px; }
[data-theme="showroom"] .lv-tools .btn, [data-theme="showroom"] .lv-tools .lv-select { white-space: nowrap; }

/* ---------- phones: every table is a stack of labelled cards ---------- */
@media (max-width: 760px) {
    [data-theme="showroom"] .lv-wrap, [data-theme="showroom"] .table-scroll { padding: 0 0 6px; }
    [data-theme="showroom"] table.lv-t, [data-theme="showroom"] table.sr-cards { border-spacing: 0; }
    [data-theme="showroom"] .lv-t tbody tr,
    [data-theme="showroom"] table.sr-cards tbody tr { border: 0; border-radius: 22px; background: var(--pc-surface-2); box-shadow: none; padding: 12px 16px; margin: 0 12px 10px; }
    [data-theme="showroom"] .lv-t td,
    [data-theme="showroom"] table.sr-cards td { background: transparent !important; border-radius: 0 !important; height: auto; padding: 8px 0; width: auto !important; white-space: normal; }
    [data-theme="showroom"] .lv-t td + td,
    [data-theme="showroom"] table.sr-cards td + td { border-top: 1px solid var(--pc-line); }
    [data-theme="showroom"] .lv-t td.c-name, [data-theme="showroom"] .lv-t td.c-name + td { border-top: 0; }
    [data-theme="showroom"] .lv-t td > *, [data-theme="showroom"] table.sr-cards td > * { min-width: 0; }
    [data-theme="showroom"] .lv-t td.c-name { min-width: 0; padding-bottom: 12px; border-bottom: 1px solid var(--pc-line); }
    [data-theme="showroom"] .lv-t td.c-owner { min-width: 0; }
    [data-theme="showroom"] .lv-t td[data-label]::before,
    [data-theme="showroom"] table.sr-cards td[data-label]::before { font-size: 12px; font-weight: 500; max-width: 42%; line-height: 1.4; }

    [data-theme="showroom"] table.sr-cards { display: block; min-width: 0 !important; width: 100%; }
    [data-theme="showroom"] table.sr-cards thead { display: none; }
    [data-theme="showroom"] table.sr-cards tbody, [data-theme="showroom"] table.sr-cards tfoot { display: block; }
    [data-theme="showroom"] table.sr-cards tbody tr { margin-inline: 0; }
    [data-theme="showroom"] table.sr-cards tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 10px 16px; }
    [data-theme="showroom"] table.sr-cards tfoot td { padding: 0; }
    [data-theme="showroom"] table.sr-cards td { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: end; }
    [data-theme="showroom"] table.sr-cards td[data-label]::before { content: attr(data-label); color: var(--pc-muted); text-align: start; flex: none; }
    [data-theme="showroom"] table.sr-cards td:empty { display: none; }
    [data-theme="showroom"] table.sr-cards td:first-child { font-weight: 600; }
    [data-theme="showroom"] .table-wrap:has(table.sr-cards) { overflow: visible; }
    [data-theme="showroom"] .table-scroll:has(table.sr-cards) { overflow: visible; }
}

/* desktop: a cell holds one line — the table scrolls sideways rather than stacking words */
@media (min-width: 761px) {
    [data-theme="showroom"] .lv-t td:not(.c-name):not(.wrap),
    [data-theme="showroom"] .table td:not(.wrap):not(:has(p, textarea, ul)) { white-space: nowrap; }
    [data-theme="showroom"] .lv-t td .truncate, [data-theme="showroom"] .table td .truncate { white-space: nowrap; }
    [data-theme="showroom"] .lv-wrap, [data-theme="showroom"] .table-scroll { scrollbar-width: thin; }
}
/* inventory list (showroom view) */
[data-theme="showroom"] .sr-inv__loc > span:first-child { display: block; color: var(--pc-body); }
[data-theme="showroom"] .sr-inv__loc .pill { margin-top: 4px; }
[data-theme="showroom"] .sr-inv__docs { display: table-cell; }
[data-theme="showroom"] .sr-doc { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--pc-surface); color: var(--pc-muted); white-space: nowrap; }
[data-theme="showroom"] .sr-doc + .sr-doc { margin-inline-start: 6px; }
[data-theme="showroom"] .sr-doc .icon { width: 14px; height: 14px; }
[data-theme="showroom"] .sr-doc.is-ok { background: var(--pc-ok-tint); color: var(--pc-ok-ink); }
[data-theme="showroom"] .sr-doc.is-no { background: var(--pc-err-tint); color: var(--pc-err-ink); }
[data-theme="showroom"] .sr-aged { color: var(--pc-err-ink); font-weight: 700; }
@media (max-width: 760px) {
    [data-theme="showroom"] .sr-inv__docs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
    [data-theme="showroom"] .sr-inv__docs::before { margin-inline-end: auto; }
    [data-theme="showroom"] .sr-doc + .sr-doc { margin: 0; }
    [data-theme="showroom"] .sr-inv__loc { flex-wrap: wrap; }
}

/* phones: cards are a 2-column grid of «label over value» — half the height of one-field-per-row */
@media (max-width: 760px) {
    [data-theme="showroom"] .lv-t tbody tr,
    [data-theme="showroom"] table.sr-cards tbody tr { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; row-gap: 0; }
    [data-theme="showroom"] .lv-t tbody td,
    [data-theme="showroom"] table.sr-cards tbody td { display: flex !important; flex-direction: column !important; align-items: flex-start !important; justify-content: flex-start !important; gap: 2px !important; text-align: start !important; padding: 8px 0 !important; border-top: 1px solid var(--pc-line) !important; min-width: 0; }
    :root[dir="rtl"][data-theme="showroom"] :is(.lv-t, table.sr-cards) tbody td[dir="ltr"] { align-items: flex-end !important; }
    [data-theme="showroom"] :is(.lv-t, table.sr-cards) tbody td[data-label]::before { max-width: none !important; font-size: 11.5px !important; }
    [data-theme="showroom"] :is(.lv-t, table.sr-cards) tbody td > * { max-width: 100%; }
    /* identity, actions, long text and a lone last cell take the full width */
    [data-theme="showroom"] .lv-t tbody td.c-name,
    [data-theme="showroom"] .lv-t tbody td.c-act,
    [data-theme="showroom"] :is(.lv-t, table.sr-cards) tbody td.wrap,
    [data-theme="showroom"] :is(.lv-t, table.sr-cards) tbody td:has(p, textarea, ul, .idn),
    [data-theme="showroom"] table.sr-cards tbody td:first-child { grid-column: 1 / -1; }
    [data-theme="showroom"] .lv-t tbody td.c-name, [data-theme="showroom"] table.sr-cards tbody td:first-child { border-top: 0 !important; padding-top: 0 !important; }
    [data-theme="showroom"] .lv-t tbody td.c-act { flex-direction: row !important; justify-content: flex-end !important; align-items: center !important; }
    [data-theme="showroom"] :is(.lv-t, table.sr-cards) tbody td:empty { display: none !important; }
}
