/* GSCC data tables, lists, empty/loading/error, stackable responsive */

/* ----- Typography & density (legacy + modern) ----- */
.gscc-data-table,
table.gscc-table,
table#file-datatable,
.institute-public-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--gscc-fs-md, 0.8125rem);
  color: var(--gscc-color-text, #17212B);
}

.gscc-data-table thead th,
.gscc-table thead th,
table#file-datatable thead th,
.institute-public-table thead th {
  background: var(--gscc-color-secondary, #1B3A2F);
  color: var(--gscc-color-text-inverse, #fff);
  font-size: var(--gscc-fs-xs, 0.6875rem);
  font-weight: var(--gscc-fw-semibold, 600);
  letter-spacing: var(--gscc-ls-wide, 0.04em);
  text-transform: uppercase;
  padding: 0.55rem 0.75rem;
  border: none;
  white-space: nowrap;
  vertical-align: middle;
}

.gscc-data-table thead th a,
.gscc-table thead th a,
table#file-datatable thead th a {
  color: inherit !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gscc-data-table thead th a:focus-visible,
.gscc-table thead th a:focus-visible,
table#file-datatable thead th a:focus-visible {
  outline: 2px solid var(--gscc-color-accent, #F0B429);
  outline-offset: 2px;
}

.gscc-data-table tbody td,
.gscc-table tbody td,
table#file-datatable tbody td,
.institute-public-table tbody td {
  padding: 0.55rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--gscc-color-border-subtle, #E5E7EB);
  line-height: 1.35;
  max-width: 28rem;
}

.gscc-data-table tbody tr:nth-child(even),
table#file-datatable tbody tr:nth-child(even) {
  background: var(--gscc-color-bg-subtle, #F8FAFB);
}

.gscc-data-table tbody tr:hover,
table#file-datatable tbody tr:hover {
  background: var(--gscc-color-primary-soft);
}

/* Identifiers, dates, amounts */
.gscc-mono,
.gscc-id,
.gscc-app-no,
td.gscc-id,
td.gscc-mono {
  font-family: var(--gscc-font-mono, ui-monospace, Consolas, monospace);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.gscc-num,
td.gscc-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.gscc-cell-clamp {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 16rem;
}

.gscc-cell-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Sort affordance */
th[aria-sort] .gscc-sort-icon {
  margin-left: 0.25rem;
  opacity: 0.85;
}
th[aria-sort="none"] .gscc-sort-icon { opacity: 0.45; }

/* Scroll host */
.gscc-table-host,
.gscc-table-scroll,
.table-responsive.gscc-table-host {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--gscc-color-border, #DCE3E7);
  border-radius: var(--gscc-radius-md, 6px);
  background: var(--gscc-color-surface, #fff);
}

.gscc-table-host:focus-visible {
  outline: 2px solid var(--gscc-color-primary);
  outline-offset: 2px;
}

/* No decorative edge gradient: it was absolutely positioned inside the scroller, so it
   scrolled with the rows and showed up as a dark vertical bar across list tables. */
.gscc-table-host[data-gscc-scrollable="1"]::after {
  content: none;
}

/* Pagination landmark keeps flex layout of .gp-bar */
.gp-bar > .gp-nav {
  display: contents;
}

/* Filter toolbar */
.gscc-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}
.gscc-list-toolbar .gscc-label,
.gscc-filter-bar .gscc-label {
  display: block;
  font-size: var(--gscc-fs-sm, 0.75rem);
  font-weight: var(--gscc-fw-semibold, 600);
  margin-bottom: 0.25rem;
  color: var(--gscc-color-text-secondary, #3D4A57);
}

/* Empty / loading / error */
.gscc-table-status {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--gscc-color-text-secondary, #3D4A57);
}
.gscc-table-status h2,
.gscc-table-status h3,
.gscc-table-status h5,
.gscc-table-status h6 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0.5rem 0 0.25rem;
  color: var(--gscc-color-text, #17212B);
}
.gscc-table-status p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--gscc-color-muted, #667085);
}
.gscc-table-status img {
  width: 4.5rem;
  height: auto;
  opacity: 0.85;
}
.gscc-table-status--error {
  color: var(--gscc-color-danger, #C93636);
}
.gscc-table-status--error h2,
.gscc-table-status--error h3,
.gscc-table-status--error h5,
.gscc-table-status--error h6 {
  color: var(--gscc-color-danger, #C93636);
}

.gscc-table-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 8rem;
  padding: 1.5rem;
  color: var(--gscc-color-text-secondary, #3D4A57);
  font-weight: 600;
}
.gscc-table-loading .gscc-spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: gscc-table-spin 0.7s linear infinite;
}
@keyframes gscc-table-spin {
  to { transform: rotate(360deg); }
}

/* Align legacy empty with shared look */
.al-empty,
td.dataTables_empty .card {
  padding: 2.5rem 1rem;
  text-align: center;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.al-empty img,
td.dataTables_empty img {
  width: 4.5rem;
  opacity: 0.85;
}
.al-empty h6,
td.dataTables_empty h5 {
  font-weight: 700;
  color: var(--gscc-color-text, #17212B);
}
.al-empty p,
td.dataTables_empty a.text-dark {
  color: var(--gscc-color-muted, #667085) !important;
  font-size: 0.875rem;
  text-decoration: none;
}

/* Row actions */
.gscc-row-actions,
.veiw-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}
.gscc-row-actions a:focus-visible,
.veiw-group a:focus-visible,
.veiw-group button:focus-visible {
  outline: 2px solid var(--gscc-color-primary);
  outline-offset: 2px;
}

/* KPI / chart helpers */
.gscc-kpi-value,
.gscc-stat-value {
  font-variant-numeric: tabular-nums;
}
.gscc-chart-box {
  position: relative;
}
.gscc-chart-box canvas:focus-visible {
  outline: 2px solid var(--gscc-color-primary);
  outline-offset: 2px;
}
.gscc-chart-desc {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Stackable tables (narrow viewports) — preserves all columns as labeled rows */
/* ----- Enterprise grid: horizontal row rules only (no vertical cell lines), numeric columns right-aligned ----- */
.gscc-data-table.table-bordered > :not(caption) > * > * {
  border-left-width: 0;
  border-right-width: 0;
}
.gscc-data-table.table-bordered > :not(caption) > * {
  border-width: 0;
}
.gscc-data-table.table-bordered {
  border: 0;
}
.gscc-data-table > tbody > tr > td {
  border-bottom: 1px solid var(--gscc-color-border-subtle, #E5E7EB);
}
.gscc-data-table > tbody > tr:last-child > td { border-bottom: 0; }
/* Columns detected as numeric by js/gscc-tables.js */
.gscc-data-table th.gscc-col-num,
.gscc-data-table td.gscc-col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 767.98px) {
  .gscc-stack-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .gscc-stack-table,
  .gscc-stack-table tbody,
  .gscc-stack-table tr,
  .gscc-stack-table td {
    display: block;
    width: 100%;
  }

  .gscc-stack-table tbody tr {
    margin-bottom: 0.75rem;
    border: 1px solid var(--gscc-color-border, #DCE3E7);
    border-radius: var(--gscc-radius-md, 6px);
    background: var(--gscc-color-surface, #fff);
    padding: 0.35rem 0;
  }

  .gscc-stack-table tbody td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) 1fr;
    gap: 0.5rem;
    align-items: start;
    max-width: none;
    white-space: normal;
    border-bottom: 1px solid var(--gscc-color-border-subtle, #E5E7EB);
    padding: 0.45rem 0.75rem;
  }

  .gscc-stack-table tbody td:last-child {
    border-bottom: 0;
  }

  .gscc-stack-table tbody td::before {
    content: attr(data-label);
    font-size: var(--gscc-fs-xs, 0.6875rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gscc-color-muted, #667085);
  }

  .gscc-stack-table tbody td[colspan] {
    display: block;
  }

  .gscc-stack-table tbody td[colspan]::before {
    display: none;
  }

  .gscc-stack-table .gscc-row-actions,
  .gscc-stack-table .veiw-group {
    justify-content: flex-start;
  }

  /* Wide admin tables: keep horizontal scroll (don't stack 15+ cols) unless opted in */
  .gscc-stack-table.gscc-stack-force,
  table.gscc-stack-table.gscc-stack-force {
    /* already stacking */
  }
}

@media (prefers-reduced-motion: reduce) {
  .gscc-table-loading .gscc-spinner { animation: none; opacity: 0.5; }
}

[data-gscc-theme="dark"] .gscc-table-host,
[data-gscc-theme="high-contrast"] .gscc-table-host {
  background: var(--gscc-color-surface);
}

.gscc-inst-table tbody td {
  max-width: none;
  vertical-align: top;
}
.gscc-inst-table tbody tr:nth-child(even) td {
  background: #f7fbf8;
}
.gscc-inst-table .gscc-inst-name {
  min-width: 220px;
  max-width: 34rem;
  font-weight: 600;
}
.home-page .gscc-inst-table .gscc-inst-state,
.gscc-inst-table .gscc-inst-state {
  white-space: nowrap;
}
