/* ===================== TABLES v6.0 — Stitch Design System ===================== */
/* Data Table, Unified Table System, Sortable Headers */

/* ---- DATA TABLE (Legacy) ---- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table thead th {
    background: var(--surface-dark);
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-size: 10px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}

[data-theme="light"] .data-table thead th {
    background: rgba(241, 245, 249, 0.95);
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    vertical-align: middle;
    font-size: 13px;
}

[data-theme="light"] .data-table tbody td {
    border-bottom-color: rgba(0, 0, 0, 0.04);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr.row-negative {
    background: rgba(239, 68, 68, 0.04);
    border-left: 3px solid rgba(239, 68, 68, 0.6);
}

/* ---- SORTABLE HEADERS ---- */
.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 20px;
}

.data-table thead th.sortable:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.data-table thead th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    opacity: 0.3;
}

.data-table thead th.sortable.sort-asc::after {
    content: '↑';
    opacity: 0.8;
    color: var(--accent-blue);
}

.data-table thead th.sortable.sort-desc::after {
    content: '↓';
    opacity: 0.8;
    color: var(--accent-blue);
}

/* ---- UNIFIED TABLE SYSTEM ---- */
.ut-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.ut-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 14px 0;
    flex-shrink: 0;
    gap: 12px;
}

.ut-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ut-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.ut-search {
    background: var(--surface-dark);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    width: 220px;
    transition: var(--transition);
    outline: none;
}

[data-theme="light"] .ut-search {
    background: var(--bg-input);
    border-color: rgba(0, 0, 0, 0.1);
}

.ut-search:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.ut-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    max-height: calc(100vh - 280px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .ut-scroll {
    border-color: rgba(0, 0, 0, 0.06);
}

.ut-scroll::-webkit-scrollbar {
    width: 6px;
}

.ut-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.ut-scroll::-webkit-scrollbar-thumb {
    background: var(--surface-dark-lighter);
    border-radius: 3px;
}

.ut-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 4px 0;
    flex-shrink: 0;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.ut-page-sizes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ut-label {
    font-size: 12px;
    color: var(--text-dim);
    margin-right: 4px;
}

.ut-size-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.ut-size-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.ut-size-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    font-weight: 600;
}

.ut-info {
    font-size: 12px;
    color: var(--text-dim);
}

.ut-page-btns {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ut-page-btn {
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.ut-page-btn:hover:not(:disabled) {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.ut-page-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
    font-weight: 600;
}

.ut-page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ---- PAGINATION (Legacy) ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    font-size: 12px;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-btn {
    padding: 5px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    font-family: var(--font);
    transition: var(--transition);
}

.page-btn:hover {
    background: var(--bg-card-hover);
}

.page-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-size-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    padding: 4px 8px;
    font-size: 11px;
    font-family: var(--font);
    outline: none;
}

/* ---- FILTER BAR ---- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filter-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: var(--surface-dark);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

[data-theme="light"] .filter-chip {
    background: var(--bg-card);
    border-color: rgba(0, 0, 0, 0.08);
}

.filter-chip:hover {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.filter-chip.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--accent-blue);
}

/* ---- INFINITE SCROLL ---- */
.scroll-sentinel {
    height: 1px;
    margin-top: 10px;
}

.scroll-loading {
    text-align: center;
    padding: 16px;
    color: var(--text-dim);
    font-size: 11px;
}