/* MFSA FIRB Institutions compatibility layer — Phase 3. */

.mfsa-firb {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    color: var(--mfsa-ui-text);
}

.mfsa-firb .mfsa-firb-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    margin: 12px 0;
    padding: 8px;
    box-sizing: border-box;
    color: var(--mfsa-ui-text);
    background: var(--mfsa-ui-surface-subtle);
    border: 1px solid var(--mfsa-ui-border-light);
    border-radius: var(--mfsa-ui-radius);
}

.mfsa-firb .mfsa-firb-toolbar > * {
    min-width: 0;
    max-width: 100%;
}

.mfsa-firb .mfsa-firb-count {
    flex: 0 1 auto;
}

.mfsa-firb .mfsa-firb-search {
    flex: 1 1 220px;
    width: auto;
}

.mfsa-firb .mfsa-firb-sort {
    flex: 1 1 260px;
    width: auto;
}

.mfsa-firb .mfsa-firb-controls {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.25fr) repeat(3, minmax(106px, 124px));
    flex: 1 1 auto;
    align-items: stretch;
    justify-content: flex-start;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.mfsa-firb .mfsa-firb-controls > label {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.mfsa-firb .mfsa-firb-count {
    color: var(--mfsa-ui-text-muted);
}

.mfsa-firb .mfsa-firb-search,
.mfsa-firb .mfsa-firb-sort,
.mfsa-firb .mfsa-firb-page-size {
    min-height: var(--mfsa-ui-control-height);
    margin: 0;
    width: 100% !important;
    max-width: 100%;
    min-width: 0 !important;
    padding: 8px;
    box-sizing: border-box;
    color: var(--mfsa-ui-text);
    background: var(--mfsa-ui-surface);
    border: 1px solid var(--mfsa-ui-border);
    border-radius: var(--mfsa-ui-radius);
    box-shadow: none;
    font: inherit;
}

.mfsa-firb .mfsa-firb-search::placeholder {
    color: #6b7280;
    opacity: 1;
}

.mfsa-firb .mfsa-firb-button,
.mfsa-firb .mfsa-firb-pages button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--mfsa-ui-control-height);
    margin: 0;
    padding: 8px 12px;
    box-sizing: border-box;
    color: var(--mfsa-ui-teal-dark) !important;
    background: var(--mfsa-ui-surface);
    border: 1px solid var(--mfsa-ui-teal);
    border-radius: var(--mfsa-ui-radius);
    box-shadow: none;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
}

.mfsa-firb .mfsa-firb-toolbar .mfsa-firb-button {
    flex: 0 1 auto !important;
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
    padding-inline: 10px;
}

.mfsa-firb .mfsa-firb-button:hover,
.mfsa-firb .mfsa-firb-button:focus-visible,
.mfsa-firb .mfsa-firb-pages button:hover,
.mfsa-firb .mfsa-firb-pages button:focus-visible,
.mfsa-firb .mfsa-firb-pages button[aria-current="page"] {
    color: #ffffff !important;
    background: var(--mfsa-ui-teal-dark);
    border-color: var(--mfsa-ui-teal-dark);
}

.mfsa-firb :is(.mfsa-firb-search, .mfsa-firb-sort, .mfsa-firb-page-size, .mfsa-firb-button, .mfsa-firb-pages button):focus-visible {
    outline: 3px solid var(--mfsa-ui-focus) !important;
    outline-offset: 2px !important;
}

.mfsa-firb .mfsa-firb-table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: var(--mfsa-ui-radius);
    -webkit-overflow-scrolling: touch;
}

.mfsa-firb table {
    width: 100%;
    max-width: 100%;
    color: var(--mfsa-ui-text);
    background: var(--mfsa-ui-surface);
}

.mfsa-firb th {
    color: #ffffff;
    background: var(--mfsa-ui-teal);
    border-color: var(--mfsa-ui-teal-dark);
}

.mfsa-firb td {
    color: var(--mfsa-ui-text);
    background: var(--mfsa-ui-surface);
    border-color: var(--mfsa-ui-border-light);
}

.mfsa-firb tbody tr:nth-child(even) td {
    background: var(--mfsa-ui-surface-subtle);
}

.mfsa-firb .mfsa-firb-class-heading th {
    color: #ffffff;
    background: var(--mfsa-ui-teal-dark);
}

.mfsa-firb .mfsa-firb-footer,
.mfsa-firb .mfsa-firb-footer label {
    color: var(--mfsa-ui-text-muted);
}

.mfsa-firb .mfsa-firb-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--mfsa-ui-gap);
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    box-sizing: border-box;
    background: var(--mfsa-ui-surface-subtle);
    border: 1px solid var(--mfsa-ui-border-light);
    border-radius: var(--mfsa-ui-radius);
}

.mfsa-firb .mfsa-firb-footer label {
    display: grid;
    gap: 6px;
    margin: 0;
}

.mfsa-firb .mfsa-firb-footer .mfsa-firb-page-size {
    width: 96px;
    max-width: 100%;
}

.mfsa-firb .mfsa-firb-pages {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
}

.mfsa-firb .mfsa-firb-pages button {
    min-width: 48px;
    min-height: 48px;
    padding: 8px 14px;
    font-weight: 700;
}

.mfsa-firb .mfsa-firb-empty {
    color: var(--mfsa-ui-text);
    background: var(--mfsa-ui-surface-subtle);
    border: 1px solid var(--mfsa-ui-border-light);
    border-radius: var(--mfsa-ui-radius);
}

body.pojo-a11y-high-contrast .mfsa-firb,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-toolbar,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-footer,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-empty {
    color: #ffffff !important;
    background: #000000 !important;
    border-color: #ffffff !important;
}

body.pojo-a11y-high-contrast .mfsa-firb :is(.mfsa-firb-count, .mfsa-firb-footer label) {
    color: #ffffff !important;
    background: #000000 !important;
}

body.pojo-a11y-high-contrast .mfsa-firb :is(.mfsa-firb-search, .mfsa-firb-sort, .mfsa-firb-page-size) {
    color: #ffffff !important;
    background: #000000 !important;
    border: 2px solid #ffffff !important;
}

body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-search::placeholder {
    color: #ffffff !important;
    opacity: 1 !important;
}

body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-button,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-pages button {
    color: #00ffff !important;
    background: #000000 !important;
    border: 2px solid #ffffff !important;
    text-decoration: underline !important;
}

body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-button:hover,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-button:focus-visible,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-pages button:hover,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-pages button:focus-visible,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-pages button[aria-current="page"] {
    color: #000000 !important;
    background: #ffff00 !important;
}

body.pojo-a11y-high-contrast .mfsa-firb th,
body.pojo-a11y-high-contrast .mfsa-firb .mfsa-firb-class-heading th {
    color: #000000 !important;
    background: #ffff00 !important;
    border-color: #ffffff !important;
}

body.pojo-a11y-high-contrast .mfsa-firb td,
body.pojo-a11y-high-contrast .mfsa-firb tbody tr:nth-child(even) td {
    color: #ffffff !important;
    background: #000000 !important;
    border-color: #ffffff !important;
}

@media (max-width: 900px) {
    .mfsa-firb .mfsa-firb-toolbar {
        align-items: stretch;
        flex-direction: column;
        flex-wrap: wrap;
    }

    .mfsa-firb .mfsa-firb-controls {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }

    .mfsa-firb .mfsa-firb-controls label {
        flex: 1 1 100%;
    }

    .mfsa-firb .mfsa-firb-toolbar .mfsa-firb-button {
        flex: 1 1 112px !important;
        width: auto !important;
    }

    .mfsa-firb .mfsa-firb-search,
    .mfsa-firb .mfsa-firb-sort,
    .mfsa-firb .mfsa-firb-page-size {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .mfsa-firb .mfsa-firb-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .mfsa-firb .mfsa-firb-footer label,
    .mfsa-firb .mfsa-firb-footer label {
        width: 100%;
    }

    .mfsa-firb .mfsa-firb-footer .mfsa-firb-page-size {
        width: 96px;
    }

    .mfsa-firb .mfsa-firb-pages {
        justify-content: flex-start;
    }
}

/* Print remains fully owned by the FIRB plugin. */
@media print {
    .mfsa-firb .mfsa-firb-toolbar,
    .mfsa-firb .mfsa-firb-footer,
    .mfsa-firb .mfsa-firb-empty {
        display: none !important;
    }
}
