/* Published verbatim via FilamentAsset (no Tailwind pipeline), so plain CSS only.
   Scoped under .collapsible-rows-table / .has-group-hierarchy so other Filament tables never change. */

/* Chevron buttons: collapsed state is the expand icon rotated, there is no separate collapse icon. */
.collapsible-rows-table .collapsible-chevron-btn .fi-icon {
    width: 14px;
    height: 14px;
    transform: rotate(-90deg);
    transition: transform 150ms ease;
}

.collapsible-rows-table .collapsible-chevron-btn.expanded .fi-icon {
    transform: rotate(0deg);
}

/* Every record row is its own tbody (not just hierarchy tables), so the generic 4px
   tbody spacer becomes a blank line between every row, breaking stripe/accent
   continuity. Keep it only under the header (first tbody), drop it between rows. */
.collapsible-rows-table .fi-ta-table > tbody + tbody::before {
    content: none;
    display: none;
}

/* Folder bar rows. */
.collapsible-rows-table.has-group-hierarchy tr.group-hierarchy-row > td {
    background-color: #fff;
}

.collapsible-rows-table.has-group-hierarchy tr.group-hierarchy-row > td.group-hierarchy-cell {
    padding: 0;
}

.collapsible-rows-table.has-group-hierarchy .group-hierarchy-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    background-color: transparent;
    padding: 0.5rem 0.75rem;
    margin-inline-start: calc(var(--hierarchy-depth, 0) * 1.5rem);
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 600;
    color: oklch(0.13 0.028 261.692);
}

/* Mobile: the 44px chevron tap box already carries lead space; the bar's own padding doubles it. */
@media (width < 64rem) {
    .collapsible-rows-table.has-group-hierarchy .group-hierarchy-bar {
        padding-inline-start: 0;
    }
}

.collapsible-rows-table.has-group-hierarchy .group-hierarchy-bar[data-hierarchy-depth]:not([data-hierarchy-depth='0']) {
    font-weight: 500;
}

.collapsible-rows-table.has-group-hierarchy .group-hierarchy-bar .group-hierarchy-icon {
    flex-shrink: 0;
    color: oklch(0.556 0 0);
}

.collapsible-rows-table.has-group-hierarchy .group-hierarchy-bar .group-hierarchy-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collapsible-rows-table.has-group-hierarchy .group-hierarchy-bar .group-hierarchy-count {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    font-weight: 400;
    color: oklch(0.439 0 0);
}

/* Inline fallback used by tables without a dedicated collapsible column. */
.collapsible-rows-table.has-group-hierarchy tbody .group-hierarchy-inline-chevron-btn {
    margin-inline-start: 0;
}

/* A group-collapsed record only hides its rows; hide the wrapping tbody too,
   or its spacer/borders keep an empty band visible. */
.collapsible-rows-table.has-group-hierarchy tbody:has(> tr.fi-ta-row.fi-collapsed) {
    display: none;
}

/* Indent the group header under its hierarchy bars. */
.collapsible-rows-table.has-group-hierarchy tr.fi-ta-group-header-row .fi-ta-group-header {
    margin-inline-start: calc(var(--group-depth, 0) * 1.5rem);
    padding-inline-start: 0.75rem;
}

.collapsible-rows-table.has-group-hierarchy tr.fi-ta-group-header-row .fi-ta-group-header > div:first-child {
    min-width: 0;
}

.collapsible-rows-table.has-group-hierarchy tr.fi-ta-group-header-row .fi-ta-group-header > .group-hierarchy-chevron-btn {
    flex-shrink: 0;
}

.collapsible-rows-table.has-group-hierarchy tr.fi-ta-group-header-row > td {
    background-color: #fff;
}

/* Alternate visible hierarchy rows. Alpine recalculates the fi-striped class
   after expanding/collapsing so hidden descendants never affect the pattern. */
.collapsible-rows-table.has-group-hierarchy tr.fi-ta-row.fi-striped:is(.group-hierarchy-row, .fi-ta-group-header-row) > td {
    background-color: oklch(0.97 0 0);
}

/* Record rows follow the complete folder/group hierarchy. Only for grouped tables.
   translateX (not padding) so the column widths never reflow. */
.collapsible-rows-table.has-group-hierarchy .fi-ta-table:has(.fi-ta-group-header-row) tr.fi-ta-row:not(.fi-ta-group-header-row) {
    --record-group-indent: calc(2.25rem + var(--group-depth, 0) * 1.5rem);
}

.collapsible-rows-table.has-group-hierarchy .fi-ta-table:has(.fi-ta-group-header-row) tr.fi-ta-row:not(.fi-ta-group-header-row) > td.fi-ta-selection-cell > *,
.collapsible-rows-table.has-group-hierarchy .fi-ta-table:has(.fi-ta-group-header-row) tr.fi-ta-row:not(.fi-ta-group-header-row) > td.fi-ta-selection-cell + td > * {
    transform: translateX(var(--record-group-indent));
}

/* Event row targeted from the PDF tool. border-collapse clips box-shadow on cells, so the edges are background layers. */
.collapsible-rows-table tr.highlighted-row > td {
    --highlight-accent: var(--theme-primary, #f54a00);

    background-color: color-mix(in srgb, var(--highlight-accent) 8%, transparent);
    background-image:
        linear-gradient(var(--highlight-accent), var(--highlight-accent)),
        linear-gradient(var(--highlight-accent), var(--highlight-accent));
    background-repeat: no-repeat;
    background-size: 100% 1px;
    background-position: top left, bottom left;
}

.collapsible-rows-table tr.highlighted-row > td:first-child {
    border-start-start-radius: 0.5rem;
    border-end-start-radius: 0.5rem;
    background-image:
        linear-gradient(var(--highlight-accent), var(--highlight-accent)),
        linear-gradient(var(--highlight-accent), var(--highlight-accent)),
        linear-gradient(var(--highlight-accent), var(--highlight-accent));
    background-size: 100% 1px, 100% 1px, 1px 100%;
    background-position: top left, bottom left, top left;
}

.collapsible-rows-table tr.highlighted-row > td:last-child {
    border-start-end-radius: 0.5rem;
    border-end-end-radius: 0.5rem;
    background-image:
        linear-gradient(var(--highlight-accent), var(--highlight-accent)),
        linear-gradient(var(--highlight-accent), var(--highlight-accent)),
        linear-gradient(var(--highlight-accent), var(--highlight-accent));
    background-size: 100% 1px, 100% 1px, 1px 100%;
    background-position: top left, bottom left, top right;
}

/* The themed row separator draws a grey line over the top edge of the first cell, breaking the outline. */
.collapsible-rows-table .collapsible-sub-table tr.highlighted-row > td:first-child::before {
    left: 0;
    background-color: var(--highlight-accent);
}

/* The themed hover rule repaints the whole row, so the tint has to be restated for the hovered state. */
.collapsible-rows-table .collapsible-sub-table tr.highlighted-row:hover > td {
    background-color: color-mix(in srgb, var(--highlight-accent) 8%, transparent);
}

/* Dark mode. */
.dark .collapsible-rows-table.has-group-hierarchy tr.group-hierarchy-row > td,
.dark .collapsible-rows-table.has-group-hierarchy tr.fi-ta-group-header-row > td {
    background-color: transparent;
}

.dark .collapsible-rows-table.has-group-hierarchy .group-hierarchy-bar {
    color: #fff;
}

.dark .collapsible-rows-table.has-group-hierarchy .group-hierarchy-bar .group-hierarchy-icon {
    color: oklch(0.708 0 0);
}

.dark .collapsible-rows-table.has-group-hierarchy tr.fi-ta-row.fi-striped:is(.group-hierarchy-row, .fi-ta-group-header-row) > td {
    background-color: rgb(255 255 255 / 0.1);
}

.dark .collapsible-rows-table tr.highlighted-row > td,
.dark .collapsible-rows-table .collapsible-sub-table tr.highlighted-row:hover > td {
    background-color: color-mix(in srgb, var(--highlight-accent) 15%, transparent);
}

/* Nested rows: the toggle sits in the gutter so opening a folder leaves the name column in place.
   A consumer sets the offset to line the toggle up with its own hierarchy chevrons. */
.collapsible-sub-table .collapsible-child-toggle {
    position: absolute;
    inset-inline-start: var(--collapsible-child-toggle-offset, 0);
}

.collapsible-sub-table .collapsible-child-indent {
    width: var(--collapsible-child-indent, 1.5rem);
}

/* Striped sub-table rows. Alpine recalculates the class after expanding a nested row,
   so hidden children never shift the pattern. */
.collapsible-sub-table tbody tr.fi-striped > td {
    background-color: oklch(0.97 0 0);
}

.dark .collapsible-sub-table tbody tr.fi-striped > td {
    background-color: rgb(255 255 255 / 0.1);
}
