/* Soomi chrome for Roundcube — the webmail counterpart of `assets/nextcloud-theming/soomi-embed.css`.
 *
 * ⚠️ THAT FILE DOES NOT CARRY OVER, AND COPYING IT WOULD NOT WORK. It is written against Nextcloud's
 * ids (`#header`, `#content`, `--header-height`); Roundcube shares none of them. This is a skin
 * problem, not a stylesheet-copy problem.
 *
 * ── ⚠️⚠️ ELASTIC HAS NO THEMING LAYER (measured 2026-09-21) ─────────────────────────────────────
 *
 * `grep -c "var(--"` over the whole 122 KB `skins/elastic/styles/styles.min.css` returns **0**. The
 * skin defines and uses NO CSS custom properties, so there is no token layer to override — every
 * colour is a concrete selector, compiled from LESS. That is why this file grows by OBSERVATION of the
 * rendered page rather than by reading templates: a template is not a DOM, and this repo has paid for
 * that lesson three times.
 *
 * ── WHY A PLUGIN AND NOT A SKIN ─────────────────────────────────────────────────────────────────
 *
 * `/var/www/html` is a NAMED VOLUME (`soomi_roundcube_html`) that masks the image — the same trap as
 * Nextcloud's `custom_apps`. A skin written there is invisible to the repo and dies on recreate.
 * `plugins/soomi_prime` is a repo-backed bind mount, so CSS shipped here is reproducible and deploys
 * without touching the container. ★ Same reasoning `soomi_prime.php` already records for deriving its
 * contact endpoint instead of adding an env var: this container's environment is baked at creation,
 * and recreating it is the risky operation we still owe for the stale `--add-host` pin.
 */

/* ── The per-service quota bar — HIDDEN BY POLICY, not by taste ─────────────────────────────────────
 *
 * ⛔ Soomi never shows a per-SERVICE storage total. `app/portal/storage-usage-bar.tsx` is the single
 * place storage is reported, and it reports the ACCOUNT's, because a customer buys one allowance and
 * not a mail quota and a files quota. A second bar disagreeing with it in a pane they reached from our
 * own app switcher is worse than no bar: it invites the question "which number is my plan?".
 *
 * Roundcube offers no config to suppress it, so CSS is the only lever. Two surfaces, both measured:
 *   · `#quotadisplay.quota-widget`  — the inline bar, in BOTH `mail.html` and `folders.html`
 *   · `.quota-info`                 — the per-root breakdown TABLE behind it
 * ⚠️ The widget ships as `class="quota-widget hidden"` and is un-hidden by JS, so this has to be
 * `!important` — a plain rule loses to the script that reveals it.
 */
#quotadisplay,
.quota-widget,
.quota-info {
    display: none !important;
}

/* ── The task rail — match the portal's charcoal, and stop the blue ────────────────────────────────
 *
 * Observed on the rendered pane 2026-09-21 (Mark): "the colour for the side bar is a lighter grey than
 * the footer/header". Measured cause — elastic paints the rail `#2f3a3f`, which is both LIGHTER than
 * our `#2A2D31` and carries a blue-green cast. `brand.tsx` calls the Soomi charcoal out explicitly as
 * "no blue", which is exactly why the mismatch reads as wrong rather than merely different.
 *
 * Three elements share that colour and must move together, or the rail bands: the rail itself, the
 * bottom `.special-buttons` block (Dark mode / About / Logout) and the popover header.
 */
#layout-menu,
#layout-menu .popover-header,
#taskmenu .special-buttons {
    background-color: #2A2D31 !important;
}

/* Hover / selected lift. ★ A WHITE ALPHA rather than a new grey — the same device `app-bar.tsx` uses
 * for its own hairline on this charcoal, so the two bars stay related by construction instead of by a
 * hex someone has to keep in sync. Replaces elastic's `#45555c`, which is the blue-grey again. */
#taskmenu a.selected,
#taskmenu a.selected:hover,
#taskmenu a:hover,
#taskmenu a:focus {
    background-color: rgba(255, 255, 255, 0.10) !important;
}

/* ── Compose — the Soomi red TILE, not red text ────────────────────────────────────────────────────
 *
 * ⚠️⚠️ FULL RED AS TEXT ON THIS RAIL IS UNREADABLE, MEASURED. `#D80621` on `#2A2D31` is **2.61:1** —
 * it fails WCAG AA for text (4.5:1) and fails even the 3:1 non-text threshold, so it would have been
 * strictly WORSE than elastic's blue (6.57:1) that it replaced. The obvious change was the wrong one.
 *
 * ★ White ON red is **5.29:1** and passes — and it is the treatment our own header already uses one
 * row above this rail: the Soomi logo is a red tile with a white maple leaf. So Compose becomes the
 * one red thing in the pane, which is what `brand.tsx` asks for ("use as ACCENT, not a flood").
 * ⚠️ Deliberately NOT applied to the other ~46 `#37beff` usages in this skin (links, focus rings,
 * checkboxes, selected rows). Turning those red is the flood the brand rule forbids, and none of them
 * has been observed rendered.
 *
 * Hover uses `redDark` from `brand.tsx` — derived, not a new colour invented here.
 */
#taskmenu .action-buttons a {
    color: #fff !important;
    background-color: #D80621 !important;
}
#taskmenu .action-buttons a:hover,
#taskmenu .action-buttons a:focus {
    color: #fff !important;
    background-color: #A8051A !important;
}

/* ── The rail's logo — REMOVED, because the portal header already carries it ───────────────────────
 *
 * Mark, 2026-09-21: "it's already in the header, so it's duplicative in the same general area."
 * `templates/includes/menu.html` puts `<roundcube:object name="logo" id="logo">` inside
 * `#layout-menu .popover-header`, which renders directly beneath the portal's own charcoal header —
 * so the Soomi mark appeared twice, about 50px apart. That is the doubled-chrome shape BUGS #73
 * already cost us once, on a pane that spends 164px on chrome before any mail is shown.
 *
 * ⚠️ `#logo`, NOT `.popover-header`. That container's other child is the phone CLOSE button
 * (`a.button.icon.cancel`) — hiding the container would take the only way to dismiss the rail on a
 * phone with it. ★ This is exactly the mistake `soomi-embed.css` records: Nextcloud's header was
 * treated as the unit of the decision when its two halves deserved opposite answers, and three
 * controls with no replacement anywhere in the product disappeared.
 *
 * ⚠️ SCOPED TO `#layout-menu` ON PURPOSE. The LOGIN page also renders `#logo`, and it has no
 * `#layout-menu` (measured: the string does not appear in that page at all). There is no portal
 * header around the login form — it is bare Roundcube, shown when a prime fails — so the mark is the
 * only thing identifying whose login it is, and it must stay.
 */
#layout-menu #logo {
    display: none !important;
}

/* ── No webmail Logout — signing out is the PORTAL's job (Mark, 10-04) ─────────────────────────────
 *
 * Roundcube's Logout ends only the WEBMAIL session, and the login form it lands on cannot work: there is
 * no mail password to type — every session's credential is minted by the portal hand-off and never
 * shown. So the button offered a dead end ("my password doesn't work"), and it was never a real logout
 * either — the portal session lives on. One place signs out: the portal, which also ends webmail
 * (BUGS #292 b/c). `menu.html` renders it as `<a class="logout">` inside `#taskmenu .special-buttons`.
 * ⚠️ CSS hides the control, not the action: `?_task=logout` still works if typed — harmless (it only
 * ends this webmail session; opening Mail from the portal re-primes).
 */
#taskmenu a.logout {
    display: none !important;
}

/* ── The login-page note (soomi_prime::login_note) — this page is not the way in ───────────────── */
.soomi-login-note {
    margin-top: 1.5rem;
    max-width: 26rem;
    font-size: 0.95rem;
    line-height: 1.45;
}
.soomi-login-note a {
    font-weight: 600;
    white-space: nowrap;
}
.soomi-login-note .soomi-login-device {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    opacity: 0.75;
}

/* ── The "Labels" sidebar section (label-sidebar.js, webmail-labels.md) ─────────────────────────────────
 * Sits under the folder list and borrows its rhythm: same row height and padding as a folder row, so it
 * reads as part of the same list. Colour is only the dot; the name stays the sidebar's text colour (legible
 * in light and dark without a per-colour contrast check). */
#soomi-labels { margin-top: 1rem; }
#soomi-labels .soomi-labels-heading {
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  margin: 0; padding: .5rem 1rem .25rem; opacity: .7;
}
#soomi-labels ul { list-style: none; margin: 0; padding: 0; }
#soomi-labels li a {
  display: flex; align-items: center; gap: .6rem; padding: .45rem 1rem;
  color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden;
}
#soomi-labels li a:hover { background-color: rgba(0, 0, 0, .05); }
html.dark-mode #soomi-labels li a:hover { background-color: rgba(255, 255, 255, .07); }
#soomi-labels li.selected a { font-weight: 600; background-color: rgba(0, 0, 0, .08); }
html.dark-mode #soomi-labels li.selected a { background-color: rgba(255, 255, 255, .12); }
#soomi-labels .soomi-label-dot { flex: none; width: .7rem; height: .7rem; border-radius: 50%; }
#soomi-labels .soomi-label-name { overflow: hidden; text-overflow: ellipsis; }
#soomi-labels .soomi-labels-unavailable { padding: .45rem 1rem; opacity: .7; font-style: italic; }

/* ── The Label button, its picker, and chips in the list (label-picker.js) ─────────────────────────── */
.toolbar a.button.soomi-label:before { content: "\f02c"; } /* tags */
.soomi-label-menu {
  position: fixed; z-index: 1000; width: 18rem; max-width: calc(100vw - 16px);
  background: #fff; color: #2c363a; border: 1px solid #d4dbde; border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .15); padding: .5rem 0;
}
html.dark-mode .soomi-label-menu { background: #21292c; color: #c5d1d3; border-color: #3f4b50; }
.soomi-label-menu input { width: calc(100% - 1rem); margin: 0 .5rem .4rem; }
.soomi-label-menu ul { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.soomi-label-menu a.soomi-pick {
  display: flex; align-items: center; gap: .55rem; padding: .4rem .75rem;
  color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden;
}
.soomi-label-menu a.soomi-pick:hover, .soomi-label-menu a.soomi-pick:focus { background-color: rgba(0, 0, 0, .06); outline: none; }
html.dark-mode .soomi-label-menu a.soomi-pick:hover { background-color: rgba(255, 255, 255, .08); }
.soomi-label-menu .soomi-pick-tick { flex: none; width: 1rem; text-align: center; font-weight: 700; }
.soomi-label-menu .soomi-label-dot { flex: none; width: .7rem; height: .7rem; border-radius: 50%; }
.soomi-label-menu .soomi-label-name { overflow: hidden; text-overflow: ellipsis; }
.soomi-label-menu .soomi-pick-create { font-style: italic; overflow: hidden; text-overflow: ellipsis; }
.soomi-label-menu .soomi-pick-empty { padding: .4rem .75rem; opacity: .7; white-space: normal; }
.soomi-chips { display: inline; margin-right: .35rem; }
.soomi-chip {
  display: inline-block; vertical-align: middle; max-width: 9rem; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: .72rem; line-height: 1.35; padding: 0 .4rem; margin-right: .25rem;
  border-radius: .6rem; font-weight: 600;
}

/* ── The sidebar label menu: ⋮ per row, rename · colour · delete (label-sidebar.js) ──────────────────── */
#soomi-labels li { position: relative; }
#soomi-labels li a { padding-right: 2.2rem; }
#soomi-labels .soomi-label-more {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: inherit; font-size: 1.1rem; line-height: 1;
  /* Always faintly visible (11-05: Mark could not find Delete — it only appeared on hover); stronger on hover. */
  padding: .2rem .45rem; border-radius: 4px; cursor: pointer; opacity: .35;
}
#soomi-labels li:hover .soomi-label-more, #soomi-labels .soomi-label-more:focus { opacity: .75; }
@media (hover: none) { #soomi-labels .soomi-label-more { opacity: .6; } } /* touch: no hover, always shown */
#soomi-labels .soomi-label-more:hover { opacity: 1; background-color: rgba(0, 0, 0, .08); }
.soomi-label-manage .soomi-label-hint { font-size: .75rem; opacity: .65; padding: 0 .75rem .5rem; }
.soomi-swatches { display: grid; grid-template-columns: repeat(6, 1.6rem); gap: .45rem; padding: .25rem .75rem .6rem; }
.soomi-swatch { width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; }
.soomi-swatch.on { border-color: currentColor; box-shadow: 0 0 0 2px rgba(255, 255, 255, .9) inset; }
.soomi-label-menu a.soomi-label-delete { color: #b91c1c; border-top: 1px solid rgba(0, 0, 0, .1); margin-top: .2rem; padding-top: .55rem; }
html.dark-mode .soomi-label-menu a.soomi-label-delete { color: #fca5a5; border-top-color: rgba(255, 255, 255, .12); }
/* Unnamed tags (step 5): a hollow dot + the raw keyword in italics — visibly "not named yet". */
/* The unread badge (11-05) — Elastic's own folder badge (.folderlist li.mailbox .unreadcount, 1.7.5), placed in the
   flow before the ⋮ instead of absolutely at the edge where the ⋮ sits. Its colours are the skin's, copied, not new. */
#soomi-labels .soomi-label-unread {
  float: right; min-width: 2em; line-height: 1.4rem; padding: 0 .3em; border-radius: .4em;
  background: #37beff; color: #fff; text-align: center; font-weight: 700; font-style: normal;
}
html.dark-mode #soomi-labels .soomi-label-unread { background-color: #4d6066; color: #e2e8e9; font-weight: 400; }
#soomi-labels .soomi-label-dot-empty { background: transparent !important; border: 2px solid currentColor; opacity: .55; box-sizing: border-box; }
#soomi-labels .soomi-label-unnamed .soomi-label-name { font-style: italic; opacity: .8; }
.soomi-label-manage .soomi-label-head { font-weight: 600; opacity: .85; padding-top: .1rem; }

/* ── Settings → Label rules (label-rules.js, webmail-labels.md slice 2) ─────────────────────────────── */
/* The Settings entry's icon: Elastic draws each entry's icon with a Font Awesome glyph in a:before — the tag glyph. */
#settings-menu li.soomi-label-rules a:before { content: "\f02b"; }
.soomi-rules { max-width: 52rem; }
.soomi-rules-intro { margin-bottom: .25rem; }
.soomi-rules-note { opacity: .75; font-size: .9rem; }
.soomi-rules-list { list-style: none; padding: 0; margin: 1rem 0; }
.soomi-rule { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border: 1px solid rgba(0, 0, 0, .12); border-radius: 6px; margin-bottom: .5rem; }
html.dark-mode .soomi-rule { border-color: rgba(255, 255, 255, .15); }
.soomi-rule-summary { flex: 1; overflow-wrap: anywhere; }
.soomi-rule-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.soomi-rules-empty { opacity: .7; font-style: italic; padding: .5rem 0; }
.soomi-rule-editor .soomi-rule-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.soomi-rule-editor .soomi-rule-condition select { width: auto; }
.soomi-rule-editor .soomi-rule-condition input { flex: 1; min-width: 12rem; }
.soomi-rule-editor .soomi-rule-match { width: auto; }
.soomi-rule-then { font-size: 1rem; margin: 1rem 0 .5rem; }
.soomi-rule-labels { margin-bottom: .75rem; }
.soomi-rule-labels legend { font-size: .95rem; margin-bottom: .25rem; }
.soomi-rule-buttons { margin-top: 1rem; display: flex; gap: .5rem; }
.soomi-rule-check { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.soomi-rule-check input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; flex-shrink: 0; cursor: pointer; }
.soomi-rule-check label { margin: 0; cursor: pointer; }
