/* ==========================================================================
   tables.css — Data tables across the CRM
   ========================================================================== */

.table {
    --bs-table-hover-bg: #fafbfc;
    font-size: 0.8438rem;
    color: var(--crm-text);
    margin-bottom: 0;
}

/* Header */
.table > thead th,
.table > thead.table-light th {
    background: var(--crm-surface-alt) !important;
    color: var(--crm-text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--crm-border) !important;
    white-space: nowrap;
    vertical-align: middle;
}

/* Sticky header inside scrollable card bodies */
.table-responsive { border-radius: var(--crm-radius); }
.card > .card-body.p-0 .table-responsive { max-height: none; }
.table-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Body cells */
.table > tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--crm-border);
    vertical-align: middle;
}
.table-sm > tbody td { padding: 0.625rem 0.75rem; }
.table > tbody tr:last-child td { border-bottom: 0; }

.table-hover > tbody > tr:hover > * {
    background-color: var(--bs-table-hover-bg);
}

/* Row hierarchy helpers used throughout the views */
.table td .fw-semibold { color: var(--crm-ink); }
.table td .small, .table td.small { font-size: 0.8125rem; }
.table td .fs-xs { font-size: 0.7188rem; }

/* Money — always tabular */
.table td .text-primary,
.table td .text-success {
    font-variant-numeric: tabular-nums;
}
.table td .text-primary { color: var(--crm-primary) !important; }
.table td .text-success { color: var(--crm-success) !important; }

/* Inline-edit selects that live inside table rows */
.table .form-select-sm {
    background-color: var(--crm-surface);
    border-color: var(--crm-border);
    box-shadow: none;
    font-size: 0.7813rem;
    min-height: 30px;
}
.table .form-select-sm:hover { border-color: var(--crm-border-strong); }
.table .form-select-sm:focus { border-color: var(--crm-primary); }

/* Action button clusters at the row end */
.table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.2;
}

/* Empty state row */
.table td[colspan] { border-bottom: 0; }

/* Card-embedded tables: remove doubled corners */
.card .table-responsive:first-child { border-radius: var(--crm-radius) var(--crm-radius) 0 0; }
.card .card-body.p-0 > .table-responsive > .table > thead th:first-child { border-top-left-radius: var(--crm-radius); }
.card .card-body.p-0 > .table-responsive > .table > thead th:last-child { border-top-right-radius: var(--crm-radius); }

/* DataTables (activity logs etc.) — align controls with the system */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--crm-border-strong);
    border-radius: var(--crm-radius-sm);
    padding: 0.3125rem 0.625rem;
    font-size: 0.8125rem;
}
.dataTables_wrapper .dataTables_info { font-size: 0.75rem; color: var(--crm-text-muted); }
th.hide-search input { display: none; }
