/*
 * 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 - 220px); /* leave room for header + filters */
    overflow-y: auto;
    overflow-x: hidden; /* table-layout:fixed guarantees the table fits — no phantom h-scrollbar */
    -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 - 160px);
    }
}

/* DataTables builds its length/info/pagination controls inside Bootstrap .row
   elements whose negative gutters overflow the scroll wrapper and produce a
   spurious green horizontal scrollbar. Zero the gutters to remove it. */
.crud-card .table-responsive .dataTables_wrapper > .row,
.app-content .table-responsive .dataTables_wrapper > .row,
[data-index-scroll] .dataTables_wrapper > .row,
.index-table-scroll .dataTables_wrapper > .row {
    margin-left: 0;
    margin-right: 0;
}

/* `table-fixed-cols` had no CSS rule, so the colgroup widths were ignored and the
   browser sized columns to their content (e.g. the 3 action buttons), pushing the
   table past 100% of its container — hence the horizontal scrollbar and the clipped
   first column. Enforcing fixed layout makes the colgroup widths authoritative so the
   table is exactly container-width. */
.custom-table.table-fixed-cols {
    table-layout: fixed;
    width: 100%;
    word-break: break-word;
}

/* Center every header and cell across all list tables (per request). */
.custom-table th,
.custom-table td {
    text-align: center !important;
    vertical-align: middle;
}

/* Keep the action buttons and their inner group centered too. */
.custom-table td .action-btn-group {
    justify-content: center;
}

/* Action buttons are icon-only here; the global 65px min-width makes three of them
   overflow their fixed-width column (then overflow-x:hidden clips the last one).
   Let them size to content so they fit and stay centered. */
.custom-table.table-fixed-cols .action-btn {
    min-width: 0;
}

.custom-table.table-fixed-cols .action-btn-group {
    flex-wrap: wrap;
    row-gap: 6px;
}

/* DataTables pagination: the active/current button used an undefined --primary-blue
   var so its background collapsed, leaving white text on white (invisible). Force a
   solid, high-contrast green scheme so buttons stay readable — including on hover. */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #00685E !important;
}

    .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
        background: #E7F3F2 !important;
        border-color: #00685E !important;
        color: #00685E !important;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button.current,
    .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
        background: #00685E !important;
        border-color: #00685E !important;
        color: #ffffff !important;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
    .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
        background: #f8fafc !important;
        color: #cbd5e1 !important;
        border-color: #e2e8f0 !important;
    }

/* Bootstrap5 DataTables markup uses .page-link / .page-item.active — the active link
   kept white text while hover turned the background light, making it vanish. Pin
   readable colors for every state. */
.dataTables_wrapper .pagination .page-link {
    color: #00685E !important;
}

    .dataTables_wrapper .pagination .page-link:hover {
        background: #E7F3F2 !important;
        border-color: #00685E !important;
        color: #00685E !important;
    }

    .dataTables_wrapper .pagination .page-item.active .page-link,
    .dataTables_wrapper .pagination .page-item.active .page-link:hover {
        background: #00685E !important;
        border-color: #00685E !important;
        color: #ffffff !important;
    }

    .dataTables_wrapper .pagination .page-item.disabled .page-link {
        color: #cbd5e1 !important;
        background: #f8fafc !important;
    }

/* 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;
}
