/* LEAN-TABLES — desktop/tablet only (>=861px). Products and Orders lists show the essentials;
   the rest moves under the name / into the item, or back on with the "All columns" toggle.
   Presentation only: no data, handler or permission changes. Phones keep the card lists
   (mobile-tables.js) untouched, so every rule here is inside min-width:861px. */
@media screen and (min-width: 861px) {
  /* Products: hide Category(3) Cost(5) Profit(6) SKU(7) Date added(10) */
  .dt-products:not(.show-all) :is(th, td):is(:nth-child(7)) { display: none; } /* Date added (order: select, Product, Status, Inventory, Category, Price, Date added, Actions) */
  /* Orders: hide Channel(3) Phone(5) Items(6) Delivery(8) Payment method(9) */
  .dt-orders:not(.show-all) :is(th, td):is(:nth-child(3), :nth-child(5), :nth-child(6), :nth-child(8), :nth-child(9)) { display: none; }
  /* Secondary line under a name / badge; redundant once the full columns are showing */
  .dt-lean .cell-sub { font-size: 12px; color: var(--text-muted, #6B7280); margin-top: 2px; }
  .dt-lean .cell-sub:empty, .dt-lean.show-all .cell-sub { display: none; }
}
@media screen and (max-width: 860px) {
  .dt-lean .cell-sub, .dt-cols-toggle { display: none !important; }
}

/* LEAN-TABLES (2): clickable rows + one ⋮ menu (desktop/tablet only) */
@media screen and (min-width: 861px) {
  .dt-lean tbody tr[data-open] { cursor: pointer; }
  .dt-lean tbody tr[data-open]:hover > td { background: var(--color-bg, #F9FAFB); }
  .dt-lean .cell-actions.has-menu > :not(.cell-menu-btn) { display: none; }
  .dt-lean .cell-actions.has-menu { justify-content: flex-end; }
  .dt-lean th:last-child { width: 48px !important; font-size: 0; } /* header text stays for screen readers */
  .dt-lean td:last-child { width: 48px; }
  .dt-menu { position: fixed; z-index: 1000; min-width: 168px; padding: 4px; background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #E5E7EB); border-radius: 10px; box-shadow: 0 8px 24px rgba(17, 24, 39, .12); }
  .dt-menu[hidden] { display: none; }
  .dt-menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px;
    background: none; font: inherit; font-size: 14px; color: var(--color-text, #111827); text-align: left; cursor: pointer; }
  .dt-menu-item:hover, .dt-menu-item:focus-visible { background: var(--color-bg, #F9FAFB); outline: none; }
  .dt-menu-item.is-danger { color: #B42318; }
  .dt-menu-item .ai { width: 16px; height: 16px; }
}
@media screen and (max-width: 860px) { .dt-menu, .cell-menu-btn { display: none !important; } }

/* LEAN-TABLES (3): ONE LINE PER ROW (desktop/tablet only, >=861px). Matches the Shopify drafts list:
   the second/third lines under a name (type, SKU, phone, payment method, health badges, "reason" etc.)
   now sit on the same line, muted, and ellipsize instead of stacking. Presentation only: same markup,
   same data. Phones keep the card lists. Dashboard tables (.dash-table) are left alone. */
@media screen and (min-width: 861px) {
  table.dtable:not(.dash-table) tbody td { white-space: nowrap; }
  /* name cell: thumbnail + [name  meta  badges] on one line */
  table.dtable:not(.dash-table) .row-title { max-width: 380px; }
  table.dtable:not(.dash-table) .row-title > *:last-child { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; overflow: hidden; white-space: nowrap; }
  table.dtable:not(.dash-table) .row-title > *:last-child > * { margin: 0 !important; flex: 0 1 auto; min-width: 0; }
  table.dtable:not(.dash-table) .row-title > *:last-child > .name { flex-shrink: 0; max-width: 220px; }
  table.dtable:not(.dash-table) .row-title > *:last-child > .meta:not(:empty)::before { content: "\00b7"; margin-right: 8px; color: var(--text-faint, #9CA3AF); }
  table.dtable:not(.dash-table) .row-title > *:last-child > .meta:empty { display: none; }
  table.dtable:not(.dash-table) .row-badges { display: inline-flex; gap: 4px; flex-wrap: nowrap; flex-shrink: 0; }
  /* meta / cell-sub directly in a cell (customer + phone, payment status + method, item preview) */
  table.dtable:not(.dash-table) td > .meta, .dt-lean:not(.show-all) td > .cell-sub { display: inline-block; vertical-align: middle; max-width: 200px; margin: 0 0 0 8px; }
  table.dtable:not(.dash-table) td > .meta:empty, .dt-lean:not(.show-all) td > .cell-sub:empty { display: none; }
  /* compact thumbs so a row with an image is still a short one-liner */
  table.dtable:not(.dash-table) .row-thumb { width: 32px; height: 32px; }
}

/* LEAN-TABLES (4): professional status pills (desktop/tablet). Soft pill + leading status dot,
   one line, same colour tokens as before (success / warning / danger / info / muted). */
@media screen and (min-width: 861px) {
  table.dtable:not(.dash-table) .badge {
    display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
    padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; line-height: 18px; letter-spacing: 0;
  }
  table.dtable:not(.dash-table) .badge::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; opacity: .85;
  }
  table.dtable:not(.dash-table) .badge:has(> .ai)::before { display: none; }
  table.dtable:not(.dash-table) .badge > .ai { width: 12px; height: 12px; }
}

/* LEAN-TABLES (5): solid status badges (desktop/tablet). Filled colour + white text; the dot stays as a
   subtle white marker. Colours picked for >=4.5:1 contrast with white text. */
@media screen and (min-width: 861px) {
  table.dtable:not(.dash-table) .badge { color: #fff; border: 0; }
  table.dtable:not(.dash-table) .badge::before { background: #fff; opacity: .9; }
  table.dtable:not(.dash-table) .badge-success { background: #15803D; color: #fff; }
  table.dtable:not(.dash-table) .badge-warning { background: #B45309; color: #fff; }
  table.dtable:not(.dash-table) .badge-danger  { background: #DC2626; color: #fff; }
  table.dtable:not(.dash-table) .badge-info    { background: #168A4E; color: #fff; }
  table.dtable:not(.dash-table) .badge-muted   { background: #6B7280; color: #fff; }
  table.dtable:not(.dash-table) .badge .ai { color: #fff; }
}

/* LEAN-TABLES (6): no status dot on table badges */
@media screen and (min-width: 861px) {
  table.dtable:not(.dash-table) .badge::before { display: none !important; content: none; }
  table.dtable:not(.dash-table) .badge { gap: 0; padding: 2px 10px; }
}

/* LEAN-TABLES (7): "New Order" = indigo (distinct from blue in-progress states, calmer than amber warning).
   Status colour map: green = done/positive, amber = pending/needs attention, blue = in progress/informative,
   indigo = new, red = failed/cancelled, grey = neutral/inactive. Same status = same colour everywhere. */
.badge-new { background: #E3F4EB; color: #0F6E3E; }
@media screen and (min-width: 861px) {
  table.dtable:not(.dash-table) .badge-new { background: #168A4E; color: #fff; }
}
