/* ==========================================================================
   Lists (Panel overhaul, 2026-09): the data tables in the AAB style.

   Desktop: a calm table. Links read as text until hovered, so a row is not a
   wall of accent colour; the accent stays for what is selected or acts.

   Below 768px: every table.data-table becomes a stack of cards, one per row.
   js/table-cards.js labels the cells (data-label, data-card); this sheet lays
   them out: title and row actions on top, then "label  value" lines. Sortable
   headers stay usable as a row of chips above the cards. A table marked
   .data-table--scroll keeps scrolling sideways instead.

   Everything is scoped under .pnl-content table.data-table so it outranks the
   old theme's .table-responsive stacking rules and app.css's scroll floors.
   ========================================================================== */

/* --- Desktop table ---------------------------------------------------------- */
.pnl-content table.data-table {
    background: var(--aab-surface);
    border: 1px solid var(--aab-line);
    border-radius: var(--aab-radius-md);
    font-size: var(--aab-fs-body);
}

.pnl-content table.data-table th {
    padding: var(--aab-space-3) var(--aab-space-4);
    background: transparent;
    border-bottom: 1px solid var(--aab-line);
    color: var(--aab-text-2);
    font-size: var(--aab-fs-small);
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    /* A two-word header ("Laatste bezoek") may wrap when the table is tight, instead of
       holding its column wide enough to push Actie off a laptop screen (2026-10-08). A table
       that fits does not change; phones and --wide tables keep their own nowrap rules. */
    white-space: normal;
}

.pnl-content table.data-table td {
    padding: var(--aab-space-3) var(--aab-space-4);
    border-bottom: 1px solid var(--aab-line);
    color: var(--aab-text);
    vertical-align: middle;
}

.pnl-content table.data-table tbody tr:nth-child(even) {
    background: transparent;
}

.pnl-content table.data-table tbody tr:hover {
    background: var(--aab-surface-2);
}

.pnl-content table.data-table tbody tr:last-child td {
    border-bottom: none;
}

.pnl-content table.data-table td a:not(.action-btn):not(.btn) {
    color: inherit;
    text-decoration: none;
}

.pnl-content table.data-table td a:not(.action-btn):not(.btn):hover {
    color: var(--aab-accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.pnl-content table.data-table th.sorted,
.pnl-content table.data-table th.sorted .sort-icon {
    color: var(--aab-accent-text);
}

.pnl-content table.data-table tr.row-selected td {
    background: var(--aab-accent-soft);
}

/* Row actions: quiet icon buttons that only show a fill on hover. */
.pnl-content .action-btn {
    width: var(--aab-target);
    height: var(--aab-target);
    border: none;
    border-radius: var(--aab-radius-sm);
    background: transparent;
    color: var(--aab-text-2);
    font-size: 1rem;
}

.pnl-content .action-btn:hover {
    background: var(--aab-surface-2);
    color: var(--aab-text);
}

.pnl-content .action-btn:focus-visible {
    outline: 3px solid var(--aab-accent);
    outline-offset: 1px;
}

/* --- Phone: rows become cards ------------------------------------------------- */
@media (max-width: 767.98px) {
    .pnl-content .table-responsive[data-cards] {
        overflow: visible;
    }

    .pnl-content table.data-table[data-cards] {
        display: block;
        min-width: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        overflow: visible;
    }

    /* Sort chips: the sortable headers as a scrollable row; the rest of the header goes. */
    .pnl-content table.data-table[data-cards] > thead {
        display: none;
    }

    .pnl-content table.data-table[data-cards][data-cards-sortable] > thead {
        display: block;
        margin: 0 calc(-1 * var(--aab-gutter)) var(--aab-space-3);
    }

    .pnl-content table.data-table[data-cards] > thead > tr {
        display: flex;
        gap: var(--aab-space-2);
        padding: 0 var(--aab-gutter) var(--aab-space-1);
        overflow-x: auto;
        scrollbar-width: none;
    }

    .pnl-content table.data-table[data-cards] > thead th {
        display: none;
    }

    .pnl-content table.data-table[data-cards] > thead th.sortable {
        display: inline-flex;
        align-items: center;
        gap: var(--aab-space-1);
        flex: 0 0 auto;
        min-height: var(--aab-chip);
        padding: 0 var(--aab-space-4);
        border: 1px solid var(--aab-line-strong);
        border-radius: var(--aab-radius-pill);
        background: var(--aab-surface);
        color: var(--aab-text);
        font-size: var(--aab-fs-small);
    }

    .pnl-content table.data-table[data-cards] > thead th.sortable.sorted {
        border-color: transparent;
        background: var(--aab-accent-soft);
        color: var(--aab-accent-text);
    }

    .pnl-content table.data-table[data-cards] > tbody {
        display: flex;
        flex-direction: column;
        gap: var(--aab-space-3);
    }

    /* The card: [check] [title] [actions] on top, label/value lines below. */
    .pnl-content table.data-table[data-cards] > tbody > tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        column-gap: 0;            /* the check and actions cells carry their own spacing, so a */
        row-gap: var(--aab-space-2); /* card without a checkbox does not indent its title */
        padding: var(--aab-space-4);
        background: var(--aab-surface);
        border: 1px solid var(--aab-line);
        border-radius: var(--aab-radius-md);
    }

    .pnl-content table.data-table[data-cards] > tbody > tr:hover {
        background: var(--aab-surface);
    }

    .pnl-content table.data-table[data-cards] > tbody > tr.row-selected {
        border-color: var(--aab-accent);
        background: var(--aab-accent-soft);
    }

    /* A line of the card: the label sits in the left gutter, the value flows inline beside it,
       so a value made of text plus a pill (Opdracht + Ongepland) stays on its own line. */
    .pnl-content table.data-table[data-cards] > tbody > tr > td {
        grid-column: 1 / -1;
        position: relative;
        display: block;
        min-height: 1.4em;
        max-width: none;
        padding: 0 0 0 calc(36% + var(--aab-space-3));
        border: none;
        background: transparent;
        font-size: var(--aab-fs-small);
        line-height: var(--aab-leading);
        white-space: normal;
        overflow: visible;
        overflow-wrap: anywhere;
        text-overflow: clip;
    }

    .pnl-content table.data-table[data-cards] > tbody > tr > td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: 0;
        width: 36%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: var(--aab-text-2);
        font-size: var(--aab-fs-small);
        font-weight: 400;
        text-transform: none;
        letter-spacing: 0;
    }

    .pnl-content table.data-table[data-cards] > tbody > tr > td .badge,
    .pnl-content table.data-table[data-cards] > tbody > tr > td .status-badge {
        display: inline-flex;
        width: auto;
        vertical-align: baseline;
    }

    /* A value truncated to one line on a wide screen (.cell-truncate, e.g. the audit log's
       action code) wraps inside the card instead: an inline element ignores max-width and
       overflow, so with nowrap it ran out of the card and the page (#172). */
    .pnl-content table.data-table[data-cards] > tbody > tr > td .cell-truncate {
        max-width: none;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    /* A cell without a header name spans the card instead of leaving a blank label. */
    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-label=""],
    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-card] {
        padding-left: 0;
    }

    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-label=""]::before,
    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-card]::before {
        content: none;
    }

    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-card="title"] {
        grid-column: 2;
        grid-row: 1;
        display: block;
        font-size: var(--aab-fs-body);
        font-weight: 700;
        line-height: var(--aab-leading-tight);
    }

    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-card="check"] {
        grid-column: 1;
        grid-row: 1;
        display: flex;
        padding-right: var(--aab-space-3);
    }

    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-card="check"] input {
        width: 22px;
        height: 22px;
    }

    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-card="actions"] {
        grid-column: 3;
        grid-row: 1;
        display: flex;
        justify-content: flex-end;
        gap: var(--aab-space-1);
        padding-left: var(--aab-space-3);
        white-space: nowrap;
    }

    .pnl-content table.data-table[data-cards] > tbody > tr > td[data-card="empty"],
    .pnl-content table.data-table[data-cards] > tbody > tr > td.cell-hide-phone {
        display: none;
    }

    /* Empty states and expanded detail rows: one full-width block. */
    .pnl-content table.data-table[data-cards] > tbody > tr[data-card="full"] {
        display: block;
    }

    .pnl-content table.data-table[data-cards] > tbody > tr[data-card="full"] > td {
        display: block;
    }

    .pnl-content table.data-table[data-cards] > tbody > tr[data-card="full"] > td::before {
        content: none;
    }
}
