/*
 * Internal table scroll for Index pages.
 * Makes the table body scroll INTERNALLY instead of pushing the whole page.
 * Apply by wrapping table inside `.index-table-scroll` or by adding it to existing wrappers.
 *
 * Used on: Index pages (Departments, Floors, Buildings, Tickets, etc.)
 */

/* Scoped to crud-table inside Index pages */
.crud-card .crud-table-wrapper,
.crud-card .table-responsive,
.app-content .table-responsive,
[data-index-scroll],
.index-table-scroll {
    max-height: calc(100vh - 280px); /* leave room for header + filters + footer */
    min-height: 400px;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
}

/* Sticky header inside scrollable wrapper */
.crud-card .crud-table-wrapper > table > thead > tr > th,
.crud-card .table-responsive > table > thead > tr > th,
.app-content .table-responsive > table > thead > tr > th,
[data-index-scroll] > table > thead > tr > th,
.index-table-scroll > table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--mot-primary, #00685E);
    color: #ffffff;
}

/* Custom scrollbar for cleaner look */
.crud-card .crud-table-wrapper::-webkit-scrollbar,
.crud-card .table-responsive::-webkit-scrollbar,
.app-content .table-responsive::-webkit-scrollbar,
[data-index-scroll]::-webkit-scrollbar,
.index-table-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.crud-card .crud-table-wrapper::-webkit-scrollbar-thumb,
.crud-card .table-responsive::-webkit-scrollbar-thumb,
.app-content .table-responsive::-webkit-scrollbar-thumb,
[data-index-scroll]::-webkit-scrollbar-thumb,
.index-table-scroll::-webkit-scrollbar-thumb {
    background: var(--mot-primary, #00685E);
    border-radius: 4px;
}

.crud-card .crud-table-wrapper::-webkit-scrollbar-track,
.crud-card .table-responsive::-webkit-scrollbar-track,
.app-content .table-responsive::-webkit-scrollbar-track,
[data-index-scroll]::-webkit-scrollbar-track,
.index-table-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

/* Smaller screens: less reserved space */
@media (max-width: 768px) {
    .crud-card .crud-table-wrapper,
    .crud-card .table-responsive,
    .app-content .table-responsive,
    [data-index-scroll],
    .index-table-scroll {
        max-height: calc(100vh - 200px);
        min-height: 300px;
    }
}

/* Skip rule for items-table-wrapper (used in EditDraft / forms — already has its own scroll) */
.items-table-wrapper {
    max-height: none !important;
    min-height: 0 !important;
}
