/* ============================================
   Table Styles
   ============================================ */

.table {
    font-size: 0.875rem;
    --bs-table-bg: var(--ias-bg-surface);
    --bs-table-color: var(--ias-text-primary);
    --bs-table-border-color: var(--ias-border);
}

.table thead th {
    font-weight: 600;
    color: var(--ias-text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    background-color: var(--ias-bg-muted);
    border-bottom: 2px solid var(--ias-border);
    padding: 0.875rem 1rem;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--ias-border);
    color: var(--ias-text-primary);
}

.table-hover tbody tr:hover {
    background-color: var(--ias-primary-light);
}

/* Clickable table rows */
.table tbody tr.clickable-row {
    cursor: pointer;
}

/* Table column widths (common sizes) */
.table .col-xs { width: 60px; }
.table .col-sm { width: 80px; }
.table .col-md { width: 100px; }
.table .col-lg { width: 120px; }
.table .col-xl { width: 150px; }
.table .col-xxl { width: 180px; }
.table .col-actions { width: 80px; }

/* ============================================
   Invoices Page Table
   ============================================ */

.invoices-page .resizable-table-container table {
    min-width: 1200px;
}

.invoices-page .table tbody tr:hover {
    background-color: var(--ias-primary-light);
}

.invoices-page .table-active {
    background-color: rgba(var(--ias-primary-rgb), 0.1) !important;
}

.invoices-page .status-cell {
    white-space: normal;
    line-height: 1.3;
}

.invoices-page .action-cell {
    white-space: nowrap;
}

/* ============================================
   Audit Logs Page Table
   ============================================ */

.audit-logs-page .card {
    border: 1px solid var(--ias-border);
    box-shadow: var(--ias-shadow-sm);
    background: var(--ias-bg-surface);
    border-radius: var(--ias-radius-lg);
}

.audit-logs-page .table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ias-text-secondary);
    border-top: none;
}

.audit-logs-page .badge {
    font-size: 0.75rem;
    font-weight: 500;
}

.audit-logs-page pre {
    font-size: 0.8rem;
    margin: 0;
}

.audit-logs-page code {
    font-size: 0.8rem;
}

/* ============================================
   Table Responsive Styles
   ============================================ */

@media (max-width: 767.98px) {
    .table-responsive {
        border-radius: var(--ias-radius-lg);
    }

    .table thead th {
        padding: 0.625rem 0.75rem;
        font-size: 0.6875rem;
    }

    .table tbody td {
        padding: 0.625rem 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .table {
        font-size: 0.8125rem;
    }

    .table thead th,
    .table tbody td {
        padding: 0.5rem;
    }
}

/* ============================================
   Sortable Header Styles
   ============================================ */

.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.15s ease;
}

.sortable-header:hover {
    background-color: var(--ias-bg-hover, rgba(0, 0, 0, 0.05));
}

.sortable-header.active {
    background-color: var(--ias-primary-light, rgba(var(--ias-primary-rgb), 0.1));
}

.sortable-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sortable-header .header-text {
    flex: 1;
}

.sortable-header .sort-indicator {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: var(--ias-primary);
    min-width: 16px;
}

.sortable-header .sort-indicator .sort-inactive {
    opacity: 0.3;
    color: var(--ias-text-muted);
    font-size: 0.75rem;
}

.sortable-header:hover .sort-indicator .sort-inactive {
    opacity: 0.6;
}

/* ============================================
   Column Resizer Styles
   ============================================ */

.column-resizer {
    position: absolute;
    right: -4px;
    top: 0;
    bottom: 0;
    width: 9px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}

.column-resizer::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: transparent;
    border-radius: 2px;
    transition: background-color 0.15s ease;
}

.column-resizer:hover::after {
    background-color: var(--ias-primary, #0d6efd);
}

th.resizing .column-resizer::after {
    background-color: var(--ias-primary, #0d6efd);
    top: 0;
    bottom: 0;
}

.resizable-table-container {
    position: relative;
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
}

.resizable-table-container table {
    table-layout: fixed;
    width: 100%;
    min-width: 0; /* Allow table to shrink */
    max-width: 100%;
}

.resizable-table-container table th,
.resizable-table-container table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

.resizable-table-container table.resizing {
    cursor: col-resize;
    user-select: none;
}

.resizable-table-container table.resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

.resizable-table-container th.resizing {
    background-color: var(--ias-primary-light, rgba(13, 110, 253, 0.1)) !important;
}
