/**
 * GRC standard data tables — app-wide (inside .content-area).
 * Horizontal rules only, soft header band, maroon identifiers, comfortable row height.
 * Excludes: .table-bordered (grids / heatmaps), matrix & heatmap tables (own chrome).
 * Dashboard (.db-table) uses the same rules — dashboard.css no longer restyles the grid.
 */

:root {
    --grc-dt-header-bg: var(--surface-subtle, #f8fafc);
    --grc-dt-row-line: var(--border-light, #e5e7eb);
    --grc-dt-text: var(--text-strong, #111827);
    --grc-dt-header-text: var(--color-gray-700, #374151);
    --grc-dt-muted: var(--text-muted, #6b7280);
    --grc-dt-id: #842a3b;
    --grc-dt-hover: var(--surface-subtle, #f8fafc);
    --grc-dt-cell-py: 0.65rem;
    --grc-dt-cell-px: 1rem;
}

/* Specialty tables: keep existing module styling */
.content-area .table:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table),
.content-area .db-table:not(.table-bordered) {
    --bs-table-bg: transparent;
    --bs-table-border-color: transparent;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--font-md, var(--text-table));
    color: var(--grc-dt-text);
    margin-bottom: 0;
    width: 100%;
}

.content-area .table:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) > :not(caption) > * > *,
.content-area .db-table:not(.table-bordered) > :not(caption) > * > * {
    box-shadow: none;
}

.content-area .table:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) thead th,
.content-area .db-table:not(.table-bordered) thead th {
    background: var(--grc-dt-header-bg) !important;
    color: var(--grc-dt-header-text) !important;
    font-size: var(--font-sm, var(--text-xs));
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: none;
    padding: var(--grc-dt-cell-py) var(--grc-dt-cell-px);
    vertical-align: middle;
    border: none !important;
    border-bottom: 1px solid var(--grc-dt-row-line) !important;
}

.content-area .table:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) tbody td,
.content-area .db-table:not(.table-bordered) tbody td {
    padding: var(--grc-dt-cell-py) var(--grc-dt-cell-px);
    background: var(--surface, #fff);
    color: var(--grc-dt-text);
    vertical-align: middle;
    border: none !important;
    border-bottom: 1px solid var(--grc-dt-row-line) !important;
}

.content-area .table:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) tbody tr:last-child td,
.content-area .db-table:not(.table-bordered) tbody tr:last-child td {
    border-bottom: none !important;
}

.content-area .table-hover:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) tbody tr:hover td,
.content-area .db-table:not(.table-bordered) tbody tr:hover td {
    background: var(--grc-dt-hover);
}

.content-area .table-striped:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: #fafafa;
    background-color: var(--surface-subtle, #fafafa) !important;
}

.content-area .table-striped:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) > tbody > tr:nth-of-type(odd):hover > * {
    background-color: var(--grc-dt-hover) !important;
}

.content-area .table.table-sm:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) thead th,
.content-area .db-table.table-sm:not(.table-bordered) thead th,
.content-area .table.table-sm:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) tbody td,
.content-area .db-table.table-sm:not(.table-bordered) tbody td {
    padding: 0.5rem 0.75rem;
}

/* Identifiers in cells (<code>) — burgundy */
.content-area .table:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) tbody td code,
.content-area .table:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) thead th code,
.content-area .db-table:not(.table-bordered) tbody td code,
.content-area .db-table:not(.table-bordered) thead th code {
    font-family: var(--font-primary);
    font-variant-numeric: tabular-nums;
    font-size: var(--font-md, var(--text-table));
    font-weight: 400;
    color: var(--grc-dt-id);
    background: transparent;
    padding: 0;
}

.grc-text-record-id,
.grc-text-record-code {
    font-family: var(--font-primary);
    font-variant-numeric: tabular-nums;
    font-size: var(--font-md, var(--text-table));
    font-weight: 400;
    color: var(--grc-dt-id);
}

.grc-text-lifecycle {
    color: var(--grc-dt-muted);
    font-size: inherit;
}

/* Row action control — kebab / overflow (matches app button tokens) */
.content-area .btn.grc-table-action-btn {
    width: 2rem;
    height: 2rem;
    min-height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--btn-bordered-border);
    background: var(--btn-bordered-bg);
    border-radius: 0;
    color: var(--btn-bordered-color);
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0.02em;
}

.content-area .btn.grc-table-action-btn:hover,
.content-area .btn.grc-table-action-btn:focus-visible {
    background: var(--btn-bordered-bg-hover);
    border-color: var(--btn-bordered-border);
    color: var(--btn-bordered-color);
}

/* Column reorder (draggable table headers) */
th.column-reorder-handle {
    cursor: grab;
    user-select: none;
}

th.column-reorder-handle.dragging {
    opacity: 0.65;
}

/* Checkbox column (bulk select) */
.content-area .table:not(.table-bordered):not(.risk-config-matrix-table):not(.risk-heatmap-table):not(.risk-heatmap-drill-table) thead th.risk-table--check {
    width: 2.5rem;
    padding-left: 0.75rem;
    padding-right: 0.25rem;
}
