/**
 * Products list — table layout (column alignment, scroll pane; matches All Sales pattern)
 */

/* Fill the card width when zoomed out / wide viewports; grow past 100% only when columns need it */
#productListTable .business-table-pane #product_table,
#scrollable-container #productListTable .business-table-pane #product_table {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
}

#productListTable .business-table-pane #product_table_wrapper {
    width: 100% !important;
    min-width: 100% !important;
    max-width: none !important;
}

#productListTable .business-table-pane #product_table tbody td,
#productListTable .business-table-pane #product_table tfoot td {
    display: table-cell !important;
    position: static !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

#productListTable .business-table-pane #product_table thead th {
    display: table-cell !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    white-space: nowrap !important;
}

/* Sticky label + filter rows — scroll container is #productListTable_scroll (.business-table-pane) */
#productListTable .business-table-pane #product_table thead tr.table-label-row th,
#scrollable-container #productListTable .business-table-pane #product_table thead tr.table-label-row th {
    position: sticky !important;
    top: 0 !important;
    z-index: 12 !important;
    background: var(--table-header-bg, var(--bt-header-bg, #f8fafc)) !important;
    box-shadow: 0 1px 0 var(--table-border, var(--bt-border, #e2e8f0));
}

#productListTable .business-table-pane #product_table thead tr.table-filter-row th,
#scrollable-container #productListTable .business-table-pane #product_table thead tr.table-filter-row th {
    position: sticky !important;
    top: var(--bt-header-label-height, 38px) !important;
    z-index: 11 !important;
    background: var(--table-header-bg, var(--bt-header-bg, #f8fafc)) !important;
    box-shadow: 0 1px 0 var(--table-border, var(--bt-border, #e2e8f0));
}

#productListTable .business-table-pane #product_table tfoot tr.footer-total td {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 10;
    background: var(--table-header-bg, var(--bt-header-bg)) !important;
    box-shadow: 0 -2px 0 var(--table-border, var(--bt-border));
}

/* Checkbox */
#productListTable .business-table-pane #product_table .product-col-checkbox {
    min-width: 2.75rem !important;
    width: 2.75rem !important;
    max-width: 3.25rem !important;
    text-align: center !important;
    white-space: nowrap !important;
}

/* Image */
#productListTable .business-table-pane #product_table .product-col-image {
    min-width: 4.5rem !important;
    width: 4.5rem !important;
    max-width: 5.5rem !important;
    text-align: center !important;
    white-space: nowrap !important;
}

/* Action — compact menu-only column */
#productListTable .business-table-pane #product_table .product-col-action,
#productListTable .business-table-pane #product_table th.product-col-action,
#productListTable .business-table-pane #product_table td.product-col-action {
    min-width: 2.75rem !important;
    width: 2.75rem !important;
    max-width: 3rem !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding-left: 0.2rem !important;
    padding-right: 0.2rem !important;
}

/* Product name — flexible column absorbs extra width */
#productListTable .business-table-pane #product_table .product-col-name {
    min-width: 11rem !important;
    width: auto !important;
    max-width: none !important;
    white-space: normal !important;
}

/* Locations / Branch */
#productListTable .business-table-pane #product_table .product-col-location {
    min-width: 6.5rem !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
}

/* Prices */
#productListTable .business-table-pane #product_table .product-col-purchase-price,
#productListTable .business-table-pane #product_table .product-col-selling-price {
    min-width: 5.5rem !important;
    width: auto !important;
    white-space: nowrap !important;
}

/* Stock, type, category, brand, tax, status */
#productListTable .business-table-pane #product_table .product-col-stock,
#productListTable .business-table-pane #product_table .product-col-type,
#productListTable .business-table-pane #product_table .product-col-category,
#productListTable .business-table-pane #product_table .product-col-brand,
#productListTable .business-table-pane #product_table .product-col-tax,
#productListTable .business-table-pane #product_table .product-col-status {
    min-width: 4.75rem !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
}

#productListTable .business-table-pane #product_table .product-col-stock {
    text-align: left !important;
    min-width: 5.25rem !important;
}

#productListTable .business-table-pane #product_table .product-col-status {
    min-width: 4.25rem !important;
}

/* Custom fields */
#productListTable .business-table-pane #product_table .product-col-custom {
    min-width: 6rem !important;
    white-space: normal !important;
}

/* SKU / barcode column */
#productListTable .business-table-pane #product_table .product-col-sku,
#productListTable .business-table-pane #product_table thead th.bt-col-ref,
#productListTable .business-table-pane #product_table tbody td.bt-col-ref {
    min-width: 6.5rem !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
}

/* Tighter cell padding for mockup density */
#productListTable .business-table-pane #product_table thead th,
#productListTable .business-table-pane #product_table tbody td {
    padding-left: 0.45rem !important;
    padding-right: 0.45rem !important;
}

/* Products page tabs — viewport height chain (All Sales scroll pattern) */
.sa-page > .product-page-tabs {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: max(420px, calc(100vh - 156px));
    height: calc(100vh - 156px);
}

.product-page-tabs > .nav-tabs {
    flex-shrink: 0;
}

.product-page-tabs > .tab-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.product-page-tabs > .tab-content > .tab-pane.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.product-page-tabs #productListTable.business-table-component.business-table-card {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
}

.product-page-tabs #productListTable.business-table-card--standard {
    min-height: 0;
}

.product-page-tabs #productListTable .business-table-body--flat,
.product-page-tabs #productListTable .business-table-hscroll-zone,
.product-page-tabs #productListTable .business-table-pane {
    flex: 1 1 auto;
    min-height: 0;
}

.product-page-tabs .product-stock-report-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0 16px 16px;
}
