/* ============================================================================
   JbfHtmlEditor - single-row toolbar + scrollable body + fullscreen
   --------------------------------------------------------------------------
   Three layout goals:
     1. Toolbar stays on ONE row regardless of host panel width (Hero, FAQ,
        Waivers, Content blocks, Announcements, ChecklistAdmin, etc).
     2. Toolbar stays at the **top of the editor box** (flex column - it is NOT
        inside the scrolling region). Only `.rz-html-editor-content` scrolls.
        Do NOT use `position:sticky` on the toolbar: it sticks to the **page**
        scroll and overlaps app headers + the first lines of the editor body.
     3. The fullscreen icon flips the wrapper to a fixed overlay at z-index
        9000 with body scroll locked by JS - ESC and a re-press both exit.
   The .jbf-html-editor wrapper carries width:100% so each call site lays it
   out as wide as its container. min-width:0 prevents flex parents from
   forcing the editor to over-width. The toolbar row uses overflow-x:auto on
   narrow cards; Align/Indent popups are position:fixed via jbf-rte-fullscreen.js
   so they are not clipped by that scrollport.
   ========================================================================== */

.jbf-html-editor {
    display: block;
    width: 100%;
    min-width: 0;
}

.jbf-html-editor .rz-html-editor {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-height: min(60vh, 480px);
    box-sizing: border-box;
    /* Allow toolbar flyouts to extend over the body; only the body scrolls. */
    overflow: visible;
}

.jbf-html-editor .rz-html-editor-toolbar {
    position: relative;
    /* Sit above .rz-html-editor-content so toolbar chrome + fixed flyouts paint
       over the scrollable body when needed. */
    z-index: 1;
    flex: 0 0 auto;
    /* Radzen Material defaults flex-wrap:wrap - forces a second toolbar row. */
    flex-wrap: nowrap !important;
    /* No scroll - jbfRte.density (jbf-rte-fullscreen.js) downgrades the
       editor's data-density attribute (wide → compact → narrow) until the
       row fits, pushing surplus buttons into the More (kebab) popover. The
       overflow:hidden here is just a paint-time safety net during the brief
       window before the first ResizeObserver tick lands. Align/Indent/More
       popups use position:fixed and are portaled to <body>, so they are
       not clipped by this. */
    overflow-x: hidden;
    overflow-y: hidden;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.jbf-html-editor .rz-html-editor-content {
    position: relative;
    z-index: 0;
    /* Honors the optional MinHeight parameter on JbfHtmlEditor so FAQ and
       testimonial editors can request a roomier canvas than Radzen's default 160px. */
    min-height: var(--jbf-rte-min-height, 160px);
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Slim toolbar density (default) - single-row friendly */
.jbf-html-editor--slim .rz-html-editor-toolbar {
    gap: 2px;
    padding: 4px 6px;
    min-height: auto;
}

.jbf-html-editor--slim .rz-html-editor-toolbar .rz-button {
    min-width: 2rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    flex: 0 0 auto;
}

.jbf-html-editor--slim .rz-html-editor-toolbar .rz-dropdown,
.jbf-html-editor--slim .rz-html-editor-toolbar .rz-colorpicker {
    height: 2rem;
    flex: 0 0 auto;
}

.jbf-html-editor--slim .rz-html-editor-toolbar .rz-dropdown .rz-inputtext,
.jbf-html-editor--slim .rz-html-editor-toolbar .rz-colorpicker .rz-inputtext {
    min-height: 2rem;
    padding-top: 0;
    padding-bottom: 0;
}

/* ── Fullscreen overlay ────────────────────────────────────────────────────
   The shell flips to position:fixed; the inner editor stretches to fill the
   viewport. Toolbar stays in normal flow above the scrollable body (same as
   inline mode - no viewport-sticky toolbar). Body scroll is locked from JS
   (jbf-rte-fullscreen.js) so the page beneath does not rubber-band. */
.jbf-rte-fs-shell.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: #ffffff;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.jbf-rte-fs-shell.is-fullscreen .jbf-html-editor,
.jbf-rte-fs-shell.is-fullscreen .rz-html-editor {
    height: 100%;
    max-height: 100%;
    flex: 1 1 auto;
}

/* ── Toolbar group dropdowns (Align / Indent) ──────────────────────────────
   Replacements for the 5 Radzen Align/Indent buttons; each renders a single
   trigger + dropdown popup so the toolbar fits on one row. */
.jbf-rte-group {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.jbf-rte-group-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 2px 0 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: rgba(0, 0, 0, 0.54);
    height: 2rem;
    border-radius: 4px;
}
.jbf-rte-group-trigger:hover,
.jbf-rte-group-trigger.is-open {
    background: rgba(0, 0, 0, 0.06);
    color: rgba(0, 0, 0, 0.87);
}
.jbf-rte-group-trigger:focus-visible {
    outline: 2px solid rgba(125, 91, 129, 0.5);
    outline-offset: -2px;
}
.jbf-rte-group-trigger .rzi {
    font-size: 1rem;
    line-height: 1;
}
.jbf-rte-group-caret {
    font-size: 0.95rem !important;
    margin-left: -2px;
    opacity: 0.85;
}

.jbf-rte-group-popup {
    /* Default until jbfRte.toolbarFlyout.pin sets position:fixed + coordinates */
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    min-width: 140px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(2, 25, 34, 0.14);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.jbf-rte-group-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #1f2937;
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    width: 100%;
}
.jbf-rte-group-item:hover {
    background: rgba(125, 91, 129, 0.08);
    color: #4a3450;
}
.jbf-rte-group-item .rzi {
    font-size: 1rem;
    color: rgba(0, 0, 0, 0.6);
}
.jbf-rte-group-item:hover .rzi {
    color: #7d5b81;
}

/* Active state - set by jbfRte.menu.refreshActive based on
   document.queryCommandState. Slightly stronger than :hover so a row that's
   both hovered and active still reads as active. Keep weight bump subtle so
   menu rows don't visually "jump" between bold and regular widths. */
.jbf-rte-group-item.is-active {
    background: rgba(125, 91, 129, 0.16);
    color: #4a3450;
    font-weight: 600;
}
.jbf-rte-group-item.is-active .rzi {
    color: #7d5b81;
}

/* Keyboard shortcut hint, right-aligned via margin-left:auto. Monospace +
   muted color so it doesn't compete with the label. */
.jbf-rte-group-item-kbd {
    margin-left: auto;
    padding-left: 24px;
    font-size: 0.7rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: rgba(0, 0, 0, 0.42);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.jbf-rte-group-item:hover .jbf-rte-group-item-kbd,
.jbf-rte-group-item.is-active .jbf-rte-group-item-kbd {
    color: rgba(125, 91, 129, 0.7);
}

/* ── Inline format buttons (Radzen native B / I / U / UL / OL) ────────────
   These are RadzenHtmlEditorBold/Italic/Underline/UnorderedList/OrderedList
   rendered directly by Radzen - they carry their own active-state highlight
   (rz-state-active class wired up by Radzen's selection-change handler) and
   self-preventDefault on mousedown so the caret stays inside the editor when
   clicked (Pre-set formatting case). The density classes that let
   them collapse into the More popover at narrow widths are applied by JS
   (jbfRte.density.attach → tagNativeButtons) by matching each button's
   <i class="rzi"> ligature name. The .jbf-rte-density-XXX selectors lower
   in this file then key off [data-density] to show/hide them. */

/* ── More menu ("A" formatting) trigger ───────────────────────────────────
   Shares .jbf-rte-group-trigger styles for hover/focus; .jbf-rte-more-trigger
   only adds layout-specific tweaks. Force a 2rem square (matching the inline
   B/I/U/UL/OL buttons + Radzen's other icon buttons) so the A doesn't sit
   off-center with extra left padding inherited from .jbf-rte-group-trigger.
   The text_format glyph reads small at the default 16px Material weight, so
   bump it up a hair so the affordance has the same visual weight as adjacent
   toolbar buttons. */
.jbf-rte-more-trigger {
    width: 2rem;
    padding: 0;
    justify-content: center;
}

.jbf-rte-more-trigger .rzi {
    font-size: 20px;
    line-height: 1;
}

/* ── More popover ─────────────────────────────────────────────────────────
   Vertical menu portaled into <body> by jbfRte.toolbarFlyout.pin. Items are
   reused .jbf-rte-group-item buttons; .jbf-rte-more-sep gives visual breaks
   between B/I/U, list, align, and indent groups. */
.jbf-rte-more-popup {
    min-width: 180px;
}
.jbf-rte-more-sep {
    height: 1px;
    margin: 4px 6px;
    background: #e5e7eb;
}

/* ── Density-driven visibility ────────────────────────────────────────────
   The wrapper carries data-density set by jbfRte.density (ResizeObserver on
   the toolbar). Inline cluster buttons are hidden when the toolbar is too
   narrow to host them; matching items in the More popover (which also
   carries data-density via data-density-source mirror) become visible
   instead. Default (no attribute) treats the editor as wide so first paint
   isn't empty before the observer fires.

   Breakpoints (set in jbf-rte-fullscreen.js):
     wide    >= 540px : everything inline; popover holds align + indent only
     compact 380-540  : B I U inline; popover holds UL OL + align + indent
     narrow  <  380   : nothing inline; popover holds all secondary actions   */

/* Hide inline buttons that overflow at the current density */
.jbf-html-editor[data-density="narrow"]  .jbf-rte-density-bold,
.jbf-html-editor[data-density="narrow"]  .jbf-rte-density-italic,
.jbf-html-editor[data-density="narrow"]  .jbf-rte-density-underline,
.jbf-html-editor[data-density="narrow"]  .jbf-rte-density-ul,
.jbf-html-editor[data-density="narrow"]  .jbf-rte-density-ol,
.jbf-html-editor[data-density="compact"] .jbf-rte-density-ul,
.jbf-html-editor[data-density="compact"] .jbf-rte-density-ol {
    display: none !important;
}

/* Inverse: hide the More-popover twin whenever the inline button is visible.
   The popup is portaled into <body>, so we key off its own data-density
   (mirrored from the wrapper by jbfRte.density.sync via data-density-source). */
.jbf-rte-more-popup[data-density="wide"]    .jbf-rte-density-bold,
.jbf-rte-more-popup[data-density="wide"]    .jbf-rte-density-italic,
.jbf-rte-more-popup[data-density="wide"]    .jbf-rte-density-underline,
.jbf-rte-more-popup[data-density="wide"]    .jbf-rte-density-ul,
.jbf-rte-more-popup[data-density="wide"]    .jbf-rte-density-ol,
.jbf-rte-more-popup[data-density="compact"] .jbf-rte-density-bold,
.jbf-rte-more-popup[data-density="compact"] .jbf-rte-density-italic,
.jbf-rte-more-popup[data-density="compact"] .jbf-rte-density-underline {
    display: none !important;
}

/* Hide the list-section separator in the popover when its UL/OL items are
   themselves hidden (wide density), so we don't render a stray rule line. */
.jbf-rte-more-popup[data-density="wide"] .jbf-rte-density-list-sep {
    display: none !important;
}

/* Fullscreen toggle button - same hover affordance as native Radzen tools */
.jbf-rte-fullscreen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.54);
}
.jbf-rte-fullscreen-btn:hover {
    color: rgba(0, 0, 0, 0.87);
}
.jbf-rte-fullscreen-btn[aria-pressed="true"] {
    color: #7d5b81;
}

/* Custom image toolbar button - uses Radzen's native .rz-html-editor-button
   class so sizing/spacing matches the built-in tool buttons (Bold, Link, etc.).
   We only need to make sure the icon glyph renders centred. */
.jbf-rte-img-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.jbf-rte-img-btn .rzi {
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* -- Rich text editor image upload dialog -------------------------------- */

.rte-img-dialog {
    padding: 0.25rem 0;
    min-width: 480px;
}

.rte-img-dialog-hint {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0 0 1rem;
}

/* Preview after successful upload */
.rte-img-preview-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.875rem;
}

.rte-img-preview-img {
    max-width: 100%;
    max-height: 260px;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.rte-img-replace-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.rte-img-replace-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

/* Alt text field */
.rte-img-alt-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.25rem;
}

.rte-img-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
}

.rte-img-label-hint {
    font-weight: 400;
    color: #9ca3af;
    margin-left: 0.25rem;
}

.rte-img-alt-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #111827;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.rte-img-alt-input:focus {
    border-color: #7d5b81;
    box-shadow: 0 0 0 3px rgba(125, 91, 129, 0.12);
}

/* Dialog action buttons
   Scoped under .rte-img-dialog to win over Radzen Material theme resets
   that sit inside .rz-dialog-content */
.rte-img-dialog .rte-img-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.rte-img-dialog .rte-img-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem !important;
    border-radius: 6px !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: background 0.15s, box-shadow 0.15s;
    line-height: 1 !important;
}

.rte-img-dialog .rte-img-btn--cancel {
    background: #f3f4f6 !important;
    color: #374151 !important;
    border: 1px solid #d1d5db !important;
    box-shadow: none !important;
}

.rte-img-dialog .rte-img-btn--cancel:hover {
    background: #e5e7eb !important;
}

.rte-img-dialog .rte-img-btn--insert {
    background: #7d5b81 !important;
    color: #fff !important;
    border: none !important;
}

/* Inverted hover: white background + primary text/border. Matches the app-
   wide primary-button hover treatment (see event-landing, local-website,
   fsc-library, image-picker for the same rule). */
.rte-img-dialog .rte-img-btn--insert:hover {
    background: #ffffff !important;
    color: #7d5b81 !important;
    border: 1px solid #7d5b81 !important;
    box-shadow: 0 2px 6px rgba(125, 91, 129, 0.3) !important;
}


/* Align RadzenHtmlEditorCustomTool wrapper as a proper flex child in the toolbar
   so our button lines up vertically with the built-in tool buttons.
   Radzen renders this as <div class="rz-html-editor-custom-tool"> (NOT a custom
   element) - selector MUST start with '.'. The 8px padding matches the internal
   padding Radzen applies to its native tool buttons; without it the wrapper sits
   flush to its inner button and looks taller / offset versus the neighbours. */
.rz-html-editor-toolbar .rz-html-editor-custom-tool,
.rz-html-editor-custom-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    box-sizing: border-box;
    /* Do not create a second clip box for the inline flyout */
    overflow: visible;
}

/* Match the icon glyph colour to native toolbar icons (Radzen Material) */
.jbf-rte-img-btn .rzi {
    font-size: 1rem;
    color: rgba(0, 0, 0, 0.54);
}
.jbf-rte-img-btn:hover .rzi {
    color: rgba(0, 0, 0, 0.87);
}

/* Floating image resize grip (rte-image-editor.js) - hover via CSS only (no JS) to avoid flicker */
button.jbf-rte-resize-handle:hover {
    background: rgba(125, 91, 129, 0.1) !important;
    color: #7d5b81 !important;
    box-shadow: 0 2px 8px rgba(2, 25, 34, 0.16) !important;
}

button.jbf-rte-resize-handle:focus-visible {
    outline: 2px solid rgba(125, 91, 129, 0.45);
    outline-offset: 2px;
}

/* Floating image delete trash icon (rte-image-editor.js) - paired with the
   resize grip in the bottom-right toolbox. Hover is CSS-only to match the
   resize handle and avoid the flicker that JS-driven hover would cause when
   the pointer crosses between the two controls. Uses the app's red token for
   hover so the destructive intent reads at a glance. */
button.jbf-rte-delete-handle:hover {
    background: rgba(216, 15, 61, 0.1) !important;
    color: var(--jbf-red, #d80f3d) !important;
    box-shadow: 0 2px 8px rgba(2, 25, 34, 0.16) !important;
}

button.jbf-rte-delete-handle:focus-visible {
    outline: 2px solid rgba(216, 15, 61, 0.45);
    outline-offset: 2px;
}

/* xs/sm tier (max-width 767.98px mirrors --bp-md). Media queries can't deref CSS vars.
   Enable horizontal scrolling on mobile so users can access all toolbar options. */
@media (max-width: 767.98px) {
    .jbf-html-editor .rz-html-editor-toolbar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Prevent bounce on horizontal scroll edges */
        overscroll-behavior-x: contain;
        /* Show scrollbar hint */
        scrollbar-width: thin;
    }
    
    /* Ensure toolbar items don't shrink below their natural size */
    .jbf-html-editor .rz-html-editor-toolbar > * {
        flex-shrink: 0;
    }
}

/* JbfRightPanel context (container-name "rp", inline-size).
   When the editor is rendered inside a narrow side-panel (e.g. Local Website
   Charity / Hero / Photo Gallery edit panels, EventChecklistDialog ticket /
   coupon panels) on a desktop viewport, the @media rule above does NOT fire
   because the viewport itself is wide. The density observer (jbfRte.density)
   collapses Bold / Italic / UL / OL into the More menu, but the toolbar still
   carries non-collapsable items (Font, Font size, Color, Link, Image, Library,
   Source, Fullscreen) that overflow a ~400-600px panel. Container query mirrors
   the mobile rule so the toolbar scrolls horizontally inside the panel without
   touching the frozen desktop layout for full-width editors (FAQ Answer, About
   Valet Program, Owner Bio - those live in the wide main column). */
@container rp (max-width: 700px) {
    .jbf-html-editor .rz-html-editor-toolbar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
    }

    .jbf-html-editor .rz-html-editor-toolbar > * {
        flex-shrink: 0;
    }
}
