/* Global Tables & Typography Standardization
   Created: 2025-12-29
   Applies consistent table styling and typography across entire app
*/

/* =========================================
   GLOBAL TYPOGRAPHY
   ========================================= */
* {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* =========================================
   TABLE BASE STYLES
   ========================================= */
.table,
.table-dense {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* Standard table sizing */
.table {
    font-size: 15px;
    line-height: 1.7;
}

/* Dense table sizing */
.table-dense {
    font-size: 13px;
    line-height: 1.6;
}

/* =========================================
   TABLE HEADERS
   ========================================= */
.table thead th,
.table-dense thead th {
    padding: 1rem 1.25rem;
    text-align: left;
    vertical-align: middle;
    font-weight: 600;
    white-space: nowrap;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-dense thead th {
    padding: 1rem 1.25rem;
    font-size: 0.8125rem;
}

/* =========================================
   TABLE CELLS
   ========================================= */
.table tbody td,
.table-dense tbody td {
    padding: 1.25rem 1.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
    color: #495057;
    font-size: 0.9375rem;
}

.table-dense tbody td {
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
}

/* =========================================
   TABLE ROWS
   ========================================= */
.table tbody tr,
.table-dense tbody tr {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid #f8f9fa;
}

.table tbody tr:hover,
.table-dense tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

.table tbody tr:last-child,
.table-dense tbody tr:last-child {
    border-bottom: none;
}

/* =========================================
   OVERFLOW HANDLING
   ========================================= */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    background: #fff;
}

/* Add scrollbar styling */
.table-container::-webkit-scrollbar {
    height: 10px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 5px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 5px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* =========================================
   TEXT WRAPPING UTILITIES
   ========================================= */
.table .nowrap,
.table-dense .nowrap {
    white-space: nowrap;
}

.table .wrap,
.table-dense .wrap {
    white-space: normal;
    word-wrap: break-word;
}

.table .ellipsis,
.table-dense .ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================
   COLUMN WIDTH UTILITIES
   ========================================= */
.table .col-xs { width: 5%; }
.table .col-sm { width: 10%; }
.table .col-md { width: 15%; }
.table .col-lg { width: 20%; }
.table .col-xl { width: 25%; }

.table-dense .col-xs { width: 5%; }
.table-dense .col-sm { width: 10%; }
.table-dense .col-md { width: 15%; }
.table-dense .col-lg { width: 20%; }
.table-dense .col-xl { width: 25%; }

/* =========================================
   TEXT ALIGNMENT UTILITIES
   ========================================= */
.table .text-left,
.table-dense .text-left {
    text-align: left;
}

.table .text-center,
.table-dense .text-center {
    text-align: center;
}

.table .text-right,
.table-dense .text-right {
    text-align: right;
}

/* =========================================
   ACTION BUTTONS IN TABLES
   ========================================= */
.table .action-buttons,
.table-dense .action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
}

/* Ensure buttons don't overflow */
.table .btn,
.table-dense .btn {
    white-space: nowrap;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.table .btn:hover,
.table-dense .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.table-dense .btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* Three-dot menu button */
.table .btn-menu,
.table-dense .btn-menu {
    padding: 0.5rem;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.table .btn-menu:hover,
.table-dense .btn-menu:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

/* =========================================
   BADGES IN TABLES
   ========================================= */
.table .badge,
.table-dense .badge {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    font-size: 0.8125rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 600;
    line-height: 1.5;
}

/* =========================================
   RESPONSIVE TABLE BEHAVIOR
   ========================================= */
@media (max-width: 768px) {
    .table,
    .table-dense {
        font-size: 12px;
    }
    
    .table-dense {
        font-size: 11px;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.6rem 0.5rem;
    }
    
    .table-dense thead th,
    .table-dense tbody td {
        padding: 0.5rem 0.4rem;
    }
}

/* =========================================
   LEGACY COMPATIBILITY
   ========================================= */
/* Support for existing .data-table class */
.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

.data-table thead th {
    padding: 1rem 1.25rem;
    text-align: left;
    vertical-align: middle;
    font-weight: 600;
    white-space: nowrap;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid #e5e7eb;
    white-space: normal;
    overflow: visible;
    color: #1f2937;
    font-size: 0.9375rem;
}

.data-table tbody tr {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

/* Support for existing .table-compact class */
.table-compact {
    overflow-x: auto;
}

.table-compact table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 12px;
    line-height: 1.35;
}

.table-compact th {
    padding: 0.65rem 0.65rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    background: #f8f9fa;
    border-bottom: 2px solid #e6e8eb;
}

.table-compact td {
    padding: 0.65rem 0.65rem;
    vertical-align: top;
    border-bottom: 1px solid #e6e8eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0; /* Enable ellipsis to work with fixed layout */
}

.table-compact tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

/* =========================================
   EMPTY STATE
   ========================================= */
.table-empty,
.table-dense-empty {
    padding: 2rem;
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

/* =========================================
   TABLE UTILITIES
   ========================================= */
/* Force specific cells to allow wrapping */
.table td.allow-wrap,
.table-dense td.allow-wrap,
.data-table td.allow-wrap {
    white-space: normal;
    word-wrap: break-word;
    max-width: none;
}

/* First column auto-wrap for better readability */
.table tbody tr td:first-child,
.table-dense tbody tr td:first-child,
.data-table tbody tr td:first-child {
    white-space: normal;
    word-wrap: break-word;
    max-width: none;
    min-width: 150px;
}

/* Numeric columns - right align */
.table td.numeric,
.table-dense td.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Status cells - center align */
.table td.status,
.table-dense td.status {
    text-align: center;
}

/* Actions column - always centered and no wrap */
.table th.actions,
.table td.actions,
.table-dense th.actions,
.table-dense td.actions {
    text-align: center;
    white-space: nowrap;
}
