/* === Phase 3: Tables === */

/* Kill the legacy light border that bleeds through on dark theme */
table {
    border: none !important;
}

/* Wrap tables in a rounded container */
.table-responsive {
    border-radius: 8px !important;
    border: 1px solid var(--border-glass) !important;
    overflow: hidden !important;
}

.table {
    color: var(--text-primary) !important;
    border: none !important;
    border-collapse: collapse !important;
    margin-bottom: 0 !important;
}

/* Table head: clean, transparent */
.table thead th {
    background: transparent !important;
    border-color: transparent !important;
    border-bottom: 1px solid var(--border-glass) !important;
    border-top: none !important;
    color: var(--text-secondary) !important;
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    padding: 1rem 1rem !important;
    white-space: nowrap;
}

/* Sortable header links */
.table thead th a,
.table thead th a.nav-link,
.table thead th a:hover,
.table thead th a:focus {
    color: var(--text-secondary) !important;
    font-weight: 700 !important;
    text-decoration: none !important;
}

table.table thead th a:hover {
    color: var(--text-primary) !important;
}

/* Table cells */
.table td,
.table th {
    border-color: var(--border-glass) !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: 1px solid var(--border-glass) !important;
    padding: 1rem 1rem !important;
    vertical-align: middle !important;
    font-size: 0.85rem !important;
    background: transparent !important;
}

/* No border on last row */
.table tbody tr:last-child td,
.table tbody tr:last-child th {
    border-bottom: none !important;
}

/* Row hover: transparent or very subtle */
.table-hover > tbody > tr:hover > td,
.table-hover > tbody > tr:hover > th {
    background-color: var(--surface-overlay) !important;
    color: var(--text-primary) !important;
    transition: background-color 0.2s ease;
}

/* Striped rows: transparent for cleaner look */
.table-striped > tbody > tr:nth-of-type(odd),
.table-striped-alt > tbody > tr:nth-of-type(odd) {
    background-color: transparent !important;
}

/* table-curved: reset conflicting light-theme styles */
.table-curved {
    border-collapse: collapse !important;
    border-radius: 0 !important;
    border: none !important;
    border-left: none !important;
}

.table-curved td,
.table-curved th {
    border-left: none !important;
    border-top: none !important;
    border-bottom: 1px solid var(--border-glass) !important;
}

.table-curved th {
    border-top: none !important;
    border-radius: 0 !important;
}
.table-curved th:first-child,
.table-curved th:last-child,
.table-curved th:only-child,
.table-curved tr:last-child td:first-child,
.table-curved tr:last-child td:last-child,
.table-curved thead tr:first-child td:first-child,
.table-curved thead tr:first-child td:last-child {
    border-radius: 0 !important;
}

/* Expand/subtable rows */
.table tr.expand_details > td.subtable {
    padding: 20px !important;
    .table-responsive {
        background: rgba(0, 0, 0, 0.2) !important;
    }
}
.table-hover tbody tr:hover {
    color: var(--text-primary) !important;
}

/* Action buttons inside tables */
.table .btn-xs,
.table .btn-group .btn-xs,
.table .btn-group .btn {
    font-size: 0.73rem !important;
    padding: 0.22rem 0.6rem !important;
    border-radius: 4px !important;
    font-weight: 500 !important;
}

.table .btn-light {
    background: var(--surface-hover) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.table .btn-light:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.table .dropdown-menu > li > a {
    color: var(--text-secondary);
}

.table .dropdown-menu > li > a:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Badges inside tables */
.table .badge {
    font-size: 0.65rem !important;
    padding: 0.28em 0.6em !important;
    border-radius: 3px !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
}
