/* ── File Picker (DevExtreme dxFileManager) ─────────────────────────────────
   Skin for every dxPickerService popup: report images/references/working files,
   comment attachments, and the shared species/groups/methods/eco-cert galleries.

   Loaded globally from _Layout, because dxPickerService is. It used to live inside
   report.css, which is only linked by six views — so the Methods picker (whose page
   does not link it) rendered completely unstyled.

   ⚠️ LINK ORDER MATTERS: this must load AFTER site.css. That sheet carries
   `.dx-popup-normal .dx-popup-title { background: #cee4e6 !important }` — identical specificity
   (two classes) and importance to the title rule below, so whichever sheet comes last wins.
   Linked earlier, the dark title bar silently turns pale blue. It used to win only because
   report.css was linked by the view, i.e. after the layout's head.

   The popup is appended to <body> with wrapper class .dxImagePickerPopupWrapper, so it
   sits outside any page container and re-declares the ocean-depth palette locally. The
   wrapper class name is the contract with dxPickerService — renaming it drops the whole
   skin silently. See docs/Core Migration/netcore-ckfinder-callsite-rollout-handoff.md.

   The palette is declared on BOTH wrappers because the New Subfolder / Rename dialogs are
   sibling popups, not descendants of the picker (see their section below) — inheritance does
   not reach them, and a var() that resolves to nothing fails silently, per-property, leaving a
   half-styled dialog rather than an obviously broken one. Kept off :root deliberately: these
   names are this component's, not the app's. */
.dxImagePickerPopupWrapper,
.dx-filemanager-dialog-popup {
    --ad-abyss: #00263f;
    --ad-deep: #0d4763;
    --ad-teal: #2a9aaf;
    --ad-glow: #7fd8e8;
    --ad-mist: #eef6f8;
    --ad-ink: #1a5f6e;
}

.dxImagePickerPopupWrapper .dx-overlay-content.dx-popup-normal {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(13, 71, 99, 0.35);
    box-shadow: 0 24px 60px rgba(0, 30, 50, 0.40);
}

/* Title bar — same gradient + light shaft as the drawer header */
.dxImagePickerPopupWrapper .dx-popup-title {
    position: relative;
    background:
        radial-gradient(120% 180% at 85% -40%, rgba(82, 196, 222, 0.35), transparent 60%),
        linear-gradient(115deg, var(--ad-abyss), var(--ad-deep) 58%, #19708a 100%) !important;
    border: none !important;
    padding: 0 8px 0 18px !important;
    min-height: 48px !important;
}

.dxImagePickerPopupWrapper .dx-popup-title::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--ad-teal), rgba(42, 154, 175, 0));
}

.dxImagePickerPopupWrapper .dx-popup-title .dx-toolbar-label,
.dxImagePickerPopupWrapper .dx-popup-title .dx-toolbar-label * {
    color: #ffffff !important;
    font-family: interstate, Arial, sans-serif !important;
    font-size: 13px !important;
    font-weight: bold !important;
    letter-spacing: 0.09em !important;
    text-transform: uppercase !important;
    max-width: none !important;
}

/* Close button — quiet ghost on navy (kill the stock filled circle).
   The circle is NOT the DevExtreme theme, which leaves this button transparent. It is
   `site.css:1101`, `.dx-popup-normal .dx-toolbar .dx-button`, which paints every button in a popup
   toolbar as a navy pill — and a popup *title* is a toolbar (`.dx-popup-title.dx-toolbar`,
   swat_mods_dialog.css:27), so the close button is caught by it. That rule is three classes deep with
   !important; these are four, so they win.

   The New Subfolder / Rename dialogs are listed alongside rather than given their own copy: the whole
   point is that the two look identical, and two blocks would drift. `background` (not
   `background-color`) because the shorthand is what resets site.css's colour. */
.dxImagePickerPopupWrapper .dx-popup-title .dx-closebutton.dx-button,
.dx-filemanager-dialog-popup .dx-popup-title .dx-closebutton.dx-button {
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 4px !important;
    box-shadow: none !important;
}

.dxImagePickerPopupWrapper .dx-popup-title .dx-closebutton .dx-icon,
.dx-filemanager-dialog-popup .dx-popup-title .dx-closebutton .dx-icon {
    color: #bfe2ec !important;
}

.dxImagePickerPopupWrapper .dx-popup-title .dx-closebutton.dx-button:hover,
.dx-filemanager-dialog-popup .dx-popup-title .dx-closebutton.dx-button:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.dxImagePickerPopupWrapper .dx-popup-title .dx-closebutton.dx-button:hover .dx-icon,
.dx-filemanager-dialog-popup .dx-popup-title .dx-closebutton.dx-button:hover .dx-icon {
    color: #ffffff !important;
}

/* Toast messages honour literal newlines. The rename warning is two instructions — what happened,
   then what to do about it — and Toast renders `message` as text (ui.toast.js uses .text(), which is
   also what stops an interpolated file name injecting markup), so a \n is the only break available.

   Deliberately unscoped: a toast is appended to <body>, not inside .dxImagePickerPopupWrapper, and
   DevExtreme gives no reliable hook to class one from notify(). Safe globally because `pre-line` only
   changes rendering where a newline exists, and no other message in the app contains one — and if
   this rule were ever dropped, the newline degrades to a space rather than breaking anything. */
.dx-toast-message {
    white-space: pre-line;
}

/* ── The New Subfolder / Rename dialogs ─────────────────────────────────────
   These are NOT inside .dxImagePickerPopupWrapper. dxFileManager builds them as separate dxPopups
   whose wrapper carries `dx-filemanager-dialog-popup` (ui.file_manager.dialog.js), appended to the
   overlay container alongside the picker rather than inside it — so every rule above misses them and
   they fell through to the app's default popup styling (site.css's pale-blue title bar).

   The class is global, but this app has exactly one dxFileManager, so it cannot catch anything else.

   ⚠️ SPECIFICITY, not just link order: `site.css:1088` is `.dx-popup-normal .dx-popup-title` with
   `!important` — two classes. Its other `.dx-popup-normal` rules are three deep. Every selector here
   is therefore three or four classes deep, so these win on specificity alone and do not depend on
   filePicker.css being linked last (it still must be, for the picker's own title bar — see the
   header). */

.dx-filemanager-dialog-popup .dx-overlay-content.dx-popup-normal {
    border-radius: 10px !important;
    overflow: hidden !important;
    border: 1px solid rgba(13, 71, 99, 0.35) !important;
    box-shadow: 0 24px 60px rgba(0, 30, 50, 0.40) !important;
}

/* Title bar — the same gradient and teal shaft as the picker, one step shorter since a dialog
   header carries less weight than the gallery's. */
.dx-filemanager-dialog-popup .dx-popup-normal .dx-popup-title {
    position: relative;
    background:
        radial-gradient(120% 180% at 85% -40%, rgba(82, 196, 222, 0.35), transparent 60%),
        linear-gradient(115deg, var(--ad-abyss), var(--ad-deep) 58%, #19708a 100%) !important;
    border: none !important;
    padding: 0 8px 0 18px !important;
    min-height: 42px !important;
}

.dx-filemanager-dialog-popup .dx-popup-normal .dx-popup-title::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--ad-teal), rgba(42, 154, 175, 0));
}

/* The dialogs' close button is handled with the picker's, further up — one rule set for both, so the
   two cannot drift apart. */

.dx-filemanager-dialog-popup .dx-popup-normal .dx-popup-title .dx-toolbar-label,
.dx-filemanager-dialog-popup .dx-popup-normal .dx-popup-title .dx-toolbar-label * {
    color: #ffffff !important;
    font-family: interstate, Arial, sans-serif !important;
    font-size: 13px !important;
    font-weight: bold !important;
    letter-spacing: 0.09em !important;
    text-transform: uppercase !important;
    max-width: none !important;
}

/* Body — the picker's mist, so the dialog reads as part of the same surface. */
.dx-filemanager-dialog-popup .dx-popup-normal .dx-popup-content {
    background: var(--ad-mist) !important;
    padding: 18px !important;
}

/* The name field, matching the toolbar's Filter box. */
.dx-filemanager-dialog-popup .dx-popup-content .dx-textbox {
    background: #ffffff !important;
    border: 1px solid #c8e3e9 !important;
    border-radius: 7px !important;
}

.dx-filemanager-dialog-popup .dx-popup-content .dx-textbox.dx-state-focused {
    border-color: var(--ad-teal) !important;
    box-shadow: 0 0 0 2px rgba(42, 154, 175, 0.2) !important;
}

.dx-filemanager-dialog-popup .dx-popup-content .dx-textbox .dx-texteditor-input {
    color: var(--ad-ink) !important;
}

/* Bottom bar. Both buttons get the quiet treatment; the first — Create / Save, which
   ui.file_manager.dialog.js always emits ahead of Cancel — is promoted to the navy CTA the rest of
   the picker uses. Written so that if that order ever changed, both would simply read as the quiet
   variant rather than anything looking broken. */
.dx-filemanager-dialog-popup .dx-popup-normal .dx-popup-bottom {
    background: var(--ad-mist) !important;
    border-top: 1px solid #c8e3e9 !important;
    padding: 10px 14px !important;
}

.dx-filemanager-dialog-popup .dx-popup-bottom .dx-toolbar-after .dx-button {
    background: #ffffff !important;
    border: 1px solid #c8e3e9 !important;
    border-radius: 7px !important;
    box-shadow: none !important;
}

.dx-filemanager-dialog-popup .dx-popup-bottom .dx-toolbar-after .dx-button .dx-button-text {
    color: var(--ad-deep) !important;
}

.dx-filemanager-dialog-popup .dx-popup-bottom .dx-toolbar-after .dx-button:hover {
    border-color: var(--ad-teal) !important;
}

.dx-filemanager-dialog-popup .dx-popup-bottom .dx-toolbar-after .dx-toolbar-item:first-child .dx-button {
    background: linear-gradient(180deg, #0e4a63, var(--ad-abyss)) !important;
    border: 1px solid rgba(127, 216, 232, 0.45) !important;
    box-shadow: 0 1px 3px rgba(0, 38, 63, 0.25) !important;
}

.dx-filemanager-dialog-popup .dx-popup-bottom .dx-toolbar-after .dx-toolbar-item:first-child .dx-button .dx-button-text {
    color: #ffffff !important;
}

.dx-filemanager-dialog-popup .dx-popup-bottom .dx-toolbar-after .dx-toolbar-item:first-child .dx-button:hover {
    background: linear-gradient(180deg, #156080, #073651) !important;
    border-color: var(--ad-glow) !important;
}

/* File manager body + toolbar */
.dxImagePickerPopupWrapper .dx-filemanager {
    border: none !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar,
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar {
    background: #f0f7f9 !important;
    border-bottom: 1px solid #c8e3e9 !important;
}

/* The toolbar's action buttons — navy primary CTAs, matching the drawer. These are
   dx-button-mode-text (not dx-button-default), so they are targeted as the text buttons in the
   "before" area. Since decision 8 that is Upload, New Subfolder and Rename rather than Upload
   alone, and they are deliberately styled alike: CKFinder presented them as one row of equals. */
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-before .dx-button.dx-button-has-text {
    background: linear-gradient(180deg, #0e4a63, var(--ad-abyss)) !important;
    border: 1px solid rgba(127, 216, 232, 0.45) !important;
    border-radius: 7px !important;
    box-shadow: 0 1px 3px rgba(0, 38, 63, 0.25) !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-before .dx-button.dx-button-has-text:hover {
    background: linear-gradient(180deg, #156080, #073651) !important;
    border-color: var(--ad-glow) !important;
}

/* Label and icon both go white. The icon selector is the button's .dx-icon rather than
   .dx-icon-upload: New Subfolder and Rename carry their own icons, and naming each one is how the
   next button added here ends up dark-on-navy. */
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-before .dx-button.dx-button-has-text .dx-button-text,
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-before .dx-button.dx-button-has-text .dx-icon {
    color: #ffffff !important;
}

/* The Filter box (SWATV2-3545) — a custom dxTextBox in the toolbar's "after" area, matching
   CKFinder's. White field on the pale toolbar so it reads as somewhere to type, with a teal focus
   ring picked up from the rest of the skin. Scoped to .dx-toolbar-after so it cannot catch the
   New Subfolder / Rename dialogs' own text inputs, which are separate popups. */
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-textbox {
    background: #ffffff !important;
    border: 1px solid #c8e3e9 !important;
    border-radius: 7px !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-textbox.dx-state-focused {
    border-color: var(--ad-teal) !important;
    box-shadow: 0 0 0 2px rgba(42, 154, 175, 0.2) !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-textbox .dx-texteditor-input {
    color: var(--ad-ink) !important;
}

/* The clear ("x") button inside the field is an icon-only dx-button, so the flat-teal rule below
   would otherwise style it like a toolbar nav icon. */
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-textbox .dx-icon-clear {
    background: transparent !important;
    color: var(--ad-ink) !important;
}

/* Right-side nav ICONS (view switcher + refresh) — quiet flat teal.
   Scoped to icon-only buttons on purpose: "Clear selection" also lives in toolbar-after
   but carries text, and the transparent treatment left it near-invisible — pale text on a
   pale bar, reading as disabled. */
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-button:not(.dx-button-has-text),
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-buttongroup,
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-buttongroup-item {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-button:not(.dx-button-has-text) .dx-icon {
    color: var(--ad-teal) !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-button:not(.dx-button-has-text):hover {
    background: rgba(42, 154, 175, 0.12) !important;
    border-radius: 6px !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-button:not(.dx-button-has-text):hover .dx-icon {
    color: var(--ad-deep) !important;
}

/* "Clear selection" — a real, legible button, like the unstyled DevExtreme default it was
   drowning out. Same solid weight as Choose on the left so the pair reads as one toolbar. */
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-button.dx-button-has-text {
    background: linear-gradient(180deg, var(--ad-deep), var(--ad-abyss)) !important;
    border: 1px solid rgba(127, 216, 232, 0.55) !important;
    border-radius: 18px !important;
    box-shadow: 0 1px 3px rgba(0, 38, 63, 0.25) !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-button.dx-button-has-text:hover {
    background: linear-gradient(180deg, #156080, #073651) !important;
    border-color: var(--ad-glow) !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-button.dx-button-has-text .dx-button-text,
.dxImagePickerPopupWrapper .dx-filemanager-toolbar .dx-toolbar-after .dx-button.dx-button-has-text .dx-icon {
    color: #ffffff !important;
}

/* Left tree — mist "shore"; selected node carries a teal inset bar */
.dxImagePickerPopupWrapper .dx-filemanager-dirs-panel {
    background: var(--ad-mist) !important;
}

/* The per-row overflow menu (.dx-icon-overflow) stays hidden. Its entries are create / rename /
   delete *for that folder row*, and folder rename and delete are both refused (rollout decision 8) —
   a menu whose two visible actions error is worse than no menu. Creating a subfolder is on the
   toolbar, where CKFinder put it.

   The expand caret is NOT hidden any more. It was, on the premise that "the only nested folders were
   CKFinder's __thumbs caches, which are filtered out — so expanding shows nothing". Decision 8 makes
   that false: users create real subfolders now, at any depth.
   See docs/Core Migration/netcore-ckfinder-callsite-rollout-handoff.md (Slice 8, decision 8). */
.dxImagePickerPopupWrapper .dx-filemanager-dirs-panel .dx-icon-overflow {
    display: none !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-dirs-tree .dx-treeview-node.dx-state-selected > .dx-treeview-item,
.dxImagePickerPopupWrapper .dx-filemanager-dirs-tree .dx-treeview-item.dx-state-selected {
    background: rgba(42, 154, 175, 0.16) !important;
    color: var(--ad-ink) !important;
    box-shadow: inset 3px 0 0 var(--ad-teal) !important;
}

/* File area — barely-there surface→depth gradient ("looking down through water") */
.dxImagePickerPopupWrapper .dx-filemanager-files-view,
.dxImagePickerPopupWrapper .dx-filemanager-thumbnails {
    background: linear-gradient(180deg, #ffffff 0%, #f4fafb 55%, #e9f3f6 100%) !important;
}

/* The item view is sized by flex, not by claiming the whole panel. Without this the List view has no
   scrollbar (SWATV2-3545, reported from staging) — and that is a regression from un-hiding the
   breadcrumbs above.

   ui.file_manager.js:164-166 puts the breadcrumbs and the item view in .dx-filemanager-items-panel,
   a `display:flex; flex-direction:column; height:100%` box. The theme then gives the item view
   `height:100%` of that panel — so with a sibling above it, it overruns the panel by exactly the
   breadcrumb bar's height, and .dx-filemanager-container (`overflow:hidden`) clips the bottom strip.

   Thumbnails never showed it: its inner .dx-filemanager-thumbnails-view-port is `overflow-y:auto`, so
   it scrolls whatever height it is given. The Details view cannot — its dxDataGrid sizes to the
   over-tall element and puts its own scrollbar in the clipped strip, so the grid looks like it simply
   runs off the bottom. While the breadcrumbs were `display:none` the panel had one child and nothing
   overflowed, which is why this only appeared after decision 8.

   `min-height: 0` is the load-bearing half: a flex item defaults to `min-height: auto` and refuses to
   shrink below its content, which would reproduce the overflow even with `flex: 1`.

   ⚠️ Sizing the container is necessary but NOT sufficient, and two earlier attempts failed on that.
   Measured in a standalone harness against this same DevExtreme build: with the container correctly
   sized to 362px, the grid's `.dx-datagrid-rowsview` still rendered at 1488px and no scrollable
   container was created at all. **The DataGrid is in auto-height mode and no CSS reaches it** — it
   takes its height from the `height` *option* or an inline style, neither of which the file manager
   sets, and neither `height:100%` on its element, a `repaint()`, nor setting the option by hand put it
   right.

   So the container does the scrolling instead of the grid, and the header is pinned with
   `position: sticky` so nothing is lost by that. Verified in the harness: scrollTop moves, the full
   row count is reachable, and the Name / Date Modified / File Size row stays put while rows scroll
   under it.

   Only `overflow-y` is opened up; the theme's `overflow:hidden` still governs the horizontal axis, so
   this cannot produce a second horizontal scrollbar competing with the grid's own.

   Scoped to `.dx-filemanager-details` on purpose. Thumbnails has the same over-height, but its
   view-port is `overflow-y:auto` so it scrolls regardless; it works today, and the only thing it loses
   is a sliver at the bottom. Not worth the risk of re-laying-out a view the owner has already signed
   off. */
.dxImagePickerPopupWrapper .dx-filemanager-items-panel > .dx-filemanager-files-view.dx-filemanager-details {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
}

/* The grid grows to its content and the container above scrolls it. */
.dxImagePickerPopupWrapper .dx-filemanager-items-panel > .dx-filemanager-details > div {
    height: auto !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-details .dx-datagrid-headers {
    position: sticky !important;
    top: 0 !important;
    z-index: 2 !important;
}

/* Breadcrumbs are VISIBLE, reversing the rule that used to sit here (rollout decision 8).

   That rule hid them, arguing "the folder tree on the left is the only navigation, which is what
   CKFinder presented (it hid .ckf-folders-breadcrumbs the same way)". Both halves are wrong:
   CKFinder showed a live breadcrumb trail on every popup — "/ Reports Resources / 28665 / images /
   Test images" — and the one .ckf-folders-breadcrumbs hide was a per-site tweak in references.js,
   not the shared behaviour.

   Hiding them is now actively harmful, not merely a lost affordance. The up-arrow lives inside the
   breadcrumb bar and showParentFolder is off, so with the bar hidden a user who opens a subfolder
   from a tile has no way back out except closing the picker.
   See docs/Core Migration/netcore-ckfinder-callsite-rollout-handoff.md (Slice 8, decision 8). */

/* Thumbnails — quiet specimen cards */
.dxImagePickerPopupWrapper .dx-filemanager-thumbnails-item-content {
    border: 1px solid #e0ebee !important;
    border-radius: 8px !important;
    background: #fff !important;
    padding-bottom: 6px !important;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-thumbnails-item-content:hover {
    border-color: var(--ad-teal) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 38, 63, 0.12) !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-thumbnails-item-name {
    color: var(--ad-ink) !important;
    font-family: interstate, Arial, sans-serif !important;
}

.dxImagePickerPopupWrapper .dx-filemanager-thumbnails-item-thumbnail.dx-icon {
    color: var(--ad-teal) !important;
    font-size: 52px !important;
    width: 52px !important;
    height: 52px !important;
}

/* Signature — the selected specimen, lit from the shallows */
.dxImagePickerPopupWrapper .dx-filemanager-thumbnails-item.dx-item-selected .dx-filemanager-thumbnails-item-content,
.dxImagePickerPopupWrapper .dx-filemanager-thumbnails-item[aria-selected="true"] .dx-filemanager-thumbnails-item-content {
    border: 1.5px solid var(--ad-teal) !important;
    box-shadow: 0 0 0 4px rgba(42, 154, 175, 0.28), 0 0 18px 3px rgba(127, 216, 232, 0.95) !important;
    background: linear-gradient(180deg, #ffffff, #e6f7fa) !important;
}

/* ── End Image Picker ───────────────────────────────────────── */
