/* Audit log: screens 4g "Journal d’audit" and 2f "Mon activité" (templates/portal/audit), after docs/wireframes. */

.audit { width: 100%; max-width: 1100px; padding: 24px 32px 40px; display: flex; flex-direction: column; gap: 16px; }
.audit--narrow { max-width: 880px; }
.audit-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.audit-head .page-intro { flex: 1 1 400px; }

/* Filters: drop-down buttons whose choices are links. */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter { position: relative; }
.filter summary { list-style: none; cursor: pointer; }
.filter summary::-webkit-details-marker { display: none; }
.filter-button {
    min-height: 44px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); font-size: 14px; display: flex; align-items: center; gap: 6px;
}
.filter-button:hover { background: var(--bg); }
.filter-name { color: var(--text-muted); }
.filter[open] .filter-button .icon { transform: rotate(180deg); }
.filter-menu {
    position: absolute; left: 0; top: calc(100% + 4px); z-index: 10; min-width: 220px; max-height: 320px; overflow-y: auto;
    padding: 6px; display: flex; flex-direction: column; gap: 2px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.filter-menu--end { left: auto; right: 0; min-width: 280px; }
.filter-menu a {
    min-height: 40px; padding: 0 10px; border-radius: var(--radius); display: flex; align-items: center;
    font-size: 14px; color: var(--text); text-decoration: none; white-space: nowrap;
}
.filter-menu a:hover { background: var(--bg); }
.filter-menu a[aria-current="true"] { background: var(--selected); font-weight: 600; }
.filter-menu-note { margin: 4px 10px 6px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.audit-export-button {
    min-height: 44px; padding: 0 16px; border-radius: 10px; background: var(--text); color: var(--text-inverse);
    font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.audit-export-button:hover { background: var(--primary-hover); }

/* The table, and the detail beside it. */
.audit-columns { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.audit-table { flex: 999 1 560px; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 20px; }
.audit-scroll { overflow-x: auto; }
.audit-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.audit-table th {
    padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-muted);
}
.audit-table td { padding: 12px; vertical-align: top; }
.audit-table th:first-child, .audit-table td:first-child { padding-left: 0; }
.audit-table th:last-child, .audit-table td:last-child { padding-right: 0; }
.audit-table tbody tr { border-top: 1px solid var(--divider); }
.audit-table tbody tr.is-selected { background: var(--selected); }
.audit-time { white-space: nowrap; color: var(--text-soft); }
.audit-date { display: block; font-size: 12px; color: var(--text-muted); }
.audit-person { white-space: nowrap; }
/* On a narrow screen, the table scrolls inside its card rather than squeezing the events. */
.audit-event { display: flex; flex-direction: column; gap: 2px; min-width: 220px; }
.audit-label { font-weight: 600; color: var(--text); }
a.audit-label { text-decoration: none; }
a.audit-label:hover { text-decoration: underline; }
.audit-detail { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.audit-table .audit-result { text-align: right; white-space: nowrap; }
.audit-empty { margin: 0; padding: 16px 0; color: var(--text-soft); }
/* The whole row opens the detail. */
.audit-columns tbody tr { position: relative; }
.audit-columns tbody tr:hover { background: var(--bg); }
.audit-columns tbody tr.is-selected:hover { background: var(--selected); }
.audit-columns a.audit-label::after { content: ""; position: absolute; inset: 0; }

.outcome {
    display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: 999px;
    border: 1px solid var(--border-strong); font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--text);
}
.outcome--ok { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }
.outcome--no { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.outcome--wait { border: 1px dashed var(--text-muted); }
.outcome--neutral { border-color: var(--border); color: var(--text-soft); }

.audit-panel {
    flex: 1 1 300px; min-width: 0; background: var(--surface); border: 2px solid var(--text); border-radius: 12px;
    padding: 20px; display: flex; flex-direction: column; gap: 4px;
}
.audit-panel h2 { margin: 4px 0 8px; font-size: 17px; }
.audit-panel .audit-panel-kicker, .audit-panel-kicker {
    margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
}
.audit-panel-hint { margin: 4px 0; font-size: 14px; color: var(--text-soft); line-height: 1.5; }
.audit-rows { margin: 0; display: flex; flex-direction: column; }
.audit-rows div { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--divider); font-size: 14px; }
.audit-rows dt { color: var(--text-muted); }
/* A short value sits on the right of its label; a long one goes under it, read from the left. */
.audit-rows dd { margin: 0 0 0 auto; font-weight: 500; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.audit-rows .audit-hash { flex-basis: 100%; text-align: left; font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 400; color: var(--text-soft); }
.audit-panel-close { align-self: flex-start; margin-top: 8px; font-size: 13px; }
.audit-panel-note { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-muted); }

@media (min-width: 821px) {
    /* The detail stays in view along a long log. */
    .audit-panel { position: sticky; top: 16px; }
}
@media (max-width: 820px) {
    .audit { padding: 16px; }
    .filter-menu--end { left: 0; right: auto; }
}
