/* PRODUCTS-GRID-1 — Products grid view styled like the POS product tiles (pos.css: .pos-card).
   Square edge-to-edge photo, name (13/500, two lines), price (13/500), stock as a quiet caption, 12px tile, 12px gap,
   border-only hover. Row actions appear on hover over the photo. Markup is unchanged apart from data-pid (click = edit). */
#view-products .products-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; padding: 4px 0 0; }
@media (max-width: 720px) { #view-products .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 4px 0 0; } }
@media (max-width: 420px) { #view-products .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

#view-products .product-card {
  position: relative; display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
  background: var(--color-surface, #fff); border: 1px solid var(--line); border-radius: 12px; box-shadow: none; transform: none;
  transition: border-color .12s ease, background-color .12s ease;
}
#view-products .product-card:hover { border-color: var(--color-border-strong, #CFCFCF); box-shadow: none; transform: none; }
#view-products .product-card:active { background: var(--bg); }

#view-products .product-card-img { aspect-ratio: 1 / 1; background: var(--color-surface-muted, #F3F3F3); }
#view-products .product-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
#view-products .product-card-status { top: 8px; left: 8px; z-index: 1; }

/* name > price > stock > category > cost/profit > health badges, stacked from the top with no forced gap */
#view-products .product-card-body { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; padding: 10px 12px 12px; }
#view-products .product-card-name {
  order: 1; margin: 0; font-size: 13px; font-weight: 500; line-height: 18px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; overflow: hidden;
}
#view-products .product-card-price { order: 2; margin: 0; font-size: 13px; font-weight: 500; line-height: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
#view-products .product-card-was { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--text-faint); }
#view-products .product-card-stock { order: 3; margin: 0; font-size: 12px; font-weight: 400; line-height: 16px; color: var(--text-faint); }
#view-products .product-card-meta { order: 4; margin: 0; font-size: 12px; line-height: 16px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-products .product-card-body > div:not([class]) { order: 5; margin: 0 !important; font-size: 12px !important; line-height: 16px; color: var(--text-faint) !important; }
#view-products .product-card-body > div[style*="flex-wrap"] { order: 6; margin-top: 6px !important; }

/* row actions: a small floating pill over the photo, on hover / keyboard focus (always visible on touch) */
#view-products .product-card-actions {
  position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; align-items: center; gap: 2px; padding: 3px;
  background: rgba(255, 255, 255, .96); border: 0; border-radius: 10px; box-shadow: 0 1px 3px rgba(17, 24, 39, .2);
  opacity: 0; transition: opacity .12s ease;
}
#view-products .product-card:hover .product-card-actions, #view-products .product-card-actions:focus-within { opacity: 1; }
#view-products .product-card-actions .act-sep { display: none; }
#view-products .product-card-actions .tbl-icon-btn { width: 28px; height: 28px; }
@media (hover: none) { #view-products .product-card-actions { opacity: 1; } }

/* view toggle inside the filter bar: keep both buttons on one centred line */
.fb-tools .view-toggle { display: inline-flex; align-items: center; height: 28px; margin-left: 4px; padding: 0; border: 0; background: transparent; box-shadow: none; gap: 2px; }
.fb-tools .view-toggle-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; line-height: 1; border-radius: 8px; }
.fb-tools .view-toggle-btn .ai { vertical-align: 0; }
