/*
 * HappyDarkTable (HDT) — a dependency-free, sortable/filterable/paginated table component.
 * Pairs with assets/js/pxf/happydarktable/happydarktable.js. See the "Theme-aware HDT overrides" section
 * below for the token fallback chain (--app-* > --pxf-* > literal default) that makes this
 * stylesheet self-sufficient without requiring any specific theme file.
 *
 * Known coupling: several selectors exclude `:not(.buttonpx)` (a Bootstrap-button convention this
 * component doesn't itself style) so generic link/cell hover styling doesn't also apply to
 * button-styled links. If your app uses a different button class, override those specific
 * selectors; this doesn't affect the component's own color tokens.
 */
.happydarktable {
  padding: .5rem;
  border-radius: 0;
  background: #0f1b2b;
  border: 1px solid #2a4364;

  /*width: 75%;*/
  margin: auto;

  gap: 1rem;
  display: flex;
  flex-direction: column;
}

.happydarktable > div.header {
  /*outline:dashed lime .5px;*/
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Standard section wrappers for paginated table pages */
.happydarktable > .hdt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1rem;
  border: 1px solid #35567e;
  border-radius: 0;
  background: linear-gradient(180deg, #163452 0%, #122d47 100%);
}

.happydarktable > .hdt-table {
  overflow: auto;
}

.happydarktable > .hdt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .85rem 1rem;
  border: 1px solid #2f4f75;
  border-radius: 0;
  background: linear-gradient(180deg, #122840 0%, #0f2338 100%);
}

.hdt-header .hdt-title-group {
  text-align: left;
}

.hdt-header .hdt-eyebrow {
  display: inline-block;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #86afdc;
  margin-bottom: .1rem;
}

.hdt-header .hdt-title-group h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #eef5ff;
}

.hdt-header .hdt-subtitle {
  margin: .15rem 0 0;
  font-size: .9rem;
  color: #a8c0de;
}

.hdt-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: .65rem;
  padding: .55rem .65rem;
  border: 1px solid #2e4d73;
  border-radius: 0;
  background: #0f2238;
}

.hdt-tools-left,
.hdt-tools-right {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.hdt-search-label {
  margin: 0;
  color: #b2c8e2;
  font-size: .84rem;
}

.hdt-search-input {
  min-width: 220px;
  max-width: 320px;
}

.hdt-tools-page-size {
  min-width: 88px;
}

.happydarktable > div.header > div.title {
  /*border: dashed yellow 1px;*/
}

.happydarktable > div.header > div.title > h3 {
  margin: 0;
  text-align: left;
}

.happydarktable > div.header > div.buttons {
  /*border: dashed red 1px;*/
  display: flex;
  gap: 1rem;

}

.happydarktable > div:nth-of-type(2) {
  /* `overflow: overlay` was removed from Chromium; `auto` is the standard equivalent. */
  overflow: auto;
}

.happydarktable > div:nth-of-type(3) {
  /*outline:dashed yellow .5px;*/
}

table.hdt {
  width: 100%;
  border: 1px solid #315076;
  border-radius: 10px;
  background: #101c2d;
  overflow-x: scroll;
  table-layout: fixed;
  text-align: center;

  margin: auto;
}

table.hdt thead {
  font-weight: 400;
  height: 40px;
  background: linear-gradient(180deg, #1f3d61 0%, #17324f 100%);
  color: #e7f1ff;
}

table.hdt thead tr {

}

table.hdt thead tr th {

}

table.hdt thead tr th.hdt-sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.4rem;
}

table.hdt thead tr th.hdt-sortable:hover {
  background: rgba(143, 196, 255, .12);
}

table.hdt thead tr th.hdt-sortable::after {
  content: "↕";
  position: absolute;
  right: .45rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .75rem;
  color: #8fb8e4;
  opacity: .55;
}

table.hdt thead tr th.hdt-sort-asc::after {
  content: "↑";
  color: #d9ebff;
  opacity: 1;
}

table.hdt thead tr th.hdt-sort-desc::after {
  content: "↓";
  color: #d9ebff;
  opacity: 1;
}

table.hdt thead tr.hdt-filter-row th {
  padding: .35rem;
  background: #112a43;
  border-top: 1px solid #294668;
}

table.hdt thead tr.hdt-filter-row .hdt-filter-control {
  width: 100%;
  min-height: 1.9rem;
  font-size: .82rem;
  border-color: #35577e;
  background-color: #10253c;
  color: #dceafc;
}

table.hdt thead tr.hdt-filter-row .hdt-filter-control:focus {
  border-color: #7fb9ff;
  box-shadow: 0 0 0 2px rgba(127, 185, 255, .2);
}

table.hdt thead tr.hdt-filter-row th.hdt-filter-empty {
  background: #112a43;
}

table.hdt thead tr th:last-of-type div {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

table.hdt thead tr th:last-of-type div button {
  zoom: .5;
}

/*			BODY			*/
table.hdt tbody {
  background-color: #101c2d;

}


table.hdt tbody tr {
  border-top: 1px solid #253e5d;
  transition: background-color .16s ease, box-shadow .16s ease;
}

table.hdt tbody tr:hover {
  background-color: #1a3553;
  box-shadow: inset 0 0 0 1px #5f90c8;
}

table.hdt tbody tr:hover td:first-of-type img {
  /*zoom: 1.15;*/
}

table.hdt tbody tr:nth-of-type(even) {
  background-color: #13243a;
}

table.hdt tbody tr:nth-of-type(odd) {
  background-color: #101c2d;
}

table.hdt tbody tr td {
  padding: .35rem .4rem;
  /* height: 60px !important; */
  overflow: hidden;
  white-space: nowrap;
  /* border: dashed lime 0.5px; */
  text-overflow: ellipsis;
  font-weight: 300;
  color: #dbe8fa;
  position: relative;
}

table.hdt tbody tr td:first-of-type:has(img) {
  /*background-color:red;*/
}

table.hdt tbody tr td:first-of-type:has(img + span) {
  /* background-color:red; */
  align-items: center;
  /*justify-content: center;*/
  gap: .5rem;
}

table.hdt tbody tr td:first-of-type:has(img+span) > * {
  /*background-color:blue;*/
  align-items: center;
}

table.hdt tbody tr td:last-of-type .buttonpx {
  /*.buttonpx*/
  display: inline-block;
  height: 30px;
  width: 30px;
  padding: 0px 0px;
  text-align: center;
}

table.hdt tbody tr td:not(:last-of-type) {
  border-right: 1px solid #223a58;
}

table.hdt tbody tr td:first-of-type img {
  /*background-color:red;*/
  height: 40px;
  width: 40px;
}

table.hdt tbody tr td:first-of-type img {
  border: 1px solid #567eae;
  border-radius: 6px;
}

table.hdt tbody tr td:last-of-type > div {
  display: flex;
  align-items: center;
  justify-content: space-around;
}


table.hdt tbody tr td:hover {
  /*overflow:visible;*/
}

/* Hover-driven cell expansion only makes sense on devices with a real pointer;
   on touch it misfires on tap and clips at the wrapper edge. */
@media (hover: hover) and (pointer: fine) {
  /* Select a parent if it has a .child inside */
  table.hdt tbody tr td:has(span:hover),
  table.hdt tbody tr td:has(a:hover),
  table.hdt tbody tr td:has(.hdt-cell-line:hover) {
    /* outline: 1px solid green; */
    overflow: visible;
    z-index: 4;
  }

  table.hdt tbody tr td:has(> span:not(.badge):hover),
  table.hdt tbody tr td:has(> a:not(.btn):not(.buttonpx):hover),
  table.hdt tbody tr td:has(.hdt-cell-stack:hover) {
    background-color: var(--hdt-surface-alt);
    box-shadow: inset 0 0 0 1px var(--hdt-accent);
  }
}

table.hdt tbody tr td > span:not(.badge),
table.hdt tbody tr td > a:not(.btn):not(.buttonpx),
table.hdt tbody tr td > small,
table.hdt tbody tr td > strong,
table.hdt tbody tr td > em,
table.hdt tbody tr td > time,
table.hdt tbody tr td > code {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

@media (hover: hover) and (pointer: fine) {
  table.hdt tbody tr td > span:not(.badge):hover,
  table.hdt tbody tr td > a:not(.btn):not(.buttonpx):hover,
  .hdt-cell-line:hover {
    position: relative;
    padding: 0px 4px;
    max-width: none;
    overflow: visible;

    background-color: var(--hdt-surface-alt);
    border: 1px solid var(--hdt-accent);
    border-radius: 0px;

    z-index: 2;
    /*border: solid 1px black;*/
    /*border-radius: 4px;*/
  }
}

table.hdt tbody tr td > a:not(.btn) {
  text-decoration: none;
  color: var(--hdt-accent);
}

table.hdt tbody tr td > a:not(.btn):hover {
  color: #e7f3ff;
}

table.hdt.hdt-copy-on-click tbody tr td > span:not(.badge),
table.hdt.hdt-copy-on-click tbody tr td > small,
table.hdt.hdt-copy-on-click tbody tr td > strong,
table.hdt.hdt-copy-on-click tbody tr td > em,
table.hdt.hdt-copy-on-click tbody tr td > time,
table.hdt.hdt-copy-on-click tbody tr td > code,
table.hdt.hdt-copy-on-click tbody tr td .hdt-cell-line {
  cursor: copy;
}

table.hdt.hdt-copy-on-click tbody tr td > span:not(.badge).hdt-copy-success,
table.hdt.hdt-copy-on-click tbody tr td > small.hdt-copy-success,
table.hdt.hdt-copy-on-click tbody tr td > strong.hdt-copy-success,
table.hdt.hdt-copy-on-click tbody tr td > em.hdt-copy-success,
table.hdt.hdt-copy-on-click tbody tr td > time.hdt-copy-success,
table.hdt.hdt-copy-on-click tbody tr td > code.hdt-copy-success,
table.hdt.hdt-copy-on-click tbody tr td .hdt-cell-line.hdt-copy-success {
  background-color: var(--hdt-accent-strong);
  border-color: var(--hdt-accent);
  color: var(--hdt-text);
}

.hdt-cell-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .15rem;
  width: 100%;
  overflow: visible;
}

.hdt-cell-stack:hover {
  overflow: visible;
}

.hdt-cell-line {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  align-self: flex-start;
}


/* Shared pagination styling aligned with happydark blue palette */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .65rem;
}

.pagination {
  display: flex;
  gap: .35rem;
  margin: 0;
  align-items: center;
  flex-wrap: wrap;
}

.page-item {
  border-radius: 0;
  overflow: hidden;
}

.page-link {
  padding: .4rem .78rem;
  border-radius: 0;
  border: 1px solid #3a567f;
  background-color: #101c2d;
  color: #dbe8fa;
  font-weight: 600;
  min-width: 2.2rem;
  min-height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
}

.page-item.active .page-link {
  background-color: #2d5f9e;
  border-color: #7fb9ff;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(127, 185, 255, .2), inset 0 -1px 0 rgba(8, 18, 32, .35);
}

.page-item:not(.active) .page-link:hover {
  background-color: #17324f;
  border-color: #6f98c9;
  color: #ffffff;
  transform: translateY(-1px);
}

.page-item:not(.active) .page-link:focus {
  box-shadow: 0 0 0 3px rgba(127, 185, 255, .22);
  border-color: #7fb9ff;
  color: #ffffff;
}

.page-item.disabled .page-link {
  background-color: #0c1522;
  border-color: #25384f;
  color: #5f738d;
  opacity: 1;
  pointer-events: none;
}

/* Normalize legacy pagination utility classes to the blue theme */
.pagination .page-link.bg-dark {
  background-color: #101c2d !important;
  border-color: #3a567f !important;
  color: #dbe8fa !important;
}

.pagination .page-link.rounded-circle {
  border-radius: 0 !important;
}

.pagination .page-link.mx-1 {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.pagination-info {
  color: #9fb8d9;
  font-size: .92rem;
}

.hdt-footer .navigation {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .8rem;
}

.hdt-page-size {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  background: #0f1f32;
  border: 1px solid #2e4f75;
  border-radius: 0;
  padding: .4rem .55rem;
}

.hdt-page-size-label {
  color: #b5cae4;
  font-size: .84rem;
  margin: 0;
  white-space: nowrap;
}

.hdt-page-size .form-select {
  min-width: 84px;
  background-color: #102740;
  border: 1px solid #3f6490;
  color: #e6f1ff;
  font-size: .9rem;
  padding-top: .3rem;
  padding-bottom: .3rem;
}

.hdt-page-size .form-select:focus {
  border-color: #7fb9ff;
  box-shadow: 0 0 0 2px rgba(127, 185, 255, .2);
}

.hdt-client-pagination {
  margin-top: .6rem;
  padding: .5rem .65rem;
  border: 1px solid #32557d;
  border-radius: 0;
  background: #102640;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  flex-wrap: wrap;
}

.hdt-client-pagination-info {
  color: #a9c1de;
  font-size: .84rem;
}

.hdt-client-pagination-nav {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.hdt-help-text {
  margin: .6rem 0 0;
  color: #9fb7d5;
  font-size: .83rem;
  text-align: left;
}

table.hdt thead tr th,
table.hdt tbody tr td {
  vertical-align: middle;
}

.pagination-info {
  color: #a9bfd9;
  font-size: .88rem;
}

/* Theme-aware HDT overrides.
   Each --hdt-* token resolves through a three-tier fallback: an app-defined --app-* token
   (the app's own theme.css) wins if present, then the framework's own --pxf-* token
   (pxf-theme.css) if that's included, then a literal default — so this stylesheet
   renders correctly whether or not either token layer is present. */
.happydarktable {
  --hdt-surface: var(--app-surface-2, var(--pxf-surface-2, #101c2d));
  --hdt-surface-alt: var(--app-surface-1, var(--pxf-surface-1, #101722));
  --hdt-surface-soft: var(--app-surface-0, var(--pxf-surface-0, #0f141c));
  --hdt-border: var(--app-border, var(--pxf-border, #33455e));
  --hdt-border-strong: var(--app-border-strong, var(--pxf-border-strong, #3a567f));
  --hdt-text: var(--app-text-primary, var(--pxf-text-primary, #edf5ff));
  --hdt-text-muted: var(--app-text-secondary, var(--pxf-text-secondary, #c2d4eb));
  --hdt-text-soft: var(--app-text-muted, var(--pxf-text-muted, #9bb6d8));
  --hdt-accent: var(--app-accent, var(--pxf-accent, #7cb4ff));
  --hdt-accent-strong: var(--app-accent-strong, var(--pxf-accent-strong, #2d5f9e));
  --hdt-hover: var(--app-surface-hover, var(--pxf-surface-hover, #162235));
  background: var(--hdt-surface);
  border-color: var(--hdt-border);
}

.happydarktable > .hdt-header {
  border-color: var(--hdt-border-strong);
  background: linear-gradient(180deg, var(--hdt-surface-alt) 0%, var(--hdt-surface) 100%);
}

.happydarktable > .hdt-footer {
  border-color: var(--hdt-border);
  background: linear-gradient(180deg, var(--hdt-surface-alt) 0%, var(--hdt-surface) 100%);
}

.hdt-header .hdt-eyebrow {
  color: var(--hdt-text-soft);
}

.hdt-header .hdt-title-group h3 {
  color: var(--hdt-text);
}

.hdt-header .hdt-subtitle {
  color: var(--hdt-text-muted);
}

.hdt-tools {
  border-color: var(--hdt-border);
  background: var(--hdt-surface-alt);
}

.hdt-search-label,
.hdt-page-size-label,
.pagination-info,
.hdt-client-pagination-info,
.hdt-help-text {
  color: var(--hdt-text-soft);
}

table.hdt {
  border-color: var(--hdt-border-strong);
  background: var(--hdt-surface);
}

table.hdt thead {
  background: linear-gradient(180deg, var(--hdt-surface-alt) 0%, var(--hdt-surface) 100%);
  color: var(--hdt-text);
}

table.hdt thead tr th.hdt-sortable:hover {
  background: var(--hdt-hover);
}

table.hdt thead tr th.hdt-sortable::after {
  color: var(--hdt-text-soft);
}

table.hdt thead tr th.hdt-sort-asc::after,
table.hdt thead tr th.hdt-sort-desc::after {
  color: var(--hdt-accent);
}

table.hdt thead tr.hdt-filter-row th,
table.hdt thead tr.hdt-filter-row th.hdt-filter-empty {
  background: var(--hdt-surface-alt);
  border-top-color: var(--hdt-border);
}

table.hdt thead tr.hdt-filter-row .hdt-filter-control {
  border-color: var(--hdt-border);
  background-color: var(--hdt-surface-soft);
  color: var(--hdt-text);
}

table.hdt thead tr.hdt-filter-row .hdt-filter-control:focus {
  border-color: var(--hdt-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--hdt-accent) 28%, transparent);
}

table.hdt tbody {
  background-color: var(--hdt-surface);
}

table.hdt tbody tr {
  border-top-color: var(--hdt-border);
}

table.hdt tbody tr:nth-of-type(odd) {
  background-color: var(--hdt-surface);
}

table.hdt tbody tr:nth-of-type(even) {
  background-color: var(--hdt-surface-alt);
}

table.hdt tbody tr:hover {
  background-color: var(--hdt-hover);
  box-shadow: inset 0 0 0 1px var(--hdt-accent);
}

table.hdt tbody tr td {
  color: var(--hdt-text);
}

table.hdt tbody tr td:not(:last-of-type) {
  border-right-color: var(--hdt-border);
}

table.hdt tbody tr td:first-of-type img {
  border-color: var(--hdt-border-strong);
}

@media (hover: hover) and (pointer: fine) {
  table.hdt tbody tr td > span:not(.badge):hover,
  table.hdt tbody tr td > a:not(.btn):hover,
  table.hdt tbody tr td > a:not(.buttonpx):hover {
    background-color: var(--hdt-surface-alt);
    background-image: none;
    border-color: var(--hdt-accent);
  }
}

table.hdt tbody tr td > a:not(.btn) {
  color: var(--hdt-accent);
}

table.hdt tbody tr td > a:not(.btn):hover {
  color: var(--hdt-text);
}

.page-link {
  border-color: var(--hdt-border-strong);
  background-color: var(--hdt-surface);
  color: var(--hdt-text);
}

.page-item.active .page-link {
  background-color: var(--hdt-accent-strong);
  border-color: var(--hdt-accent);
  color: var(--hdt-text);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--hdt-accent) 22%, transparent);
}

.page-item:not(.active) .page-link:hover {
  background-color: var(--hdt-hover);
  border-color: var(--hdt-border-strong);
  color: var(--hdt-text);
}

.page-item:not(.active) .page-link:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hdt-accent) 25%, transparent);
  border-color: var(--hdt-accent);
  color: var(--hdt-text);
}

.page-item.disabled .page-link {
  background-color: var(--hdt-surface-soft);
  border-color: var(--hdt-border);
  color: var(--hdt-text-soft);
}

.pagination .page-link.bg-dark {
  background-color: var(--hdt-surface) !important;
  border-color: var(--hdt-border-strong) !important;
  color: var(--hdt-text) !important;
}

.hdt-page-size {
  background: var(--hdt-surface-alt);
  border-color: var(--hdt-border);
}

.hdt-page-size .form-select {
  background-color: var(--hdt-surface-soft);
  border-color: var(--hdt-border-strong);
  color: var(--hdt-text);
}

.hdt-page-size .form-select:focus {
  border-color: var(--hdt-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--hdt-accent) 25%, transparent);
}

.hdt-client-pagination {
  border-color: var(--hdt-border-strong);
  background: var(--hdt-surface-alt);
}

/* ==========================================================================
   FR-11 — Sticky headers: keep the column headers visible while scrolling a
   long table. The scroll container is the `.hdt-table` wrapper; capping its
   height turns overflowing rows into an internal scroll instead of a very tall
   page, and the sticky thead rides along. Applies to all viewports.
   ========================================================================== */
.happydarktable > .hdt-table,
.happydarktable > div:nth-of-type(2) {
  max-height: 75vh;
  overflow: auto;
}

table.hdt thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

/* The per-column filter row sits in the same sticky thead; offset it below the
   header row so both stay pinned without overlapping. */
table.hdt thead tr.hdt-filter-row th {
  position: sticky;
  top: 40px; /* matches thead height above */
  z-index: 2;
}

/* ==========================================================================
   FR-09 / FR-10 — Mobile pass (below Bootstrap md). `table-layout: fixed` plus
   nowrap-ellipsis crushes every column into ~40-60px slivers on a phone. Below
   md, let content size the columns and scroll the wrapper horizontally, and
   hide the per-column filter row (its ~40px inputs are untypeable on touch and
   can't be dismissed) — the global search in the header still works.
   ========================================================================== */
@media (max-width: 767.98px) {
  table.hdt {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
  }

  table.hdt thead tr th,
  table.hdt tbody tr td {
    min-width: 6rem;
  }

  /* Cap individual cell growth so one long value can't create an enormous
     column; the wrapper scrolls instead. */
  table.hdt tbody tr td > span:not(.badge),
  table.hdt tbody tr td > a:not(.btn):not(.buttonpx) {
    max-width: 60vw;
  }

  table.hdt thead tr.hdt-filter-row {
    display: none;
  }

  .happydarktable > .hdt-table,
  .happydarktable > div:nth-of-type(2) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
