/* ==========================================================================
   Activity log: layout only. Filter bar, table, chips, buttons, fields, pager and the drawer come from components/ui.css and
   Web Awesome. The table is an HTMX fragment (audit/log_table.html); the drawer is filled by Alpine (audit/log_view.html).
   ========================================================================== */
@layer app-pages {

    /* The loading note sits cleanly above the table instead of overlapping thead */
    .audit-results { position: relative; }
    #audit-loading { position: static; padding: 0.625rem 1rem; border-bottom: 1px solid var(--d26-line); background: var(--d26-surface); width: 100%; }
    #auditFilterForm { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    #auditFilterForm .ui-filter-wide { grid-column: auto; }
    .audit-filter-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.5rem; }
    @media (max-width: 1024px) {
        #auditFilterForm { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (max-width: 600px) {
        #auditFilterForm { grid-template-columns: minmax(0, 1fr); }
    }

    /* ---- Table ---- */
    .audit-table td { vertical-align: top; }
    .audit-row { cursor: pointer; }
    .audit-mono, .audit-code { font-family: var(--font-mono, ui-monospace, monospace); }
    .audit-code { padding: 0.125rem 0.4rem; background: var(--d26-draft-bg); border-radius: 4px; font-size: 0.75rem; color: var(--d26-ink); }
    .audit-ico { color: var(--d26-ink-2); }
    .audit-table .ui-chip + .ui-problem, .audit-table .ui-chip + .ui-sub { margin-top: 0.25rem; }
    .audit-note { max-width: 17.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8125rem; }

    /* Old and new values: a mono box. The column title (and, in the drawer, the word Before / After) says which is which. */
    .audit-val { display: inline-block; padding: 0.125rem 0.4rem; border-radius: 4px; font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.75rem; overflow-wrap: anywhere; }
    .audit-val--old { background: var(--d26-bad-bg); color: var(--d26-bad-fg); }
    .audit-val--new { background: var(--d26-ok-bg); color: var(--d26-ok-fg); }
    .audit-val--block { display: block; padding: 0.75rem; border-radius: var(--d26-radius-control); font-size: 0.8125rem; }

    /* Footer: range, page size, pager */
    .audit-foot { gap: 0.75rem 1.5rem; }
    .audit-range { color: var(--d26-ink-2); font-size: 0.875rem; }

    /* The card switch (under 55rem of table box) is the shared data_table(cards="wide"); these are this table's extras. */
    @container (width <= 55rem) { .audit-note { max-width: none; white-space: normal; } }
    @container (width > 55rem) {                                                    /* wide table: keep the Inspect button in view while it scrolls sideways */
        .ui-table--cards-wide th.audit-col-act, .ui-table--cards-wide td.audit-col-act { position: sticky; right: 0; box-shadow: -1px 0 0 var(--d26-line); }
        .ui-table--cards-wide td.audit-col-act { background: var(--d26-card); }
        .ui-table--cards-wide th.audit-col-act { background: var(--d26-surface); }
        .ui-table--cards-wide tbody tr:hover td.audit-col-act { background: var(--d26-surface); }
    }

    /* ---- Drawer ---- */
    .audit-drawer-title { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
    .audit-drawer-body { display: flex; flex-direction: column; gap: 1rem; font-size: 0.875rem; }
    .audit-section { padding: 0.875rem; background: #fff; border: 1px solid var(--d26-line); border-radius: var(--d26-radius-card); }
    .audit-section:first-child { background: var(--d26-surface); }
    .audit-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
    .audit-key { font-size: 0.75rem; font-weight: 600; color: var(--d26-ink-2); }
    .audit-strong { font-weight: 700; color: var(--d26-ink); }
    .audit-upper { text-transform: uppercase; }
    .audit-heading { display: flex; align-items: center; gap: 0.375rem; margin: 0 0 0.5rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--d26-ink-2); }
    .audit-heading--split { justify-content: space-between; }
    .audit-actor { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
    .audit-claim { margin-top: 0.5rem; padding: 0.75rem; background: var(--d26-surface); border-radius: var(--d26-radius-control); }
    .audit-claim .audit-grid2 { margin-top: 0.375rem; font-size: 0.8125rem; color: var(--d26-ink-2); }
    .audit-remarks { margin: 0; padding: 0.625rem 0.875rem; background: var(--d26-surface); border-left: 3px solid var(--d26-accent); border-radius: 4px; font-style: italic; }
    .audit-raw { margin: 0.5rem 0 0; padding: 0.75rem; max-height: 14rem; overflow: auto; background: #0f172a; color: #e2e8f0; border-radius: 4px; font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.75rem; }
    .audit-ledger { margin: 0 auto 0 0; }
}
