/**
 * Searchbox Algolia Widget — Styles
 *
 * Controls the header search toggle behavior, mobile search button,
 * and responsive breakpoints for the Algolia searchbox.
 *
 * @package CBPR_Custom_Multi_Widget
 */

/* ── Search Toggle Wrapper ────────────────────────────────────── */
#header-search-wrapper {
    width: 80vw;
    margin: 0 auto;
    overflow: hidden !important;
    max-height: 0 !important;
    opacity: 0 !important;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

#header-search-wrapper.search-open {
    max-height: 120px !important;
    opacity: 1 !important;
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

/* ── Form Input & Button Height ───────────────────────────────── */
.cbpr-searchbox-algolia-widget .cbpr-search-input,
.cbpr-searchbox-algolia-widget .cbpr-search-submit,
#header-search-wrapper .search-field,
#header-search-wrapper .search-submit {
    height: 44px;
    box-sizing: border-box;
}

/* ── Mobile Search Button ─────────────────────────────────────── */
#mobile-search-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent !important;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    color: #23395E;
    z-index: 99;
}

/*
 * ── Tablet & Mobile: Center the searchbox ────────────────────
 *
 * On tablet/mobile, Elementor uses a flex container (e-con-full)
 * with justify-content: space-between. The search widget gets
 * constrained to a narrow width alongside the logo + nav toggle.
 *
 * Fix: force the widget to take a full row (flex-wrap + flex-basis)
 * and center the form within it.
 */
@media (max-width: 1024px) {

    /* Make the Elementor widget fill the entire flex row */
    .elementor-widget:has(> .elementor-widget-container #header-search-wrapper),
    .elementor-widget-html:has(#header-search-wrapper) {
        flex-basis: 100% !important;
        width: 100% !important;
        order: 99 !important;
    }

    /* Allow the parent flex container to wrap */
    .e-con:has(#header-search-wrapper) {
        flex-wrap: wrap !important;
    }

    /* Center the form inside the full-width wrapper */
    #header-search-wrapper {
        width: 100% !important;
        box-sizing: border-box !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Form takes full width within wrapper */
    #header-search-wrapper #algolia-header-form,
    #header-search-wrapper .cbpr-search-form {
        width: 90vw !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
    }

    #mobile-search-btn {
        display: flex !important;
        position: relative !important;
        margin: 0 15px 0 0 !important;
        flex-shrink: 0 !important;
    }

    .elementor-menu-toggle.elementor-active #mobile-search-btn {
        display: none !important;
    }

    .elementor-menu-toggle {
        display: flex !important;
        align-items: center !important;
        flex-direction: row !important;
        background-color: transparent !important;
        padding: 0 !important;
        border: none !important;
    }

    .elementor-menu-toggle > i {
        background-color: #f1f1f1 !important;
        padding: 8px 12px !important;
        border-radius: 4px !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

@media (max-width: 767px) {
    .search-btn-text {
        display: none !important;
    }
}

/* ── Desktop Toggle Cursor ────────────────────────────────────── */
.header-search-toggle {
    cursor: pointer;
}
