/*
This css code fixes css framework conflicts between MUI and Joomla (Bootstrap/Cassiopeia).
 */

/* MUI DataGrid cells get a top margin from Bootstrap's `p { margin-bottom: 1rem }` — reset it */
#nextinventory-root .MuiDataGrid-mainContent p {
    margin: 0;
}

/* In admin, the component renders its own toolbar — hide Joomla's subhead */
body.com_nextinventory #subhead-container {
    display: none;
}

/* Cassiopeia ships `[role="tooltip"]:not(.show) { display: none; ... }` (Bootstrap convention).
   MUI never adds Bootstrap's `.show` class to its poppers, so that rule would hide every MUI
   tooltip and overwrite its styling. We restore MUI's behaviour for popper portals only —
   the inner `.MuiTooltip-tooltip` keeps the dark pill from MUI's own emotion styles. */
.MuiPopper-root[role="tooltip"] {
    display: block !important;
    z-index: 1500 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    color: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    right: auto !important;
    max-width: none !important;
    text-align: inherit !important;
}

/*
 * Colour scheme for native UI.
 *
 * The SPA is themed entirely by MUI inside a ScopedCssBaseline, which paints its own
 * surfaces but says nothing about native widgets - scrollbars, date pickers, select
 * dropdowns, form controls. Declaring color-scheme hands those to the browser to render
 * in the right mode, which is why there are no ::-webkit-scrollbar rules here.
 *
 * Atum already declares this for the admin, so it really bites on the site catalogue and
 * on admin templates with no colour scheme of their own, where the SPA carries
 * data-bs-theme itself. The three selector shapes cover the ScopedCssBaseline being the
 * root, being nested inside it, and <html> carrying the attribute above it.
 */
#nextinventory-root[data-bs-theme='dark'],
#nextinventory-root [data-bs-theme='dark'],
[data-bs-theme='dark'] #nextinventory-root {
    color-scheme: dark;
}

#nextinventory-root[data-bs-theme='light'],
#nextinventory-root [data-bs-theme='light'],
[data-bs-theme='light'] #nextinventory-root {
    color-scheme: light;
}
