﻿/* =========================================================
   UNIVERSAL SHARED TABLE (queues + labs)
   Class: .shared-queue-style-table
   ========================================================= */

/* Wrapper: horiz scroll only when necessary */
.table-scroll{
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* Base table */
.shared-queue-style-table{
  width: 100%;
  table-layout: fixed;             /* honors <col> widths */
  border-collapse: collapse;       /* classic 1px grid */
  border: 1px solid #8da7db;
  box-sizing: border-box;
  min-width: 930px;                /* safe floor; adjust globally if needed */
}

/* Cells */
.shared-queue-style-table th,
.shared-queue-style-table td{
  padding: 6px 8px;
  vertical-align: middle;
  border: 1px solid #8da7db !important;
  min-width: 0;                    /* allows wrapping where enabled */
  box-sizing: border-box;
}

/* Header */
.shared-queue-style-table thead th{
  background-color: #0c4da2;
  color: #fff;
  font-weight: bold;
  white-space: nowrap;             /* keep headings on one line */
}
.shared-queue-style-table thead th > a{
  color: #fff; text-decoration: none; display: inline-block;
}
.shared-queue-style-table thead th > a:hover{ text-decoration: underline; }

/* Make sure theme overrides can’t turn trailing headers white */
.shared-queue-style-table thead tr > th:last-child,
.shared-queue-style-table thead tr > th:nth-last-child(2){
  background-color: #0c4da2 !important;
  color: #fff !important;
}
.shared-queue-style-table thead tr > th:last-child a,
.shared-queue-style-table thead tr > th:nth-last-child(2) a{
  color: #fff !important;
}

/* Text helpers: default is WRAP; ellipsis is opt-in */
.nowrap { white-space: nowrap; }
.wrap   { white-space: normal; word-break: break-word; }
.shared-queue-style-table .truncate{
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}
.u-ellipsis{
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  display: inline-block;
  max-width: 100%;
}

/* ---------------------------------------------------------
   UNIVERSAL <col> BASELINES (apply to ALL shared tables)
   --------------------------------------------------------- */

/* Common queue-ish columns */
.shared-queue-style-table col.col-patient      { width: 100px; }
.shared-queue-style-table col.col-patientid    { width: 110px; } /* critical, single line */
.shared-queue-style-table col.col-location     { width: 60px;  }
.shared-queue-style-table col.col-question     { width: 110px; }
.shared-queue-style-table col.col-choice       { width: 70px;  }
.shared-queue-style-table col.col-actionstaken { width: 80px;  }
.shared-queue-style-table col.col-date         { width: 86px;  } /* MM/DD/YYYY */
.shared-queue-style-table col.col-reason       { width: 90px; }
.shared-queue-style-table col.col-createdby    { width: 70px;  }
.shared-queue-style-table col.col-provider     { width: 90px;  }
.shared-queue-style-table col.col-actions      { width: 56px;  }
.shared-queue-style-table col.col-select       { width: 40px;  }

/* Lab/report columns (also part of the universal set) */
.shared-queue-style-table col.col-labid        { width: 190px; } /* one line */
.shared-queue-style-table col.col-service      { width: 42%;  }  /* roomy; can wrap */

/* =========================================================
   ANTI-CRUSH FLOORS (pattern-aware via :has)
   - No extra table class needed: we key off <col> layout.
   ========================================================= */

/* ---------- QUEUE-LIKE LAYOUT ----------
   Heuristic: table has both col-question and col-actionstaken,
   and does NOT have col-labid (to avoid clashing with labs).
   Typical order (11 cols):
   1 Patient | 2 Patient ID | 3 Location | 4 Question | 5 Choice |
   6 Action Taken | 7 Date | 8 Reason | 9 Created By | 10 Provider | 11 Actions
*/
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(1),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(1){
  min-width: 100px; width: auto; white-space: normal; word-break: break-word; /* Patient */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(2),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(2){
  min-width: 150px; width: 150px; white-space: nowrap; overflow: visible; text-overflow: clip; /* Patient ID */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(3),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(3){
  min-width: 60px; width: auto; white-space: normal; word-break: break-word;  /* Location */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(4),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(4){
  min-width: 110px; width: auto; white-space: normal; word-break: break-word; /* Question */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(5),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(5){
  min-width: 70px; width: auto; white-space: normal; word-break: break-word;  /* Choice */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(6),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(6){
  min-width: 80px; width: auto; /* Action Taken */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(6){
  white-space: normal; word-break: break-word; overflow-wrap: anywhere; overflow: hidden;
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(7),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(7){
  min-width: 86px; width: 86px; white-space: nowrap; /* Date */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(8),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(8){
  min-width: 100px; width: auto; white-space: normal; word-break: break-word; /* Reason */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(9),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(9){
  min-width: 50px; width: auto; white-space: normal; word-break: break-word;  /* Created By */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(10),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(10){
  min-width: 64px; width: auto; white-space: normal; word-break: break-word; /* Provider */
}
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) thead th:nth-child(11),
.shared-queue-style-table:has(col.col-question):has(col.col-actionstaken):not(:has(col.col-labid)) tbody td:nth-child(11){
  min-width: 56px; width: 56px; /* Actions */
}

/* ---------- LAB-LIKE LAYOUT ----------
   Heuristic: table has col-labid & col-service
   Order (6 cols typical):
   1 Lab ID | 2 Service(s) | 3 Patient | 4 Patient ID | 5 Provider | 6 Actions
*/
.shared-queue-style-table:has(col.col-labid):has(col.col-service) thead th:nth-child(1),
.shared-queue-style-table:has(col.col-labid):has(col.col-service) tbody td:nth-child(1){
  min-width: 170px; width: auto; white-space: nowrap; overflow: visible; text-overflow: clip; /* Lab ID */
}
.shared-queue-style-table:has(col.col-labid):has(col.col-service) thead th:nth-child(2),
.shared-queue-style-table:has(col.col-labid):has(col.col-service) tbody td:nth-child(2){
  min-width: 260px; width: auto; /* Service */
}
.shared-queue-style-table:has(col.col-labid):has(col.col-service) tbody td:nth-child(2){
  white-space: normal; word-break: break-word; overflow-wrap: anywhere;
}
.shared-queue-style-table:has(col.col-labid):has(col.col-service) thead th:nth-child(3),
.shared-queue-style-table:has(col.col-labid):has(col.col-service) tbody td:nth-child(3){
  min-width: 160px; width: auto; white-space: normal; word-break: break-word; /* Patient */
}
.shared-queue-style-table:has(col.col-labid):has(col.col-service) thead th:nth-child(4),
.shared-queue-style-table:has(col.col-labid):has(col.col-service) tbody td:nth-child(4){
  min-width: 120px; width: 120px; white-space: nowrap; /* Patient ID */
}
.shared-queue-style-table:has(col.col-labid):has(col.col-service) thead th:nth-child(5),
.shared-queue-style-table:has(col.col-labid):has(col.col-service) tbody td:nth-child(5){
  min-width: 160px; width: auto; white-space: normal; word-break: break-word; /* Provider */
}
.shared-queue-style-table:has(col.col-labid):has(col.col-service) thead th:nth-child(6),
.shared-queue-style-table:has(col.col-labid):has(col.col-service) tbody td:nth-child(6){
  min-width: 56px; width: 56px; /* Actions */
}

/* ---------------------------------------------------------
   Optional: small screens – let Patient/Location wrap sooner
   --------------------------------------------------------- */
@media (max-width: 1450px){
  .shared-queue-style-table:has(col.col-question):not(:has(col.col-labid)) tbody td:nth-child(1),
  .shared-queue-style-table:has(col.col-question):not(:has(col.col-labid)) tbody td:nth-child(3){
    white-space: normal; word-break: break-word;
  }
}
