/* nc_table_html -- the NuCare table leaf's own rules.
 *
 * The form root IS the .nc-tables-container div, so that rule stays BARE:
 * the root is its subject, and a :where(.nc-tables-container) wrapper in front
 * of it would never match. It carries the --px-grid-cols track list and
 * min-height: 0.
 *
 * Every other rule is scoped :where(.nc-tables-container), which adds zero
 * specificity and so cannot change which rule wins -- EXCEPT the two
 * confirm-dialog rules at the foot of this file. pxShowOverlay moves any
 * .px-modal-overlay into #px-modal-portal, so that node is OUTSIDE this root
 * exactly when those rules are needed.
 *
 * .nc-td-token, .nc-td-items and .nc-td-actions (base rule and 768px twin) each
 * carry .px-grid-td as a second class: a head <link> loads BEFORE theme.css's
 * .px-grid-td, so a (0,1,0) tie would lose on document order.
 *
 * .nc-table-section[hidden] keeps its position and its (0,2,0), which beats
 * .nc-table-section { display: flex } whatever the order.
 *
 * DESIGNER GATE: none, and this comment is the decision. Nothing here is hidden
 * until JavaScript runs. #nc-auto-completed-section is hidden by the `hidden`
 * ATTRIBUTE in the markup, which the canvas honours; the tabs, filters, headers and empty bodies are all visible on the
 * canvas. This leaf carries no live class and needs none.
 *
 * No @keyframes, no url(), no @font-face, no html rule and no :root block
 * existed in the style block -- nothing to prefix, rewrite, drop or merge. No
 * .themed-scrollbar rule: the class stays on the root for the
 * shared scrollbar look alone.
 */

.nc-tables-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
  overflow-y: auto;
  --px-grid-cols: 140px minmax(0,1fr) minmax(0,1fr) minmax(0,2fr) 120px;
  /* Lets the flex column shrink inside the shell's slot mount. */
  min-height: 0;
}

:where(.nc-tables-container) .nc-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--px-bg-elevated);
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius);
  flex-shrink: 0;
}

:where(.nc-tables-container) .nc-tab {
  flex: 1;
  border: 0;
  border-radius: var(--px-radius-sm);
  padding: 10px 14px;
  background: transparent;
  color: var(--px-text-secondary);
  font-family: var(--px-font);
  font-weight: 700;
  cursor: pointer;
}

:where(.nc-tables-container) .nc-tab[aria-selected="true"] {
  color: var(--accent-text);
  background: var(--accent);
}

:where(.nc-tables-container) .nc-tab:focus-visible,
:where(.nc-tables-container) .nc-sort-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:where(.nc-tables-container) .nc-table-section[hidden] { display: none; }

:where(.nc-tables-container) .nc-table-section {
  background: var(--px-bg-card);
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius);
  box-shadow: var(--px-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

:where(.nc-tables-container) .nc-table-section.nc-section-primary {
  flex: 0 1 auto;
}

:where(.nc-tables-container) .nc-table-section.nc-section-secondary {
  flex: 0 1 auto;
}

:where(.nc-tables-container) .nc-section-header {
  padding: 14px 20px;
  background: var(--px-bg-elevated);
  border-bottom: 1px solid var(--px-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

:where(.nc-tables-container) .nc-section-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

:where(.nc-tables-container) .nc-section-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

:where(.nc-tables-container) .nc-section-filters .nc-filter {
  flex: 1 1 130px;
  min-width: 110px;
  max-width: 220px;
}

:where(.nc-tables-container) .nc-seg {
  display: inline-flex;
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

:where(.nc-tables-container) .nc-seg-btn {
  background: transparent;
  color: var(--px-text-secondary);
  border: none;
  border-left: 1px solid var(--px-border);
  padding: 7px 12px;
  font-family: var(--px-font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

:where(.nc-tables-container) .nc-seg-btn:first-child {
  border-left: none;
}

:where(.nc-tables-container) .nc-seg-btn:hover {
  background: var(--accent-subtle);
}

:where(.nc-tables-container) .nc-seg-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

:where(.nc-tables-container) .nc-seg-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

:where(.nc-tables-container) .nc-bulk-btn {
  margin-left: auto;
  white-space: nowrap;
}

:where(.nc-tables-container) .nc-sort-header {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

:where(.nc-tables-container) .nc-sort-indicator::after { content: '↕'; opacity: 0.45; }

:where(.nc-tables-container) .nc-sort-header[data-direction="asc"] .nc-sort-indicator::after { content: '▲'; opacity: 1; }

:where(.nc-tables-container) .nc-sort-header[data-direction="desc"] .nc-sort-indicator::after { content: '▼'; opacity: 1; }

:where(.nc-tables-container) .nc-section-title {
  font-family: var(--px-font);
  font-size: 15px;
  font-weight: 700;
  color: var(--px-text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

:where(.nc-tables-container) .nc-section-title::before {
  content: '';
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}

:where(.nc-tables-container) .nc-section-count {
  font-family: var(--px-mono);
  font-size: 12px;
  color: var(--px-text-muted);
  background: var(--accent-subtle);
  padding: 2px 8px;
  border-radius: 12px;
}

:where(.nc-tables-container) .px-grid-td.nc-td-token {
  font-family: var(--px-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

:where(.nc-tables-container) .px-grid-td.nc-td-items {
  white-space: normal;
  line-height: 1.4;
  font-size: 12px;
  color: var(--px-text-secondary);
}

:where(.nc-tables-container) .px-grid-td.nc-td-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

:where(.nc-tables-container) .nc-btn {
  font-family: var(--px-font);
  font-size: 11px;
  font-weight: 600;
  border: none;
  border-radius: var(--px-radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: normal;
  text-align: center;
}

:where(.nc-tables-container) .nc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

:where(.nc-tables-container) .nc-btn-primary {
  background: var(--accent);
  color: #fff;
}

:where(.nc-tables-container) .nc-btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
}

:where(.nc-tables-container) .nc-btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--px-danger);
  border: 1px solid transparent;
}

:where(.nc-tables-container) .nc-btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--px-danger);
}

:where(.nc-tables-container) .nc-btn-tonal {
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid transparent;
}

:where(.nc-tables-container) .nc-btn-tonal:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

@media (max-width: 768px) {
  :where(.nc-tables-container) .px-grid-td.nc-td-actions {
    justify-content: flex-start;
    padding-top: 8px;
    border-top: 1px solid var(--px-border);
  }
}

/* Portaled to #px-modal-portal by pxShowOverlay, so neither rule may be scoped
   under the form root: the scope is absent exactly when the rule is needed.
   Doubled on .px-modal / .px-modal-body because the dependency injects its
   theme after every head link, so an untied (0,1,0) would now lose. Both were
   inline style= attributes on the template's dialog. */
.px-modal.nc-confirm-modal {
  max-width: 400px;
  width: 100%;
}

.px-modal-body.nc-confirm-body {
  font-family: var(--px-font);
  font-size: 14px;
  color: var(--px-text-secondary);
  line-height: 1.5;
}
