/* Adsero branding for Metabase.
 *
 * Metabase OSS gates logo replacement behind the paid `whitelabel` feature —
 * PUT /api/setting/application-logo-url returns
 * "Setting application-logo-url is not enabled". Nothing here patches the jar
 * or fakes a licence token; this is a plain CSS override injected by nginx into
 * our own served page, swapping the inline SVG logo for the same PNG the
 * timematters UI uses in its header.
 *
 * The logo is an inline <svg data-testid="main-logo" viewBox="0 0 212 256">
 * inside <a data-testid="main-logo-link">. Hiding its children and painting a
 * background on the svg keeps Metabase's own layout and click behaviour intact.
 *
 * If Metabase changes that data-testid in a future upgrade, the logo silently
 * reverts to Metabase's own — an upgrade check, not a breakage.
 */

svg[data-testid="main-logo"] {
  width: 91px !important;      /* 1798x634 at 32px tall */
  height: 32px !important;
  background: url("/branding/logo.png") left center / contain no-repeat;
}
svg[data-testid="main-logo"] > * { display: none !important; }

/* The login and loading screens render the same mark larger. */
[data-testid="login-page"] svg[data-testid="main-logo"],
.LoadingSpinner svg[data-testid="main-logo"] {
  width: 182px !important;
  height: 64px !important;
}

/* ── No illustrations ─────────────────────────────────────────────────────────
 * Metabase gates landing-page-illustration / login-page-illustration /
 * no-data-illustration behind the same paid `whitelabel` feature, so the
 * decorative artwork is removed here instead.
 *
 * The default home illustration renders as an <svg> sized
 * width="max(1953px, 100%)" inside [data-testid="home-page"]; the attribute
 * prefix is a stabler hook than the build-hashed class name beside it.
 */

/* Home page: the landscape/lighthouse artwork, default and custom variants. */
[data-testid="home-page"] svg[width^="max("],
[data-testid="landing-page-illustration"] { display: none !important; }

/* Greeting robot avatar — hide the icon, keep the "Greetings, …" text. */
*:has(> [data-testid="greeting-message"]) > *:not([data-testid="greeting-message"]) {
  display: none !important;
}

/* Login and unsubscribe artwork. */
[data-testid="login-page-illustration"],
[data-testid="unsubscribe-page-illustration"] { display: none !important; }

/* Empty-state artwork throughout the app — the explanatory text stays. */
.empty-state-illustration { display: none !important; }

/* ── Metabase's own onboarding furniture ──────────────────────────────────────
 * `show-metabase-links` would turn these off, but it is whitelabel-gated like
 * the rest. The Examples collection and its sample dashboard were archived
 * properly through the API; what remains is hidden here.
 *
 * The sidebar section is selected by depth from a stable aria-label rather than
 * by its build-hashed emotion class:
 *   section > div > div > li[aria-label="How to use Metabase"]
 */
div:has(> div > div > li[aria-label="How to use Metabase"]) { display: none !important; }

/* "Metabase tips" card in the recents strip — a link out to metabase.com. */
a[href^="https://www.metabase.com"] { display: none !important; }

/* ── Gear menu: keep only what an Adsero user needs ───────────────────────────
 * Hides "Keyboard shortcuts", "Download diagnostics" and "About Metabase",
 * leaving Account settings, Admin settings and Sign out. ("Help" is already
 * hidden by the metabase.com link rule above.)
 *
 * CSS cannot match on text, so the rule is built from structure instead:
 *   - scope to the menu that contains the Admin settings link, so no other
 *     dropdown in the app is affected;
 *   - within it, hide every <button> menu item that has another <button> menu
 *     item after it. Sign out is last, so it survives; the three above it do
 *     not. If Metabase adds another item to that group it is hidden too, which
 *     is the intent.
 */
div:has(> a[role="menuitem"][href="/admin"]) > button[role="menuitem"]:has(~ button[role="menuitem"]) {
  display: none !important;
}

/* With those gone the menu would show two rules in a row; drop the lower one so
   Sign out sits directly under the Account/Admin group. */
div:has(> a[role="menuitem"][href="/admin"]) > div:last-of-type {
  display: none !important;
}

/* Also hide "Admin settings" from the gear menu.
 *
 * This is presentation only — the admin panel is NOT disabled. Any user with
 * the admin role can still reach it directly at
 * https://reports.lpm.theboomerang.net/admin, which is how you add a database,
 * manage groups and permissions, or check the Metabase logs.
 *
 * Note the selector still keys off this same link to scope the rules above, so
 * hiding it here (display:none, still in the DOM) does not break them.
 */
div:has(> a[role="menuitem"][href="/admin"]) > a[role="menuitem"][href="/admin"] {
  display: none !important;
}

/* ── Sidebar: hide the DATA section and Trash ─────────────────────────────────
 * Leaves Home and Collections, which is all a report consumer needs.
 *
 * "Data" (Databases / Models / Metrics) is the raw-table browser. Hiding it
 * keeps people in the curated marts rather than wandering into fact tables and
 * building numbers that disagree with the dashboards.
 *
 * Selected by depth from the stable hrefs rather than the build-hashed classes:
 *   section > div > div > li > a[href="/browse/databases"]
 *
 * Nothing is disabled — /browse/databases, /browse/models, /browse/metrics and
 * /collection/trash all still work if typed directly, and admins keep full
 * access through /admin.
 */
div:has(> div > div > li > a[href="/browse/databases"]) { display: none !important; }

li:has(> a[href="/collection/trash"]) { display: none !important; }

/* ── Collection header toolbar ────────────────────────────────────────────────
 * Hides the whole icon row on every collection page: new collection, upload
 * data, events/timelines, info, and the "..." menu (which held Edit
 * permissions, Move, Archive).
 *
 * All five sit in one container, so a single rule covers every collection page
 * rather than chasing individual icons.
 *
 * What this costs, and where it moved to:
 *   Edit permissions  -> /admin/permissions
 *   New collection    -> the "+ New" button in the top bar
 *   Upload data / Events — not used by this deployment; the warehouse is built
 *   by the nightly ETL, not by uploading spreadsheets into Metabase.
 *
 * Dashboards and questions keep their own toolbars — editing a dashboard is
 * unaffected.
 */
[data-testid="collection-menu"] { display: none !important; }
