/**
 * Global table slim scroll — thin orange scrollbars.
 * DataTables scrollY owns body height; do not force max-height on .dataTables_scrollBody.
 * Plain .table-responsive gets a capped height for vertical scroll.
 */

/* Plain (non-DataTables) responsive wrappers */
.table-responsive:not(.no-table-slim-scroll),
.box-body.table-responsive:not(.no-table-slim-scroll),
.card-body.table-responsive:not(.no-table-slim-scroll) {
  max-height: min(60vh, 560px);
  overflow: auto !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #FE9F43 transparent;
}

/* DataTables scroll body: style scrollbars only — height from scrollY.
   Force both-axis overflow so H+V scroll work when content overflows. */
.dataTables_wrapper .dataTables_scrollBody {
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #FE9F43 transparent;
}

.dataTables_wrapper .dataTables_scroll {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #FE9F43 transparent;
}

.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar,
.box-body.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar,
.card-body.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar,
.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar,
.dataTables_wrapper .dataTables_scroll::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-track,
.box-body.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-track,
.card-body.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-track,
.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-track,
.dataTables_wrapper .dataTables_scroll::-webkit-scrollbar-track {
  background: transparent;
}

.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-thumb,
.box-body.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-thumb,
.card-body.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-thumb,
.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-thumb,
.dataTables_wrapper .dataTables_scroll::-webkit-scrollbar-thumb {
  background: #FE9F43;
  border-radius: 0;
  border: 0;
}

.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-thumb:hover,
.box-body.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-thumb:hover,
.card-body.table-responsive:not(.no-table-slim-scroll)::-webkit-scrollbar-thumb:hover,
.dataTables_wrapper .dataTables_scrollBody::-webkit-scrollbar-thumb:hover,
.dataTables_wrapper .dataTables_scroll::-webkit-scrollbar-thumb:hover {
  background: #e8892e;
}

/* Sticky header for plain (non-DataTables) tables */
.table-responsive:not(.no-table-slim-scroll) > table > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #fff;
}

/* Dark mode sticky header */
html.dark .table-responsive:not(.no-table-slim-scroll) > table > thead > tr > th,
body.dark-mode .table-responsive:not(.no-table-slim-scroll) > table > thead > tr > th {
  background-color: var(--bg-card, #1f2937);
}

/* POS Order Details: Dreams CSS remains source of truth for cart scroll */
body.pos-dreams-skin .product-added .pos_product_div .table-responsive:not(.no-table-slim-scroll),
body.pos-dreams-skin .pos_product_div .table-responsive:not(.no-table-slim-scroll) {
  max-height: none !important;
  overflow: visible !important;
}

body.pos-dreams-skin .product-added .pos_product_div .table-responsive:not(.no-table-slim-scroll) > table > thead > tr > th {
  position: static;
}

/* Print / invoice: do not clip tables */
.print_section .table-responsive,
.print_section .dataTables_wrapper .dataTables_scrollBody,
.invoice.print_section .table-responsive,
#receipt_section .table-responsive {
  max-height: none !important;
  overflow: visible !important;
}

@media print {
  .table-responsive:not(.no-table-slim-scroll),
  .box-body.table-responsive:not(.no-table-slim-scroll),
  .card-body.table-responsive:not(.no-table-slim-scroll),
  .dataTables_wrapper .dataTables_scrollBody,
  .dataTables_wrapper .dataTables_scroll {
    max-height: none !important;
    overflow: visible !important;
  }

  .table-responsive:not(.no-table-slim-scroll) > table > thead > tr > th {
    position: static;
  }
}

/* ============================================================
   Full-width responsive tables (content area)
   ============================================================ */
.table-responsive:not(.no-table-slim-scroll),
.box-body.table-responsive:not(.no-table-slim-scroll),
.card-body.table-responsive:not(.no-table-slim-scroll),
.dataTables_wrapper,
.dataTables_wrapper .dataTables_scroll,
.dataTables_wrapper .dataTables_scrollHead,
.dataTables_wrapper .dataTables_scrollHeadInner,
.dataTables_wrapper .dataTables_scrollBody {
  width: 100% !important;
  max-width: 100%;
}

.table-responsive:not(.no-table-slim-scroll) > table,
.dataTables_wrapper table.dataTable,
.dataTables_wrapper .dataTables_scrollHeadInner table,
.dataTables_wrapper .dataTables_scrollBody table {
  width: 100% !important;
  min-width: 100%;
}

/* Narrow screens: compact cells + horizontal slim scroll */
@media (max-width: 767px) {
  .table-responsive:not(.no-table-slim-scroll) > table > thead > tr > th,
  .table-responsive:not(.no-table-slim-scroll) > table > tbody > tr > td,
  .dataTables_wrapper table.dataTable > thead > tr > th,
  .dataTables_wrapper table.dataTable > tbody > tr > td {
    white-space: nowrap;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 12px;
  }
}

/* POS Order Details: do not override Dreams cart table width */
body.pos-dreams-skin .product-added .pos_product_div .table-responsive:not(.no-table-slim-scroll),
body.pos-dreams-skin .pos_product_div .table-responsive:not(.no-table-slim-scroll),
body.pos-dreams-skin .product-added .pos_product_div .table-responsive:not(.no-table-slim-scroll) > table,
body.pos-dreams-skin .pos_product_div .table-responsive:not(.no-table-slim-scroll) > table {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
}

/* Print: natural width */
.print_section .table-responsive,
.print_section .dataTables_wrapper,
.print_section .dataTables_wrapper table.dataTable,
.invoice.print_section .table-responsive,
#receipt_section .table-responsive {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
}

@media print {
  .table-responsive:not(.no-table-slim-scroll) > table,
  .dataTables_wrapper table.dataTable,
  .dataTables_wrapper .dataTables_scrollHeadInner table,
  .dataTables_wrapper .dataTables_scrollBody table {
    width: auto !important;
    min-width: 0 !important;
  }
}
