/* tokens */
:root {
    --aa-surface: #ffffff;          /* opaque sticky-cell background (rows must not bleed through) */
    --aa-surface-alt: #f8f9fa;      /* zebra-stripe alt / sticky-header tint */
    --aa-border: #dee2e6;
    --aa-table-cell-y: 0.3rem;      /* compact vertical cell padding */
    --aa-table-cell-x: 0.5rem;
    --aa-table-font: 0.85rem;       /* data-dense step-down */
    --aa-table-max-h: 70vh;         /* sticky needs a bounded scroll container */
}

/* navbar */
.navbar {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.navbar .dropdown-menu {
    font-size: 0.9rem;
}

/* cards */
.card {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.filter-card .card-header {
    background: var(--aa-surface-alt);
}

/* compact tables — .data-table-wrap is the lighter CRUD variant (no sticky
   first column; everything else shared) */
.report-table-wrap table.table,
.data-table-wrap table.table {
    font-size: var(--aa-table-font);
    margin-bottom: 0;
}
.report-table-wrap table.table > :not(caption) > * > *,
.data-table-wrap table.table > :not(caption) > * > * {
    padding: var(--aa-table-cell-y) var(--aa-table-cell-x);
}
.report-table-wrap table.table th,
.data-table-wrap table.table th {
    white-space: nowrap;
}

/* table scroll container — sticky needs a bounded-height scroll parent */
.report-table-wrap,
.data-table-wrap {
    max-height: var(--aa-table-max-h);
    overflow: auto;
    border: 1px solid var(--aa-border);
    border-radius: 0.375rem;
    position: relative;
    /* horizontal scroll shadows (left/right edge cues) */
    background:
        linear-gradient(to right, var(--aa-surface) 30%, rgba(255, 255, 255, 0)) left center,
        linear-gradient(to left, var(--aa-surface) 30%, rgba(255, 255, 255, 0)) right center,
        radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) left center,
        radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) right center;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}
.report-table-wrap thead th,
.data-table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--aa-surface-alt);
    box-shadow: inset 0 -1px 0 var(--aa-border);
}
/* sticky first column (group label) — report tables only */
.report-table-wrap th:first-child,
.report-table-wrap td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--aa-surface);
}
.report-table-wrap tbody tr:nth-of-type(odd) td:first-child {
    /* Bootstrap's striped overlay is rgba(0,0,0,.05) over the surface; the
       sticky cell needs the same shade but OPAQUE (rows must not bleed). */
    background: #f2f2f2;
}
.report-table-wrap thead th:first-child {
    z-index: 3;
}

/* searchable multiselect */
.aa-multiselect {
    position: relative;
}
.aa-multiselect .aa-ms-toggle {
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.aa-multiselect .aa-ms-panel {
    max-height: 16rem;
    overflow-y: auto;
    min-width: 14rem;
    /* right-edge clamp — never wider than the viewport allows */
    max-width: min(24rem, calc(100vw - 2rem));
    padding: 0.25rem;
}
.aa-multiselect .aa-ms-search {
    margin-bottom: 0.25rem;
}
.aa-multiselect .aa-ms-option {
    display: block;
    padding: 0.15rem 0.4rem;
    cursor: pointer;
    white-space: nowrap;
}
.aa-multiselect .aa-ms-option:hover {
    background: var(--aa-surface-alt);
}
.aa-multiselect .aa-ms-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.25rem;
}
.aa-ms-chip {
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.aa-ms-empty {
    color: #6c757d;
    font-size: 0.8rem;
    padding: 0.4rem;
}

/* filter card + chips */
.filter-card .filter-toggle {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.filter-card .filter-toggle .chevron {
    transition: transform 0.15s ease-in-out;
}
.filter-card .filter-toggle[aria-expanded="true"] .chevron {
    transform: rotate(90deg);
}
.filter-card fieldset.filter-group {
    border: 1px solid var(--aa-border);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem 0.75rem;
    margin-bottom: 0.75rem;
}
.filter-card fieldset.filter-group > legend {
    float: none;
    width: auto;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
    padding: 0 0.4rem;
    margin-bottom: 0;
}
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
/* template-level invalid marker — Bootstrap-red border on the offending input */
.field-invalid .form-control,
.field-invalid .form-select {
    border-color: #dc3545;
}
.filter-chip {
    font-size: 0.78rem;
    font-weight: normal;
}

/* pagination */
.aa-pagination .page-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.aa-pagination-chevron {
    width: 1em;
    height: 1em;
}

/* home dashboard, login */
.home-card {
    height: 100%;
    transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
}
.home-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.login-card {
    max-width: 26rem;
    margin: 3rem auto 0;
}
/* AuthenticationForm fields carry no widget class — style them as form-control */
.login-card input[type="text"],
.login-card input[type="password"] {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}

/* print — flatten the scroll containers, drop the chrome */
@media print {
    .report-table-wrap,
    .data-table-wrap {
        max-height: none;
        overflow: visible;
        border: none;
        background: none;
    }
    .report-table-wrap thead th,
    .data-table-wrap thead th,
    .report-table-wrap th:first-child,
    .report-table-wrap td:first-child {
        position: static;
    }
    .navbar,
    .filter-card,
    .aa-pagination,
    .btn,
    form {
        display: none !important;
    }
}
