/* Table collapse styles */

/* Row containing the collapse button */
.table-collapse-button-row {
    border-top: 1px solid var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.12));
}

/* Cell containing the collapse button */
.table-collapse-button-cell {
    text-align: center;
    padding: 0;
    background-color: var(--md-default-bg-color--light, rgba(0, 0, 0, 0.02));
}

/* Collapse/expand button */
.table-collapse-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    color: var(--md-default-fg-color--light, rgba(0, 0, 0, 0.54));
    transition: opacity 0.2s ease;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 1rem;
    max-height: 1rem;
}

.table-collapse-button:hover {
    opacity: 0.8;
}

.table-collapse-button:active {
    opacity: 0.6;
}

.table-collapse-button:focus {
    outline: none;
}

/* Hidden rows */
.table-collapse-hidden-row {
    display: none;
}

/* Ensure button row is visible */
.table-collapse-button-row {
    display: table-row;
}

/* Fix table width to prevent changes when collapsing/expanding */
table[data-collapse-processed="true"] {
    table-layout: fixed;
    width: 100%;
    max-width: 100%;
}

/* Preserve column widths from original rendering */
table[data-collapse-processed="true"] th[data-original-width],
table[data-collapse-processed="true"] td[data-original-width] {
    width: var(--original-width, auto);
}

/* Ensure all cells in the same column have consistent width */
table[data-collapse-processed="true"] th,
table[data-collapse-processed="true"] td {
    min-width: 0;
    overflow-wrap: break-word;
}

/* Prevent vertical scrolling on small screens */
@media screen and (max-width: 76.1875em) {
    /* Remove vertical overflow from table containers */
    .md-typeset__scrollwrap {
        overflow-y: visible !important;
        overflow-x: auto;
        /* max-height: none !important; */
    }
    
    /* Ensure tables with collapse script don't create vertical scroll */
    table[data-collapse-processed="true"] {
        overflow-y: visible !important;
        max-height: none !important;
    }
    
    /* Ensure parent containers don't create vertical scroll */
    .md-typeset table[data-collapse-processed="true"],
    .md-content table[data-collapse-processed="true"] {
        overflow-y: visible !important;
        max-height: none !important;
    }
    
    /* Ensure button cell doesn't create extra height */
    .table-collapse-button-cell {
        padding: 0.1rem 0 !important;
        height: auto;
        line-height: 1;
        vertical-align: middle;
    }
    
    /* Ensure button doesn't create extra space */
    .table-collapse-button {
        margin: 0;
        padding: 0;
        min-height: auto;
        height: 1rem;
        max-height: 1rem;
        line-height: 1;
    }
    
    /* Ensure button row doesn't create extra height */
    .table-collapse-button-row {
        height: auto;
        line-height: 1;
    }
}

/* Additional fixes for very small screens */
@media screen and (max-width: 59.9375em) {
    .md-typeset__scrollwrap {
        overflow-y: visible !important;
        overflow-x: auto;
        max-height: none !important;
    }
    
    table[data-collapse-processed="true"] {
        overflow-y: visible !important;
        max-height: none !important;
    }
    
    .table-collapse-button-cell {
        padding: 0.05rem 0 !important;
    }
    
    .table-collapse-button {
        padding: 0;
        height: 0.9rem;
        max-height: 0.9rem;
    }
}

