/**
 * DBIM Tables — Alignment
 * Source: https://dbimtoolkit.digifootprint.gov.in (Typography §4.1.1 Application/Usage)
 *
 * Column names are centre-aligned, text is left-aligned, numbers are right-aligned.
 * "Numbers" = S.No, Year/FY, Size, counts, amounts, percentages, totals.
 * Dates stay left-aligned; the Action (buttons) column stays right-aligned.
 *
 * Code-rendered tables mark numeric cells with `.dbim-num`. Tables authored in
 * Elementor HTML / text-editor widgets are tagged at runtime by
 * assets/js/dbim-tables.js (`.dbim-table`, `th.dbim-head`, `td.dbim-num`).
 */

/* Column names: centred (overrides ux4g's !important .text-end/.text-start on <th>). */
.table > thead > tr > th,
table.dataTable > thead > tr > th,
table thead th,
table th.dbim-head,
table.dbim-table td.dbim-head {
    text-align: center;
}

table thead th.text-end,
table thead th.text-start,
table thead th.dbim-num, /* DataTables columnDefs.className also lands on the <th> */
table th.dbim-head.text-end,
table th.dbim-head.text-start {
    text-align: center !important;
}

/* Text cells: left. Elementor widgets can inherit a centred alignment from the widget. */
table.dbim-table td:not(.dbim-head),
table.dbim-table tbody th:not(.dbim-head) {
    text-align: left;
}

/* Row labels (<th> beside <td>s, e.g. label/value detail tables) are text, not column names. */
table tbody tr:has(> td) > th:not(.dbim-head) {
    text-align: left;
}

/* Numbers: right, with tabular digits so columns line up. */
table td.dbim-num,
table th.dbim-num {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Mobile card layouts turn each cell into a label/value row; keep those left. */
@media (max-width: 767px) {
    .custom-card-table .table td.dbim-num,
    .custom-card-table-2 .table td.dbim-num,
    .custom-card-table-3 .table td.dbim-num,
    .custom-card-table-4 .table td.dbim-num {
        text-align: left !important;
        white-space: normal;
    }
}

table thead th.dbim-num {
    white-space: normal;
}
