/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * FailproofTable - shared data table styles (MDB-compatible markup)
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

.fp-table-root
{
    --fp-table-header-bg: #e9ecef;
    --fp-table-header-color: #212529;
    --fp-table-header-border: #adb5bd;
    --fp-table-header-hover-bg: #dee2e6;
    --fp-table-group-bg: #dee2e6;
    --fp-table-group-divider: rgba(0, 0, 0, 0.14);
    --fp-table-body-bg: #fff;
    --fp-table-hover-bg: #f1f3f5;
    --fp-table-border: #dee2e6;
    --fp-table-sort-icon-color: #6c757d;
    --fp-table-sort-icon-active: #212529;

    /*
     * Bound width to the parent so a max-content <table> scrolls inside
     * .fp-table-scroll - otherwise the scroll box grows with the table and
     * an ancestor (e.g. stepper panels) shows the horizontal scrollbar.
     */
    width: 100%;
    min-width: 0;
}

.fp-table-scroll
{
    width: 100%;
    max-height: 65vh;
    overflow: auto;
    border: 1px solid var(--fp-table-border);
    background: var(--fp-table-body-bg);
    border-radius: 0.25rem;
}

.fp-table
{
    margin-bottom: 0;
    width: max-content;
    min-width: 100%;
    white-space: nowrap;
    border-collapse: separate;
    border-spacing: 0;
}

/* Base header look - vertical stickiness applied via .fp-table-head */
.fp-table thead th
{
    background-color: var(--fp-table-header-bg) !important;
    color: var(--fp-table-header-color);
    vertical-align: middle;
    font-size: 0.8rem;
    font-weight: 600;
    border-bottom: 2px solid var(--fp-table-header-border);
    /* Kill MDB/Bootstrap inset accent shadow that breaks sticky paints */
    box-shadow: none !important;
}

/* Column header row sticks; group header row scrolls away with content */
.fp-table thead tr.fp-table-column-row th.fp-table-head
{
    position: sticky;
    top: 0;
    z-index: 4;
}

.fp-table thead tr.fp-table-group-row th
{
    position: relative;
    z-index: 1;
    background-color: var(--fp-table-group-bg) !important;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.72rem;
    font-weight: 700;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--fp-table-header-border);
    border-left: none;
}

/*
 * Empty / identity group cells use the same darker band as labeled groups
 * (Employee, Manager, …) so the group row reads as one continuous strip.
 */
.fp-table thead tr.fp-table-group-row th.fp-table-group-empty
{
    background-color: var(--fp-table-group-bg) !important;
}

/*
 * Empty group cells above sticky identity columns: stick horizontally only
 * (top: auto) so they scroll away vertically, but cover scrolling group labels.
 */
.fp-table thead tr.fp-table-group-row th.fp-table-sticky
{
    position: sticky !important;
    top: auto !important;
    z-index: 11;
    background-color: var(--fp-table-group-bg) !important;
}

/* Divider only between groups (not before the first group after sticky cols) */
.fp-table thead tr.fp-table-group-row th.fp-table-group-start,
.fp-table thead tr.fp-table-column-row th.fp-table-group-start,
.fp-table tbody td.fp-table-group-start
{
    border-left: 1px solid var(--fp-table-group-divider);
}

.fp-table tbody td
{
    vertical-align: middle;
    background-color: var(--fp-table-body-bg) !important;
    border-bottom: 1px solid var(--fp-table-border);
    box-shadow: none !important;
}

.fp-table tbody tr:hover td
{
    background-color: var(--fp-table-hover-bg) !important;
}

/*
 * Sticky left columns.
 * left is set inline from declared widths (same for header + body).
 * ::before paints 2px over the previous sticky col to seal subpixel seams.
 */
.fp-table th.fp-table-sticky,
.fp-table td.fp-table-sticky
{
    position: sticky !important;
    z-index: 5;
    box-sizing: border-box;
    background-color: var(--fp-table-body-bg) !important;
}

.fp-table th.fp-table-sticky::before,
.fp-table td.fp-table-sticky::before
{
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -3px;
    width: 3px;
    pointer-events: none;
    background-color: var(--fp-table-body-bg);
}

.fp-table thead tr.fp-table-column-row th.fp-table-sticky
{
    z-index: 12;
    background-color: var(--fp-table-header-bg) !important;
}

.fp-table thead tr.fp-table-column-row th.fp-table-sticky::before
{
    background-color: var(--fp-table-header-bg);
}

.fp-table thead tr.fp-table-group-row th.fp-table-sticky::before
{
    background-color: var(--fp-table-group-bg);
}

/*
 * Right-edge sticky separator - gradient strip flush outside the cell (not a
 * 1px + box-shadow combo, which left a white hairline). Stays off the Name
 * face. Applied to column header, group sticky-last empty, and body.
 */
.fp-table thead tr.fp-table-column-row th.fp-table-sticky-last::after,
.fp-table thead tr.fp-table-group-row th.fp-table-sticky-last::after,
.fp-table tbody td.fp-table-sticky-last::after
{
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 100%;
    width: 7px;
    pointer-events: none;
    background: linear-gradient(
        to right,
        rgba(0, 0, 0, 0.12) 0%,
        rgba(0, 0, 0, 0.05) 45%,
        rgba(0, 0, 0, 0) 100%
    );
}

/*
 * Body sticky below all header cells (incl. non-sticky headers at z-index 4)
 * so the right-edge sticky separator never paints over the header row.
 * Later sticky cols stack above earlier ones so the 1px overlap seals cleanly.
 */
.fp-table tbody td.fp-table-sticky
{
    z-index: 2;
}

.fp-table tbody td.fp-table-sticky-last
{
    z-index: 3;
}

/* Kill white hairline at the top of the first body row under sticky thead */
.fp-table tbody tr:first-child > *
{
    border-top: none !important;
}

.fp-table tbody tr:hover td.fp-table-sticky
{
    background-color: var(--fp-table-hover-bg) !important;
}

.fp-table tbody tr:hover td.fp-table-sticky::before
{
    background-color: var(--fp-table-hover-bg);
}

/*
 * Below options.stickyMinWidth, JS adds .fp-table-no-sticky: left pins off,
 * but column headers stay sticky (top) across the whole table - including
 * former sticky identity columns (previously forced to position:static).
 */
.fp-table-root.fp-table-no-sticky tbody td.fp-table-sticky
{
    position: static !important;
    left: auto !important;
    z-index: auto !important;
}

/*
 * Vertical stick only - same as other .fp-table-head cells. Inline left is
 * cleared in JS when .fp-table-no-sticky is on (left:!important from offsets
 * would otherwise keep these headers pinned while the row scrolls).
 */
.fp-table-root.fp-table-no-sticky thead tr.fp-table-column-row th.fp-table-sticky
{
    position: sticky !important;
    top: 0 !important;
    left: auto !important;
    z-index: 4 !important;
}

.fp-table-root.fp-table-no-sticky thead tr.fp-table-group-row th.fp-table-sticky
{
    position: static !important;
    top: auto !important;
    left: auto !important;
    z-index: auto !important;
}

.fp-table-root.fp-table-no-sticky th.fp-table-sticky::before,
.fp-table-root.fp-table-no-sticky td.fp-table-sticky::before,
.fp-table-root.fp-table-no-sticky th.fp-table-sticky-last::after,
.fp-table-root.fp-table-no-sticky td.fp-table-sticky-last::after
{
    content: none !important;
    display: none !important;
}

/*
 * Scroll area too short (JS .fp-table-no-sticky-y) - disable all stickiness
 * so headers do not eat the tiny viewport.
 */
.fp-table-root.fp-table-no-sticky-y thead tr.fp-table-column-row th.fp-table-head,
.fp-table-root.fp-table-no-sticky-y thead tr.fp-table-column-row th.fp-table-sticky,
.fp-table-root.fp-table-no-sticky-y thead tr.fp-table-group-row th.fp-table-sticky,
.fp-table-root.fp-table-no-sticky-y th.fp-table-sticky,
.fp-table-root.fp-table-no-sticky-y td.fp-table-sticky
{
    position: static !important;
    top: auto !important;
    left: auto !important;
    z-index: auto !important;
}

/*
 * Sort icons are position:absolute. When Y-sticky is disabled, headers become
 * static above - keep sortable column headers as relative so arrows stay in-cell
 * instead of anchoring to the scroll/table edge.
 */
.fp-table-root.fp-table-no-sticky-y thead tr.fp-table-column-row th.fp-table-sortable.fp-table-head
{
    position: relative !important;
}

.fp-table-root.fp-table-no-sticky-y th.fp-table-sticky::before,
.fp-table-root.fp-table-no-sticky-y td.fp-table-sticky::before,
.fp-table-root.fp-table-no-sticky-y th.fp-table-sticky-last::after,
.fp-table-root.fp-table-no-sticky-y td.fp-table-sticky-last::after
{
    content: none !important;
    display: none !important;
}

.fp-table th.fp-table-sortable
{
    cursor: pointer;
    user-select: none;
    /* Containing block for .fp-table-sort-icon (sticky headers also qualify). */
    position: relative;
}

.fp-table thead th.fp-table-sortable.fp-table-head
{
    padding-right: 1.35rem;
}

.fp-table th.fp-table-sortable:hover
{
    background-color: var(--fp-table-header-hover-bg) !important;
}

.fp-table thead tr.fp-table-column-row th.fp-table-sortable.fp-table-sticky:hover,
.fp-table thead tr.fp-table-column-row th.fp-table-sortable.fp-table-sticky:hover::before
{
    background-color: var(--fp-table-header-hover-bg) !important;
}

/* MDB Datatable-style sort arrow (right side, rotates on desc) */
.fp-table-sort-icon
{
    position: absolute;
    right: 0.35rem;
    left: auto;
    top: 50%;
    margin-top: -0.5rem;
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0;
    color: var(--fp-table-sort-icon-color);
    pointer-events: none;
    transition: opacity 0.2s linear, transform 0.3s linear, color 0.2s linear;
    transform: rotate(0deg);
}

.fp-table-sort-icon.fp-table-sort-active
{
    opacity: 1;
    color: var(--fp-table-sort-icon-active);
}

.fp-table-sort-icon.fp-table-sort-desc
{
    transform: rotate(180deg);
}

.fp-table th.fp-table-sortable:hover .fp-table-sort-icon
{
    opacity: 0.45;
}

.fp-table th.fp-table-sortable:hover .fp-table-sort-icon.fp-table-sort-active
{
    opacity: 1;
}

.fp-table-empty
{
    text-align: center;
    color: #6c757d;
    padding: 1.5rem 1rem !important;
    white-space: normal;
}

/* MDB-like pagination footer */
.fp-table-footer.datatable-pagination
{
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 0;
    border-top: none;
    margin-top: 0.25rem;
}

.fp-table-footer .datatable-pagination-nav
{
    flex: 0 1 auto;
    min-width: 0;
    padding: 0;
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.6);
    white-space: nowrap;
}

.fp-table-footer-end
{
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    margin-left: auto;
    gap: 0.25rem;
}

.fp-table-footer .datatable-select-wrapper
{
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 400;
    padding: 0 0.5rem 0 0;
    gap: 0.5rem;
}

.fp-table-footer .datatable-select-text
{
    margin: 0;
    white-space: nowrap;
}

.fp-table-footer .fp-table-page-size
{
    width: auto;
    min-width: 4.5rem;
    display: inline-block;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* MDB Select chrome for rows-per-page */
.fp-table-footer .datatable-select-wrapper .select-wrapper
{
    min-width: 4.75rem;
    width: 4.75rem;
    margin-top: 0;
    margin-bottom: 0;
}

.fp-table-footer .datatable-select-wrapper .select-input
{
    min-height: 1.75rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    font-size: 0.875rem;
}

.fp-table-footer .datatable-pagination-buttons
{
    display: flex;
    align-items: center;
}

.fp-table-footer .datatable-pagination-button
{
    padding-left: 1rem;
    padding-right: 1rem;
    color: rgba(0, 0, 0, 0.6);
}

.fp-table-footer .datatable-pagination-button:hover:not(:disabled)
{
    color: rgba(0, 0, 0, 0.9);
}

.fp-table-footer .datatable-pagination-button:disabled
{
    color: #757575;
    opacity: 0.65;
}

/* Selected row (radio / click selection) - cover sticky seam overlays too */
.fp-table tbody tr.is-selected td,
.fp-table tbody tr.is-selected td.fp-table-sticky::before
{
    background-color: rgba(18, 102, 241, 0.12) !important;
}

.fp-table tbody tr.is-selected td.fp-table-sticky-last::after
{
    opacity: 0.35;
}

.fp-table-root.fp-table-selectable .fp-table tbody tr
{
    cursor: pointer;
}

/*
 * MDB checkboxes inside scrolling tables: checkmark is ::after on the input,
 * so the input must stay position:relative (scrolls with the cell). ::before
 * is only the ripple halo - suppress it in dense table layouts.
 */
.fp-table .form-check-input
{
    float: none;
    position: relative;
    margin: 0;
    overflow: visible;
}

.fp-table .form-check-input::before
{
    content: none !important;
    display: none !important;
    box-shadow: none !important;
}
