/* TCC CRM Design System - Professional Table Styles
 * Replaces generic Bootstrap tables with polished, corporate look
 * Created: January 30, 2026
 */

/* ===================
 * BASE TABLE STYLES
 * =================== */
.table {
    --table-border-color: var(--color-border);
    --table-hover-bg: rgba(0, 51, 102, 0.04);
    --table-striped-bg: rgba(0, 0, 0, 0.015);

    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-sm);
    margin-bottom: 0;
}

/* Wrap tables in a card-like container for shadow effect */
.table-container {
    background: var(--color-bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

/* ===================
 * TABLE HEADER
 * Professional, refined header
 * =================== */
.table > thead {
    position: relative;
}

.table > thead > tr > th {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 2px solid var(--tcc-primary);
    color: var(--tcc-primary);
    font-weight: var(--font-semibold);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.875rem 1rem;
    white-space: nowrap;
    vertical-align: middle;
}

/* Remove top border from thead */
.table > thead > tr:first-child > th {
    border-top: none;
}

/* Sortable column indicator */
.table > thead > tr > th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast);
}

.table > thead > tr > th.sortable:hover {
    background: linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
}

/* ===================
 * TABLE BODY
 * Clean rows with subtle hover
 * =================== */
.table > tbody > tr > td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
    transition: background-color var(--transition-fast);
}

/* Last row - no bottom border */
.table > tbody > tr:last-child > td {
    border-bottom: none;
}

/* Hover effect - subtle navy tint */
.table-hover > tbody > tr:hover > td {
    background-color: var(--table-hover-bg);
}

/* Striped rows - very subtle */
.table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: var(--table-striped-bg);
}

/* Striped + hover combined */
.table-striped.table-hover > tbody > tr:hover > td {
    background-color: var(--table-hover-bg);
}

/* ===================
 * CLICKABLE ROWS
 * =================== */
.table > tbody > tr.clickable-row {
    cursor: pointer;
}

.table > tbody > tr.clickable-row:hover > td {
    background-color: rgba(0, 51, 102, 0.06);
}

.table > tbody > tr.clickable-row:active > td {
    background-color: rgba(0, 51, 102, 0.1);
}

/* ===================
 * TABLE CELL VARIANTS
 * =================== */

/* Compact cells for action buttons */
.table td.cell-actions {
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
    text-align: right;
    width: 1%;
}

/* Numeric data - right aligned, monospace */
.table td.cell-number,
.table th.cell-number {
    text-align: right;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

/* Currency cells */
.table td.cell-currency {
    text-align: right;
    font-family: var(--font-mono);
    font-weight: var(--font-semibold);
    color: var(--tcc-accent);
}

/* Date cells */
.table td.cell-date {
    white-space: nowrap;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

/* Truncated text cells */
.table td.cell-truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Centered cells */
.table th.cell-center,
.table td.cell-center {
    text-align: center;
}

/* Small/minimal width */
.table th.cell-min,
.table td.cell-min {
    width: 1%;
    white-space: nowrap;
}

/* ===================
 * DONOR NAME STYLING
 * Makes donor names stand out
 * =================== */
.donor-name {
    font-weight: var(--font-semibold);
    color: var(--tcc-primary);
}

.donor-name:hover {
    color: var(--tcc-secondary);
    text-decoration: underline;
}

.donor-name-cell {
    min-width: 180px;
}

/* ===================
 * AMOUNT/CURRENCY DISPLAY
 * =================== */
.amount-display {
    font-family: var(--font-mono);
    font-weight: var(--font-semibold);
    color: var(--tcc-accent);
}

.amount-display-lg {
    font-size: var(--text-lg);
}

.amount-positive {
    color: var(--color-success);
}

.amount-negative {
    color: var(--color-danger);
}

/* ===================
 * IMPROVED BADGES IN TABLES
 * =================== */
.table .badge {
    font-size: 0.7rem;
    font-weight: var(--font-medium);
    padding: 0.35em 0.65em;
    border-radius: var(--radius-sm);
    letter-spacing: 0.3px;
}

/* Organization badges - refined */
.badge-org {
    font-size: 0.65rem;
    font-weight: var(--font-bold);
    padding: 0.25em 0.5em;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
}

.badge-org-tcc {
    background-color: var(--tcc-primary);
    color: white;
}

.badge-org-tccf {
    background-color: #0891b2;
    color: white;
}

.badge-org-atl {
    background-color: var(--color-text-muted);
    color: white;
}

/* Status badges - refined */
.badge-status {
    font-size: 0.7rem;
    font-weight: var(--font-semibold);
    padding: 0.3em 0.6em;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-status-active,
.badge-status-success,
.badge-status-generated {
    background-color: rgba(25, 135, 84, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.badge-status-pending,
.badge-status-warning {
    background-color: rgba(255, 193, 7, 0.15);
    color: #997404;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.badge-status-inactive,
.badge-status-danger,
.badge-status-held {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--color-danger);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.badge-status-info {
    background-color: rgba(13, 202, 240, 0.1);
    color: #0aa2c0;
    border: 1px solid rgba(13, 202, 240, 0.2);
}

/* ===================
 * ACTION BUTTONS IN TABLES
 * =================== */
.table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.table .btn-group-sm > .btn {
    padding: 0.2rem 0.4rem;
}

/* Action button group styling */
.table-actions {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
}

.table-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Icon-only buttons in tables */
.btn-icon-sm {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ===================
 * TABLE RESPONSIVE WRAPPER
 * =================== */
.table-responsive {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Add shadow when inside card */
.card .table-responsive {
    margin: -1px;
}

.card .table {
    margin-bottom: 0;
}

.card .table > thead > tr:first-child > th:first-child {
    border-top-left-radius: var(--radius-lg);
}

.card .table > thead > tr:first-child > th:last-child {
    border-top-right-radius: var(--radius-lg);
}

/* ===================
 * EMPTY TABLE STATE
 * =================== */
.table-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.table-empty-icon {
    font-size: 3rem;
    color: var(--color-text-light);
    margin-bottom: 1rem;
}

.table-empty-message {
    font-size: var(--text-base);
    margin-bottom: 0.5rem;
}

.table-empty-hint {
    font-size: var(--text-sm);
    color: var(--color-text-light);
}

/* ===================
 * LOADING STATE
 * =================== */
.table-loading {
    position: relative;
    min-height: 200px;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================
 * SELECTED ROW
 * =================== */
.table > tbody > tr.selected > td {
    background-color: rgba(0, 51, 102, 0.08);
    border-color: rgba(0, 51, 102, 0.15);
}

/* ===================
 * TABLE FOOTER
 * =================== */
.table > tfoot > tr > td {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-top: 2px solid var(--color-border);
    font-weight: var(--font-semibold);
    padding: 0.75rem 1rem;
}

/* ===================
 * SPECIAL TABLE VARIANTS
 * =================== */

/* Compact table - tighter spacing */
.table-compact > thead > tr > th,
.table-compact > tbody > tr > td {
    padding: 0.5rem 0.75rem;
    font-size: var(--text-xs);
}

/* Borderless variant */
.table-borderless > tbody > tr > td {
    border-bottom: none;
}

/* Card-style rows */
.table-cards > tbody > tr {
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-md);
}

.table-cards > tbody > tr > td:first-child {
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}

.table-cards > tbody > tr > td:last-child {
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

/* ===================
 * RESPONSIVE ADJUSTMENTS
 * =================== */
@media (max-width: 768px) {
    .table > thead > tr > th,
    .table > tbody > tr > td {
        padding: 0.625rem 0.5rem;
        font-size: var(--text-xs);
    }

    /* Hide less important columns on mobile */
    .table .d-none-mobile {
        display: none !important;
    }
}

/* ===================
 * PRINT STYLES
 * =================== */
@media print {
    .table {
        font-size: 10pt;
    }

    .table > thead > tr > th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .table-actions,
    .btn {
        display: none !important;
    }
}
