/* =============================================================================
   Book preview panel (the Book Viewer): AffiniAI, the Search page and Saved Search
   =============================================================================
   Panels opt in with cls `acs-book-preview`. ExtJS creates the split bar and the
   collapsed strip with ids only, so those rules name each panel by id.
   Colours come from --bp-* tokens that default to the main theme (cyan);
   ext-acs-affiniai.css maps them to the AffiniAI purple on body.acs-affiniai.
   ============================================================================= */

/* ── Book viewer panel (east region of chat-bot-view) ────────────────────── */

/* Strip ExtJS default 1px #aeb6be border from the panel body. */
.acs-book-preview .x-panel-body {
    border: none !important;
}

/* Loading: the theme's mask and message box (as on the result lists), on the
   document's grid row instead of Ext's absolute cover, so the header stays usable
   (acs_chat_bot.bookPreview.showLoading). */
.acs-book-preview .book-preview-loading {
    position: static;
    grid-row: 3;
    grid-column: 1;
}

.acs-book-preview .ext-el-mask.book-preview-loading {
    width: auto;
    height: auto;
    z-index: 1;
}

.acs-book-preview .ext-el-mask-msg.book-preview-loading {
    place-self: center;
    z-index: 2;
}

/* ── Book viewer with no book: a hint instead of a blank frame ───────────── */

/* Shares the iframe's grid cell (ext-acs-chat-bot.js). */
.acs-book-preview .book-viewer-empty-hint {
    display: none;
    grid-row: 3;
    grid-column: 1;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--acs-text-secondary, #5a6370);
}

.acs-book-preview .book-viewer-empty .book-viewer-empty-hint {
    display: flex;
}

.acs-book-preview .book-viewer-empty #book-viewer-iframe {
    visibility: hidden;
}

/* Search and open-in-new-window need a book. */
.acs-book-preview .book-viewer-empty .book-viewer-search-btn,
.acs-book-preview .book-viewer-empty .book-viewer-open-new-window-btn {
    display: none !important;
}

/* ── Book viewer split bar: the shared split bar (ext-acs-widgets.css) ──── */
/* AffiniAI recolours its bar in ext-acs-affiniai.css. */

/* The pill closes the panel on click; the bar only resizes here. */
#chat-bot-book-viewer-xsplit .x-layout-mini,
#search-book-preview-xsplit .x-layout-mini,
#saved-search-book-preview-xsplit .x-layout-mini {
    display: none !important;
}

/* With the tab hidden, the grip stays on hover (the shared rule fades it for a tab). */
#search-book-preview-xsplit:hover::after,
#saved-search-book-preview-xsplit:hover::after {
    opacity: 1 !important;
}

/* No control on the right edge while the viewer is closed. Width 0, not
   display none: ExtJS sizes the opening panel from this strip's height. */
#chat-bot-book-viewer-xcollapsed,
#search-book-preview-xcollapsed,
#saved-search-book-preview-xcollapsed {
    width: 0 !important;
    overflow: hidden !important;
}

#chat-bot-book-viewer-xcollapsed::before,
#search-book-preview-xcollapsed::before,
#saved-search-book-preview-xcollapsed::before,
#chat-bot-book-viewer-xcollapsed .x-layout-mini,
#search-book-preview-xcollapsed .x-layout-mini,
#saved-search-book-preview-xcollapsed .x-layout-mini {
    display: none !important;
}

/* Preview header: override the inline border-bottom set in ext-acs-chat-bot.js
   with a themed token, and align background with col-2 surface. */
.acs-book-preview .book-viewer-preview-header {
    background: var(--bp-surface, var(--acs-surface, #f5f7f9)) !important;
    border-bottom: 1px solid var(--bp-border, var(--acs-border, #e2e6ec)) !important;
    padding: 5px 10px !important;
}

/* "Open in new window": no ExtJS 9-slice chrome, only the icon (as in
   ext-acs-startpage.css). */
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-tl,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-tr,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-tc,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-ml,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-mr,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-mc,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-bl,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-br,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-bc,
.acs-book-preview .book-viewer-close-btn .x-btn-tl,
.acs-book-preview .book-viewer-close-btn .x-btn-tr,
.acs-book-preview .book-viewer-close-btn .x-btn-tc,
.acs-book-preview .book-viewer-close-btn .x-btn-ml,
.acs-book-preview .book-viewer-close-btn .x-btn-mr,
.acs-book-preview .book-viewer-close-btn .x-btn-mc,
.acs-book-preview .book-viewer-close-btn .x-btn-bl,
.acs-book-preview .book-viewer-close-btn .x-btn-br,
.acs-book-preview .book-viewer-close-btn .x-btn-bc,
.acs-book-preview .book-viewer-header-btn td {
    background: transparent !important;
    background-image: none !important;
    border: none !important;
}

.acs-book-preview .book-viewer-open-new-window-btn button.icon-external-link {
    -webkit-mask-image: var(--icon-external-link) !important;
            mask-image: var(--icon-external-link) !important;
    -webkit-mask-size: 16px 16px !important;
            mask-size: 16px 16px !important;
    -webkit-mask-position: center !important;
            mask-position: center !important;
    -webkit-mask-repeat: no-repeat !important;
            mask-repeat: no-repeat !important;
    background-image: none !important;
    background-color: var(--acs-text-secondary, #5a6370) !important;
    border: none !important;
}

.acs-book-preview .book-viewer-open-new-window-btn.x-btn-over button.icon-external-link,
.acs-book-preview .book-viewer-open-new-window-btn .x-btn-over button.icon-external-link {
    background-color: var(--bp-accent, var(--acs-brand-cyan, #00aeef)) !important;
}

/* ── Find-in-document search ─────────────────────────────────────────────── */
/* Toggle / step / close buttons all share the icon-mask pattern: strip the
   ExtJS 9-slice chrome and paint the glyph via a mask token, cyan on hover. */
.acs-book-preview .book-viewer-search-btn .x-btn-tl,
.acs-book-preview .book-viewer-search-btn .x-btn-tr,
.acs-book-preview .book-viewer-search-btn .x-btn-tc,
.acs-book-preview .book-viewer-search-btn .x-btn-ml,
.acs-book-preview .book-viewer-search-btn .x-btn-mr,
.acs-book-preview .book-viewer-search-btn .x-btn-mc,
.acs-book-preview .book-viewer-search-btn .x-btn-bl,
.acs-book-preview .book-viewer-search-btn .x-btn-br,
.acs-book-preview .book-viewer-search-btn .x-btn-bc,
.acs-book-preview .book-viewer-search-step-btn,
.acs-book-preview .book-viewer-search-step-btn .x-btn-tl,
.acs-book-preview .book-viewer-search-step-btn .x-btn-tr,
.acs-book-preview .book-viewer-search-step-btn .x-btn-tc,
.acs-book-preview .book-viewer-search-step-btn .x-btn-ml,
.acs-book-preview .book-viewer-search-step-btn .x-btn-mr,
.acs-book-preview .book-viewer-search-step-btn .x-btn-mc,
.acs-book-preview .book-viewer-search-step-btn .x-btn-bl,
.acs-book-preview .book-viewer-search-step-btn .x-btn-br,
.acs-book-preview .book-viewer-search-step-btn .x-btn-bc,
.acs-book-preview .book-viewer-search-close-btn,
.acs-book-preview .book-viewer-search-close-btn .x-btn-tl,
.acs-book-preview .book-viewer-search-close-btn .x-btn-tr,
.acs-book-preview .book-viewer-search-close-btn .x-btn-tc,
.acs-book-preview .book-viewer-search-close-btn .x-btn-ml,
.acs-book-preview .book-viewer-search-close-btn .x-btn-mr,
.acs-book-preview .book-viewer-search-close-btn .x-btn-mc,
.acs-book-preview .book-viewer-search-close-btn .x-btn-bl,
.acs-book-preview .book-viewer-search-close-btn .x-btn-br,
.acs-book-preview .book-viewer-search-close-btn .x-btn-bc,
.acs-book-preview .book-viewer-search-clear-btn,
.acs-book-preview .book-viewer-search-clear-btn .x-btn-mc,
.acs-book-preview .book-viewer-search-run-btn,
.acs-book-preview .book-viewer-search-run-btn .x-btn-mc {
    background: transparent !important;
    background-image: none !important;
    border: none !important;
}

/* The preview-header icons (search toggle, open-in-new-window, close) are
   bordered icon boxes so they read as a matching set, unlike the borderless
   step/close icons inside the find bar. */
.acs-book-preview .book-viewer-search-btn,
.acs-book-preview .book-viewer-open-new-window-btn,
.acs-book-preview .book-viewer-close-btn,
.acs-book-preview .book-viewer-header-btn {
    border: 1px solid var(--bp-border, var(--acs-border, #e2e6ec)) !important;
    border-radius: 4px !important;
    background: transparent !important;
    background-image: none !important;
}

.acs-book-preview .book-viewer-search-btn button.icon-search,
.acs-book-preview .book-viewer-search-step-btn button[class*="icon-chevron"],
.acs-book-preview .book-viewer-search-close-btn button.icon-close,
.acs-book-preview .book-viewer-search-clear-btn button.icon-close,
.acs-book-preview .book-viewer-search-run-btn button.icon-search,
.acs-book-preview .book-viewer-close-btn button.icon-close,
.acs-book-preview .book-viewer-header-btn button {
    -webkit-mask-size: 16px 16px !important;
            mask-size: 16px 16px !important;
    -webkit-mask-position: center !important;
            mask-position: center !important;
    -webkit-mask-repeat: no-repeat !important;
            mask-repeat: no-repeat !important;
    background-image: none !important;
    background-color: var(--acs-text-secondary, #5a6370) !important;
    border: none !important;
}

.acs-book-preview .book-viewer-search-btn button.icon-search,
.acs-book-preview .book-viewer-search-run-btn button.icon-search {
    -webkit-mask-image: var(--icon-search) !important;
            mask-image: var(--icon-search) !important;
}

.acs-book-preview .book-viewer-search-clear-btn button.icon-close,
.acs-book-preview .book-viewer-close-btn button.icon-close {
    -webkit-mask-image: var(--icon-close, var(--icon-x)) !important;
            mask-image: var(--icon-close, var(--icon-x)) !important;
}

/* Another panel's header box (book-viewer-header-btn) names its glyph by iconCls. */
.acs-book-preview .book-viewer-header-btn button.icon-filter-x {
    -webkit-mask-image: var(--icon-filter-x) !important;
            mask-image: var(--icon-filter-x) !important;
}

.acs-book-preview .x-btn.book-viewer-header-btn.x-item-disabled {
    opacity: 0.45 !important;
}

.acs-book-preview .book-viewer-search-step-btn button.icon-chevron-up {
    -webkit-mask-image: var(--icon-chevron-up) !important;
            mask-image: var(--icon-chevron-up) !important;
}

.acs-book-preview .book-viewer-search-step-btn button.icon-chevron-down {
    -webkit-mask-image: var(--icon-chevron-down) !important;
            mask-image: var(--icon-chevron-down) !important;
}

.acs-book-preview .book-viewer-search-close-btn button.icon-close {
    -webkit-mask-image: var(--icon-close, var(--icon-x)) !important;
            mask-image: var(--icon-close, var(--icon-x)) !important;
}

/* Disabled steppers (no matches to step through): faded and not interactive. */
.acs-book-preview .book-viewer-search-step-btn.x-item-disabled {
    opacity: 0.35 !important;
    cursor: default !important;
}
.acs-book-preview .book-viewer-search-step-btn.x-item-disabled button[class*="icon-chevron"] {
    background-color: var(--bp-text-tertiary, var(--acs-text-tertiary, #8c95a0)) !important;
}

/* Toggle turns cyan on hover / while open; steps + close on hover. */
.acs-book-preview .book-viewer-search-btn.x-btn-over button.icon-search,
.acs-book-preview .book-viewer-search-btn .x-btn-over button.icon-search,
.acs-book-preview .book-viewer-search-btn.x-btn-pressed button.icon-search,
.acs-book-preview .book-viewer-search-step-btn.x-btn-over button[class*="icon-chevron"],
.acs-book-preview .book-viewer-search-step-btn .x-btn-over button[class*="icon-chevron"],
.acs-book-preview .book-viewer-search-close-btn.x-btn-over button.icon-close,
.acs-book-preview .book-viewer-search-close-btn .x-btn-over button.icon-close,
.acs-book-preview .book-viewer-search-clear-btn.x-btn-over button.icon-close,
.acs-book-preview .book-viewer-search-clear-btn .x-btn-over button.icon-close,
.acs-book-preview .book-viewer-search-run-btn.x-btn-over button.icon-search,
.acs-book-preview .book-viewer-search-run-btn .x-btn-over button.icon-search,
.acs-book-preview .book-viewer-close-btn.x-btn-over button.icon-close,
.acs-book-preview .book-viewer-close-btn .x-btn-over button.icon-close,
.acs-book-preview .book-viewer-header-btn.x-btn-over button {
    background-color: var(--bp-accent, var(--acs-brand-cyan, #00aeef)) !important;
}

/* All header boxes turn accent-bordered + tinted on hover; the search toggle
   also holds that state while the find bar is open (pressed). The extra .x-btn
   outranks the theme's global deep-cyan hover (STYLING_PATTERNS 1.8). */
.acs-book-preview .x-btn.book-viewer-search-btn.x-btn-over,
.acs-book-preview .x-btn.book-viewer-search-btn.x-btn-pressed,
.acs-book-preview .x-btn.book-viewer-open-new-window-btn.x-btn-over,
.acs-book-preview .x-btn.book-viewer-close-btn.x-btn-over,
.acs-book-preview .x-btn.book-viewer-header-btn.x-btn-over {
    border-color: var(--bp-accent, var(--acs-brand-cyan, #00aeef)) !important;
    background: var(--bp-accent-tint, var(--acs-active-bg, rgba(0, 174, 239, 0.1))) !important;
}

/* The find bar's borderless icons only recolour their glyph on hover. */
.acs-book-preview .x-btn.book-viewer-search-step-btn.x-btn-over,
.acs-book-preview .x-btn.book-viewer-search-close-btn.x-btn-over,
.acs-book-preview .x-btn.book-viewer-search-clear-btn.x-btn-over,
.acs-book-preview .x-btn.book-viewer-search-run-btn.x-btn-over {
    border-color: transparent !important;
    background: transparent !important;
}

/* Space between the header icons (search toggle + open-in-window + close);
   each icon is spaced from the one that follows it. */
.acs-book-preview .book-viewer-preview-header .book-viewer-search-btn,
.acs-book-preview .book-viewer-preview-header .book-viewer-open-new-window-btn,
.acs-book-preview .book-viewer-preview-header .book-viewer-header-btn {
    margin-right: 6px;
}

/* The find bar row: matches the header's surface + border language. */
.acs-book-preview .book-viewer-preview-find-bar {
    background: var(--bp-surface, var(--acs-surface, #f5f7f9));
    border-bottom: 1px solid var(--bp-border, var(--acs-border, #e2e6ec));
    padding: 5px 10px;
}

/* Search field group: the flex item that fills the bar minus the step + close
   cluster. It is the positioning context for the in-field count / clear / search
   controls, which sit over the input's right edge. */
.acs-book-preview .book-viewer-search-field-group {
    position: relative !important;
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: 28px;
}

/* The input fills the group. Right padding reserves room for the two in-field
   icons (clear + search) so typed text never runs under them. */
.acs-book-preview input.book-viewer-search-field {
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    height: 28px;
    border: 1px solid var(--bp-border, var(--acs-border, #e2e6ec));
    border-radius: 4px;
    background: var(--bp-card-bg, var(--acs-card-bg, #ffffff));
    padding: 0 48px 0 10px;
    font-size: 13px;
    color: var(--bp-text-primary, var(--acs-text-primary, #1c2127));
}

.acs-book-preview input.book-viewer-search-field:focus {
    border-color: var(--bp-accent, var(--acs-brand-cyan, #00aeef));
    outline: none;
}

/* Match count: a flex item between the field and the step buttons, not
   inside the field (ExtJS sizing put it behind the input). Zero width when
   empty, so it leaves no gap. */
.acs-book-preview .book-viewer-preview-find-bar .book-viewer-search-count {
    flex: 0 0 auto;
    min-width: 40px;
    text-align: center;
    font-size: 11px;
    color: var(--bp-text-tertiary, var(--acs-text-tertiary, #8c95a0));
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.acs-book-preview .book-viewer-preview-find-bar .book-viewer-search-count:empty {
    display: none;
}

/* The two in-field icons: clear then search, right-anchored inside the input.
   The 22px-tall buttons centre in the 28px field: (28-22)/2 = 3px. */
.acs-book-preview .book-viewer-search-field-group .book-viewer-search-clear-btn {
    position: absolute !important;
    right: 26px;
    top: 3px;
}

.acs-book-preview .book-viewer-search-field-group .book-viewer-search-run-btn {
    position: absolute !important;
    right: 4px;
    top: 3px;
}

/* The active match's stronger fill is set inline in _step_preview_match:
   the highlights are in the viewer iframe, which this file does not reach. */
