/*
 * FluentBoards 2.0 integration fixes (child theme).
 *
 * The 2.0 UI is an Element-Plus rewrite embedded on the front end through the
 * Pro [fluent_boards] shortcode: FrontendRenderer::renderFrontendShortcode()
 * wraps it in <div class="fluent_boards_frontend fbs_front fbs_page_render">.
 * Site-wide theme/Elementor styles bleed into that box, and 2.0.12's admin.css
 * ships frontend-only rules that change what 1.32 did. Every rule below is
 * scoped to that wrapper or to the Element Plus overlays FB teleports to
 * <body> (.el-overlay dialogs/drawers, .el-popper popovers), so nothing leaks
 * to the rest of the site, to wp-admin, or to the Pro standalone portal
 * (which lacks .fbs_page_render).
 *
 * Cascade: this sheet is printed in <head> BEFORE the plugin CSS (ours is
 * enqueued on wp_enqueue_scripts, FB's during shortcode render), so each
 * override has to win on specificity, never on order. No !important needed.
 * FB 2.0 keeps its Element Plus base styles in @layer element-plus; unlayered
 * theme/Elementor rules beat that layer whatever their specificity, which is
 * where most of the bleed below comes from.
 */

/* 1. Black button outline.
   The theme's global button border (Elementor primary #2e2e2e) lands on
   Element-Plus buttons at rest: on the borderless text/icon variants it draws
   a box FB never intended, and on the rest it repaints the library's own
   border. Restore Element Plus' variable first, then clear the borderless
   variants. Scoped to the embed and to the dialogs, drawers and popovers FB
   teleports to <body> — the task modal (.el-overlay .fbs_view_task_modal)
   lives there, which is why it kept the black boxes. */
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button {
    border-color: var(--el-button-border-color, transparent);
}

:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button.is-text,
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button.is-link,
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button--text,
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button.is-circle,
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .fbs_topbar_icon_btn,
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .fbs_task_modal_nav__btn,
:is(.fluent_boards_frontend, .el-overlay, .el-popper) button[class*="close"],
:is(.fluent_boards_frontend, .el-overlay, .el-popper) button.el-tooltip__trigger {
    border-color: transparent;
}

:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button:focus,
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button:focus-visible {
    outline: none;
}

/* 2. Toolbar logo and menu alignment.
   The site header right above the embed already shows the WW logo, so
   inc/fluentboards.php strips <div class="menu_logo_holder"> from the
   shortcode markup (do_shortcode_tag). The display:none below is only a guard
   in case FluentBoards changes that markup. With the logo gone, the
   Dashboard / Boards / Reports list starts at the left edge of the toolbar
   where the logo used to sit; 2.0.12 centres it (ul.fframe_menu
   {justify-content:center}, 1.32 had it left-aligned next to the logo). The
   off-canvas mobile menu is a separate list and is not affected. */
.fluent_boards_frontend.fbs_page_render .fframe_main-menu-items .menu_logo_holder {
    display: none;
}

.fluent_boards_frontend.fbs_page_render .fframe_main-menu-items ul.fframe_menu {
    justify-content: flex-start;
}

/* 3. Global search button: no border on hover/focus.
   The Elementor kit styles every <button> on hover and focus
   (.elementor-kit-44 button:hover, :focus {border-style:solid; border-width:1px}
   at specificity (0,2,1)), which beats FB's borderless
   .fbs_icon_btn.fbs_global_search{border:none} (0,2,0). The button grew from
   36 to 38px on hover and pushed the whole board down. Pin the borderless
   state for the interactive pseudo-classes as well; colours are unaffected
   because FB's own hover rule already outranks the kit for them. */
.fluent_boards_frontend.fbs_page_render .fbs_icon_btn.fbs_global_search:hover,
.fluent_boards_frontend.fbs_page_render .fbs_icon_btn.fbs_global_search:focus,
.fluent_boards_frontend.fbs_page_render .fbs_icon_btn.fbs_global_search:focus-visible,
.fluent_boards_frontend.fbs_page_render .fbs_icon_btn.fbs_global_search:active {
    border: 0;
}

/* 4. Kanban: per-stage scrolling.
   1.32 gave the board a definite height (.fluentboards_databox{height:calc(100vh
   - 100px)}), so the 100% chain (section_view > scroller > el-row.h-full >
   layout_grid > stage_drag_and_drop > section_board{max-height:100%} >
   fbs_task_group_drag{overflow:auto}) resolved and every column scrolled its
   own list. 2.0.12 admin.css adds .fluent_boards_frontend
   .fluentboards_databox{height:auto} and sizes the wrapper as
   .fbs-board-layout-kanban-view #fbs_tasks_wrapper{height:calc(100% - 56px)};
   percent of auto is auto, so the whole chain collapses to content height, the
   page scrolls instead, and the per-stage lazy loader (handleScroll ->
   fetchStageTasksPage) never fires, so stages with more than one page of tasks
   stay truncated at 20 cards. wp-admin is unaffected because it gets #wpbody
   #fbs_tasks_wrapper{height:calc(100vh - 180px)}; this is the frontend
   equivalent. (0,1,3,0) beats both plugin wrapper rules (0,1,1,0).

   The offset is everything above the wrapper at scroll 0 plus a 14px bottom
   gap. The constants below are the fallback for the usual chrome measured
   locally: WP toolbar 32 + top-bar announcement 103 + fixed header 88 +
   Elementor padding 10 + FB menu 57 + board title bar 56 = 346 (+14 = 360).
   assets/js/fluentboards-fixes.js replaces them with the real measured top
   (inline --ww-fb-kanban-offset on the static .fluent_boards_frontend
   wrapper, which beats the declarations below), so the board fits whatever is
   actually above it. Below 1025px the plugin's own page-scroll
   layout is kept, as on 1.32. Only kanban carries fbs-board-layout-kanban-view;
   list/table/calendar/gantt views, the dashboard and the task modal are not
   touched. */
@media (min-width: 1025px) {
    .fluent_boards_frontend.fbs_page_render {
        --ww-fb-kanban-offset: 360px;
    }

    body:not(.admin-bar) .fluent_boards_frontend.fbs_page_render {
        --ww-fb-kanban-offset: 328px;
    }

    .fluent_boards_frontend.fbs_page_render .fbs-board-layout-kanban-view #fbs_tasks_wrapper {
        height: calc(100vh - var(--ww-fb-kanban-offset, 360px));
        /* overrides the plugin's min-height:calc(100vh - 200px) */
        min-height: 320px;
    }
}

/* 5. Elementor kit hover/focus bleed (dark buttons on hover).
   The kit styles every <button> on hover and focus:
   .elementor-kit-44 button:hover, :focus {color; background-color;
   border-style:solid; border-width:1px; border-color} at (0,2,1).
   FluentBoards 2.0 ships its Element Plus styles inside @layer element-plus,
   and unlayered rules beat layered ones whatever their specificity, so the
   kit turns most FB buttons dark (#2e2e2e, light icons) on hover and keeps
   them dark while focused after a click. Re-apply the intended look from
   unlayered rules that only just outrank the kit, so FB's own stronger
   unlayered rules keep winning. Scoped to the embed and to the dialogs,
   drawers and popovers FB teleports to <body> (.el-overlay / .el-popper). */

/* Element Plus buttons: the library's own variables (normal on focus, hover on hover). */
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button:is(:focus, :focus-visible) {
    color: var(--el-button-text-color);
    background-color: var(--el-button-bg-color);
    border-color: var(--el-button-border-color);
}

:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button:hover {
    color: var(--el-button-hover-text-color);
    background-color: var(--el-button-hover-bg-color);
    border-color: var(--el-button-hover-border-color);
}

/* Borderless variants (text / icon buttons): FB's grey hover, no border box. */
:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button:is(.is-text, .no-border):is(:focus, :focus-visible) {
    color: var(--fbs-secondary-text, #525866);
    background-color: transparent;
    border-width: 0;
}

:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button:is(.is-text, .no-border):hover {
    color: var(--fbs-primary-text, #0e121b);
    background-color: var(--fbs-secondary-bg, #f5f7fa);
    border-width: 0;
}

:is(.fluent_boards_frontend, .el-overlay, .el-popper) .el-button.is-link:is(:hover, :focus, :focus-visible) {
    background-color: transparent;
    border-width: 0;
}

/* FluentBoards' own buttons (priority badge, date trigger, modal nav, profile
   trigger...): FB's grey hover. */
:is(.fluent_boards_frontend, .el-overlay, .el-popper) button:not(.el-button):is(:hover, :focus, :focus-visible) {
    color: var(--fbs-primary-text, #0e121b);
    background-color: var(--fbs-secondary-bg, #f5f7fa);
    border-color: var(--fbs-primary-border, #e1e4ea);
}

/* 6. Theme switcher (Light / Dark / System) hidden.
   A site-wide theme switch is planned separately; until then the FB-only one
   in the toolbar looks detached. inc/fluentboards.php also resets the stored
   choice to light before the app boots, so nobody is left in dark mode. The
   switcher is the el-dropdown wrapper .fbs-theme-mode in
   .fbs-global-action-buttons; its popper is only created on click. */
.fluent_boards_frontend.fbs_page_render .fbs-theme-mode {
    display: none;
}
