/* Spreadsheet Diff table surfaces. The treatment follows code-viewer:
 * one quiet surface, a small heading strip, and controls in the footer. */

.table-viewer {
    position: relative;
    display: flex;
    min-width: 0;
    width: 100%;
    flex-direction: column;
    padding: 0;
    gap: 0;
    overflow: hidden;
    border-radius: var(--r-sm);
    background: var(--surface-01);
    color: var(--text-primary);
}

.table-viewer__bar {
    display: flex;
    min-height: 2.75rem;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-8) var(--space-12);
    margin: var(--space-8) var(--space-12);
    border: 0;
    border-radius: var(--r-md);
    background: var(--surface-02);
}

.table-viewer__identity {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: var(--space-2);
}

.table-viewer__identity .tool-stat__value {
    overflow: hidden;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-viewer__identity .tool-stat__label {
    color: var(--text-muted);
    font-size: var(--fs-xs);
    line-height: 1.2;
}

.table-viewer__bar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-8);
    margin-left: auto;
}

.table-viewer__toggle {
    flex: 0 0 auto;
}

.table-viewer .custom-select-trigger {
    background: var(--surface-04);
}

.table-viewer> :is(.tool-table-scroll, .table-wrap, .table-responsive) {
    width: 100%;
    height: 500px;
    max-height: 500px;
    margin: 0;
    padding: 0;
    overflow: auto;
    border: 0;
    border-radius: 0;
    background: var(--surface-base);
    scrollbar-color: var(--surface-03) var(--surface-base);
}

.table-viewer> :is(.tool-table-scroll, .table-wrap, .table-responsive) thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-01);
}

.table-viewer--collapsed> :is(.tool-table-scroll, .table-wrap, .table-responsive) {
    display: none;
}

.table-viewer--collapsed>.table-viewer__footer {
    display: none;
}

.table-viewer--changed-only .table-viewer-row--unchanged {
    display: none;
}

.table-viewer__footer {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-8);
    min-height: 2.75rem;
    padding: var(--space-8) var(--space-12);
    background: var(--surface-01);
}

.table-viewer__footer-control {
    position: relative;
}

.table-viewer__footer-control>summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    list-style: none;
    cursor: pointer;
}

.table-viewer__footer-control>summary::-webkit-details-marker {
    display: none;
}

.table-viewer__footer-control[open]>summary {
    background: var(--surface-03);
    color: var(--accent);
}

.table-viewer__footer-menu {
    position: absolute;
    z-index: 5;
    right: 0;
    bottom: calc(100% + var(--space-8));
    display: grid;
    min-width: 12rem;
    max-width: min(20rem, calc(100vw - 2 * var(--space-16)));
    max-height: 19rem;
    overflow: auto;
    gap: var(--space-8);
    padding: var(--space-10);
    border: 1px solid var(--surface-rim);
    border-radius: var(--r-sm);
    background: var(--surface-02);
    box-shadow: var(--shadow-md);
}

.table-viewer__footer-menu.custom-select-menu {
    top: auto;
    left: auto;
}

.table-viewer__column-menu {
    display: grid;
    gap: var(--space-6);
    min-width: 12rem;
}

.table-viewer__column-menu label {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    cursor: pointer;
}

.table-viewer__column-menu label:hover {
    color: var(--text-primary);
}

@media (max-width: 760px) {
    .table-viewer> :is(.tool-table-scroll, .table-wrap, .table-responsive) {
        height: 420px;
        max-height: 420px;
    }
}
