/* ============================================================================
   SORTABLE TABLES COMPONENT
   Clean, data-dense tables - FootyStats style
   ============================================================================ */

/* Enhanced table wrapper */
.enhanced-table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    background: var(--match-card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* Table base styles */
.enhanced-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    table-layout: auto;
}

/* Table header */
.enhanced-table thead {
    background: var(--match-dark-bg);
    border-bottom: 2px solid var(--border-medium);
}

.enhanced-table th {
    padding: var(--spacing-md);
    text-align: left;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    user-select: none;
}

/* Sortable column headers */
.enhanced-table th.sortable {
    cursor: pointer;
    position: relative;
    transition: background-color var(--transition-fast);
}

.enhanced-table th.sortable:hover {
    background-color: var(--table-hover);
}

/* Sort indicators */
.enhanced-table th.sortable::after {
    content: '⇅';
    margin-left: var(--spacing-xs);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

.enhanced-table th.sortable.asc::after {
    content: '↑';
    color: var(--primary-green);
}

.enhanced-table th.sortable.desc::after {
    content: '↓';
    color: var(--primary-green);
}

/* Table body */
.enhanced-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background-color var(--transition-fast);
}

.enhanced-table tbody tr:hover {
    background-color: var(--table-hover);
    cursor: pointer;
}

.enhanced-table tbody tr:last-child {
    border-bottom: none;
}

.enhanced-table td {
    padding: var(--spacing-md);
    color: var(--text-secondary);
    vertical-align: top;
}

/* Column-specific styling for proper alignment */
.enhanced-table td:nth-child(1) { /* Time column */
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    text-align: center;
}

.enhanced-table td:nth-child(2) { /* Fixture column */
    width: 100%;
    min-width: 0;
}

/* Striped rows */
.enhanced-table.striped tbody tr:nth-child(even) {
    background-color: var(--table-stripe);
}

.enhanced-table.striped tbody tr:nth-child(even):hover {
    background-color: var(--table-hover);
}

/* Compact variant */
.enhanced-table.compact th,
.enhanced-table.compact td {
    padding: var(--spacing-sm);
}

/* Bordered variant */
.enhanced-table.bordered td,
.enhanced-table.bordered th {
    border-right: 1px solid var(--border-light);
}

.enhanced-table.bordered td:last-child,
.enhanced-table.bordered th:last-child {
    border-right: none;
}

/* Team cell with logo */
.team-cell {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
}

.team-cell img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.team-cell.small img {
    width: 20px;
    height: 20px;
}

/* Simplified 2-column layout for matches */

.teams-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 12px;
    flex-wrap: nowrap;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.vs-separator {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
    margin: 0 8px;
}

.score-venue-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.score-display {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.venue-display {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Centered content */
.enhanced-table .text-center {
    text-align: center;
}

.enhanced-table .text-right {
    text-align: right;
}

/* Numeric columns */
.enhanced-table td.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: var(--font-weight-medium);
}

/* Highlighted column */
.enhanced-table th.highlight,
.enhanced-table td.highlight {
    background-color: var(--bg-neutral);
    font-weight: var(--font-weight-semibold);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .enhanced-table {
        font-size: var(--font-size-xs);
    }
    
    .enhanced-table th,
    .enhanced-table td {
        padding: var(--spacing-sm);
    }
    
    /* Hide specific columns on mobile */
    .enhanced-table th.hide-mobile,
    .enhanced-table td.hide-mobile {
        display: none;
    }
    
    /* Mobile layout for simplified matches */
    .match-time {
        min-width: 60px !important;
        padding: var(--spacing-xs) !important;
    }
    
    .fixture-info {
        min-width: 250px !important;
        padding: var(--spacing-xs) !important;
    }
    
    .teams-row {
        flex-direction: column;
        gap: 8px;
        align-items: center;
        max-width: 300px;
    }
    
    .vs-separator {
        margin: 4px 0;
    }
    
    .team-cell img {
        width: 20px;
        height: 20px;
    }
    
    .score-display {
        font-size: 13px;
    }
    
    .venue-display {
        font-size: 10px;
        max-width: 180px;
    }
    
    /* Stack layout for very small screens */
    .enhanced-table.mobile-stack {
        display: block;
    }
    
    .enhanced-table.mobile-stack thead {
        display: none;
    }
    
    .enhanced-table.mobile-stack tbody,
    .enhanced-table.mobile-stack tr,
    .enhanced-table.mobile-stack td {
        display: block;
        width: 100%;
    }
    
    .enhanced-table.mobile-stack tr {
        margin-bottom: var(--spacing-md);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-sm);
    }
    
    .enhanced-table.mobile-stack td {
        border-bottom: 1px solid var(--border-light);
        display: flex;
        justify-content: space-between;
        padding: var(--spacing-sm);
    }
    
    .enhanced-table.mobile-stack td:last-child {
        border-bottom: none;
    }
    
    .enhanced-table.mobile-stack td::before {
        content: attr(data-label);
        font-weight: var(--font-weight-semibold);
        color: var(--text-primary);
    }
}

/* Loading state */
.enhanced-table.loading tbody tr {
    opacity: 0.5;
}

.enhanced-table.loading tbody tr td {
    color: transparent;
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border-medium) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Empty state */
.enhanced-table tbody.empty::after {
    content: 'No data available';
    display: block;
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* Sticky header */
.enhanced-table.sticky-header thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--background-secondary);
}

/* Row selection */
.enhanced-table tbody tr.selected {
    background-color: var(--bg-info);
}

.enhanced-table tbody tr.selected:hover {
    background-color: #bfdbfe;
}



