#tenderSearchBar {
    width: 100%;
    margin: 0 20%;
    max-width: 1200px;
}

#tenderSearchBar #searchFieldsContainer {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
}

#tenderSearchBar #keywordContainer {
    flex: 1 1 50rem;
    max-width: 50rem;
    min-width: 0;
    border-top-left-radius: 45px;
    border-bottom-left-radius: 45px;
}

#tenderSearchBar #keywordContainer {
    background-color: white;
    border-radius: 12px;
}


#tenderSearchBar #keywordContainer input {
    padding: 8px 8px 8px 1em;
}

#tenderSearchBar #keywordContainer input, #tenderSearchBar #stateSelect, #tenderSearchBar #classificationSelect,
#tenderSearchBar #advancedFilters {
    width: 100%;
    text-align: left;
}

#tenderSearchBar #searchButtonContainer button {
    text-align: center;
    padding: 8px;
    height: 100%;
    width: 100%;
    margin: auto;
}

#tenderSearchBar #keywordContainer input, #tenderSearchBar button {
    width: 100%;
    color: #000000;
    font-size: 22px;
    margin: 0;
    padding: 8px 8px 8px 1em;
    line-height: 2.3;

    & .caretIcon, .filterIndicator {
        margin-left: 0.5em;
        margin-right: 0.5em;
    }
}

/*  What the user typed is the darkest thing in the box, so an empty box with its example reads as
    empty. #767676 is the lightest grey that keeps the example at 4.5:1 on white; Firefox also dims
    placeholders with opacity, hence the reset. */
#tenderSearchBar #keywordContainer input {
    color: #333;
}

#tenderSearchBar #keywordContainer input::placeholder {
    color: #767676;
    opacity: 1;
}

#searchBarKeywords::placeholder {
    color: #737373;
}


/*  The input is transparent and fills #keywordContainer, so the white rounded box the user sees is
    the container. Taking its radius keeps the outline on that shape rather than squared off
    around it. */
#tenderSearchBar #searchBarKeywords:not(:placeholder-shown) {
    outline: var(--content-primary) solid 2px;
    border-radius: inherit;
}

#editSearch {
    border: none;
    border-radius: 6px;
    color: white;
    background-color: var(--content-primary);
}

#tenderSearchBar #searchButtonContainer {
    flex: 0.2 0 11rem;
    background: transparent;
    margin-left: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;

    & #searchButton {
        width: 100%;
        display: inline-block;
        background-color: var(--content-primary);
        border-radius: 12px;
    }

    & button {
        font-size: 22px;
        line-height: 2.3;
        color: white;
    }
}

/*  Search tips: a panel that opens under the keyword field while it has focus, and a popover
    under the info button beside Search. */
#tenderSearchBar #keywordContainer {
    position: relative;
}

#tenderSearchBar .searchTips {
    background-color: white;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
    color: #111827;
    font-size: 14px;
    line-height: 1.4;
    text-align: left;
    z-index: 1000;
}

#tenderSearchBar .searchTipsTitle {
    color: var(--content-primary);
    font-weight: 700;
    margin: 0 0 2px;
}

#tenderSearchBar .searchTipsList {
    margin: 0;
    padding-left: 1.2em;
}

#tenderSearchBar #searchTipsDropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 12px 12px;
    padding: 16px 22px 20px;
}

#tenderSearchBar #keywordContainer:focus-within {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
}

#tenderSearchBar #keywordContainer:focus-within #searchTipsDropdown {
    display: block;
}

#tenderSearchBar #searchTipsToggleContainer {
    position: relative;
    flex: 0 0 auto;
}

/*  Takes the same font size and line height as the Search button, so the two stand the same height. */
#tenderSearchBar #searchTipsToggle {
    width: auto;
    padding: 8px 0 8px 12px;
    color: var(--content-primary);
}

#tenderSearchBar #searchTipsPopover {
    position: absolute;
    top: calc(100% + 4px);
    right: -6px;
    width: 340px;
    max-width: calc(100vw - 24px);
    border-radius: 12px;
    padding: 24px 28px;
}

/*  The pinned bar is a thin strip over the results; the tips stay with the full size bar. The
    dropdown selector carries :focus-within so it outranks the rule that opens it. */
#tenderSearchBar.stuck #keywordContainer:focus-within #searchTipsDropdown,
#tenderSearchBar.stuck #searchTipsToggleContainer {
    display: none;
}

#tenderSearchBar.stuck #keywordContainer:focus-within {
    border-radius: 12px;
    box-shadow: none;
}

.searchDescription {
    font-size: 1.2rem;
    font-weight: 400;
    max-width: 29rem;
    text-align: center;
}

#tenderSearchBar .borderless, #tenderSearchBar button, #tenderSearchBar #classificationDropdownList input {
    border: none;
    background: none;
}

#tenderSearchBar .borderless:focus, #tenderSearchBar button:focus {
    outline: unset;
    box-shadow: unset;
}

#tenderSearchBar .caretIcon {
    border-top: .7em solid;
    border-right: .4em solid transparent;
    border-bottom: 0;
    border-left: .4em solid transparent;
}

#tenderSearchBar #stateDropdown, #tenderSearchBar #classificationDropdownList,
#tenderSearchBar #advancedFiltersDropdown {
    font-size: 18px;
    color: #737373;
    margin-top: 40px;
}

#tenderSearchBar #stateDropdown {
    min-width: 240px;
    border-radius: 10px;
}

#tenderSearchBar #stateDropdown div.row {
    width: 100%;
    margin: 10px 0;
    align-items: center;
}

#stateDropdown li div.row:hover {
    background-color: #e6e6e6;
}

#tenderSearchBar #stateDropdown div.row label {
    justify-content: space-between;
    align-items: center;
    cursor:pointer;
}

#tenderSearchBar #stateDropdown .switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

#tenderSearchBar #stateDropdown .switch span {
    display: block;
    font-size: 22px;
}

#tenderSearchBar #stateDropdown .slider {
    color: #b8b8b8;
    margin-left: 10px;
}

#tenderSearchBar #stateDropdown .dropdown-toggle::after {
    content: none;
}

#tenderSearchBar #stateDropdown input:checked ~ .slider {
    color: #19ACEE;
}

#tenderSearchBar #stateDropdown input + span {
    color: #b8b8b8;
}

#tenderSearchBar #stateDropdown input:checked + span, #tenderSearchBar #stateDropdown .ul.sub-region-menu li.active span {
    color: #737373;
}

#tenderSearchBar #classificationDropdownList {
    border-radius: 10px;
    max-width: 500px;
}


#tenderSearchBar #classificationDropdownList #hierarchy {
    max-height: 400px;
    overflow-y: scroll;
}


#tenderSearchBar #classificationDropdownList #unspscSearch {
    padding-top: 10px;
}

#tenderSearchBar #classificationDropdownList #tenderCategories {
    list-style-type: none;
    padding: 0 0 11px 0;
    width: 224px;
    margin-left: 10px;
}

#tenderSearchBar #classificationDropdownList #tenderCategories li:first-child {
    border-top: 1px solid #838383;
    padding-top: 10px;
}

#tenderSearchBar #classificationDropdownList #tenderCategories li input[type='text'] {
    padding-left: 0;
    padding-right: 1px;
    text-overflow: ellipsis;
}

#tenderSearchBar #classificationDropdownList #tenderCategories button.btn-outline-secondary {
    padding-right: 0;
    padding-left: 0;
}

#tenderSearchBar #advancedFiltersDropdown {
    border-radius: 15px;
    max-width: 364px;
    padding: 1%;
}

#tenderSearchBar #advancedFiltersDropdown h3 {
    font-size: 18px;
}

#tenderSearchBar #advancedFiltersDropdown #advanced-settings label {
    padding-left: 0;
    font-size: 16px;
}

#tenderSearchBar #advancedFiltersDropdown #advanced-settings label[for="searchMyCategories"] {
    font-size: 14px;
}

#tenderSearchBar #advancedFiltersDropdown div.input-group-text {
    background-color: white;
    margin-bottom: 10px;
    border: 1px solid #aaa;
}

#tenderSearchBar #advancedFiltersDropdown i {
    color: #19ACEE;
}

#tenderSearchBar #advancedFiltersDropdown select, #tenderSearchBar #advancedFiltersDropdown input {
    margin-bottom: 10px;
}

#tenderSearchBar #advancedFiltersDropdown #advanced-settings div.form-switch {
    margin-top: 2px;
    margin-left: 10px;
}

#tenderSearchBar #advancedFiltersDropdown #doneBtn, #tenderSearchBar #stateDropdown #selectAllBtn {
    height: 38px;
    background-color: #19acee;
    color: white;
    border-radius: 30px;
    border: unset;
    font-size: 14px;
    font-weight: normal;
    float: right;
}

#tenderSearchBar #stateDropdown #selectAllBtn {
    min-width: 100px;
}

#tenderSearchBar #classificationDropdownList #unspscSearch {
    width: 246px!important;
}

#tenderSearchBar #classificationDropdownList #tenderCategories {
    width: 226px;
}

.filterIndicator {
    display: none;
    background-color: var(--content-primary);
    color: white;
}

#stateContainer.active {
    box-shadow: inset 0 0 0 2px var(--content-primary);

    & .caretIcon {
        display: none;
    }

    & .filterIndicator {
        display: block;
    }
}

#classificationContainer.active {
    box-shadow: inset 0 0 0 2px var(--content-primary);

    & .caretIcon {
        display: none;
    }

    & .filterIndicator {
        display: block;
    }
}

#hierarchy .selected > .node {
    background-color: unset;
}

#advancedSearchLink {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

#advancedSearchLink.advancedSearchActive,
.search-link {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--content-primary);
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
    text-decoration: none;
}

#advancedSearchLink .advancedSearchIndicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    background-color: var(--content-primary);
    color: white;
    font-size: 10px;
}

@media (max-width: 1399px) {
    #tenderSearchBar {
        padding: 0 10%;
    }
}

@media (max-width: 1199px) {
    #tenderSearchBar #keywordContainer {
        flex: 1 0 80%;
        order: 0;
    }

    #tenderSearchBar #searchButtonContainer {
        margin-left: 1em;
        order: 1;
    }
}

@media (max-width: 767px) {
    /* The 20% side margins are desktop framing; on a phone they leave the bar too narrow and
       overflow the page. */
    #tenderSearchBar {
        margin: 0;
        padding: 0 12px;
    }

    /* The keyword field and the button stay on one row, the field taking whatever is left. */
    #tenderSearchBar #searchFieldsContainer {
        flex-wrap: nowrap;
        align-items: stretch;
    }

    #tenderSearchBar #keywordContainer {
        flex: 1 1 auto;
        max-width: none;
    }

    #tenderSearchBar #searchButtonContainer  {
        flex: 0 0 auto;
        margin-top: 0;
        margin-left: 8px;
    }

    /* 22px does not leave room for both on a narrow row. */
    #tenderSearchBar #keywordContainer input,
    #tenderSearchBar #searchButtonContainer button,
    #tenderSearchBar #searchTipsToggle {
        font-size: 1rem;
        line-height: 1.8;
    }

    #tenderSearchBar #searchTipsToggle {
        padding-left: 8px;
    }
}

@media (max-width: 575px) {
    #advancedSearchLink.advancedSearchActive,
    .search-link {
        font-size: 0.75rem;
    }

    #tenderSearchBar #keywordContainer input,
    #tenderSearchBar #searchButtonContainer button,
    #tenderSearchBar #searchTipsToggle {
        font-size: 0.875rem;
    }

    #tenderSearchBar #searchButtonContainer button {
        padding-left: 1em;
        padding-right: 1em;
    }
}
/*  ---------------------------------------------------------------------------------------------
    Pinned search bar

    Once the bar has been scrolled past, stickySearchBar.js takes it out of the flow and it pins
    itself to the top of the viewport in a compact form, so a new search stays reachable however
    far down the results the user is. #searchBarStickyHost holds the bar's place while it is gone.
    --------------------------------------------------------------------------------------------- */

/*  The bar is centred in #headerContainer's column; the host stands in for it there, so it
    centres the bar the same way. */
#searchBarStickyHost {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/*  A box for the observer to watch, marking the bottom of the header band - see stickySearchBar.js
    for why the bar pins there rather than at its own edge. Positioned against the band's bottom
    edge rather than left in the flow, where it would sit above the band's bottom padding and pin
    the bar while that padding is still on screen. Stretched across because an observer is never
    told about a target with no area. */
#headerContainer {
    position: relative;
}

.searchBarStickySentinel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
}

#tenderSearchBar.stuck {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /*  Over the results and the filters beside them, under the notification band, which is
        Bootstrap's .sticky-top at 1020. */
    z-index: 1019;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 16px 20px;
    /*  The same blue as the header band the bar sits in, so it reads as that band following the
        user down rather than as a new piece of chrome. */
    background-color: #cceffc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

/*  Full width band, page width contents: the bar keeps the measure it had in the header rather
    than stretching across the screen.

    One row at every width, too. The full size bar wraps the button under the keyword field as it
    narrows, which is right for a bar the page is built around; here it would double the height of
    a strip whose whole point is to be thin. The keyword field takes whatever the button leaves. */
#tenderSearchBar.stuck #searchFieldsContainer {
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: nowrap;
    align-items: center;
}

/*  Compact while pinned. At full size the bar is the page's centrepiece; here it is a strip laid
    over the results, and every pixel it takes is a result the user cannot see. */
#tenderSearchBar.stuck #keywordContainer input,
#tenderSearchBar.stuck #searchButtonContainer button {
    font-size: 1rem;
    line-height: 1.9;
}

/*  The advanced search link stacks under the button at full size; a second row is exactly what
    this bar cannot afford, so it moves in beside it. */
#tenderSearchBar.stuck #searchButtonContainer {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

/*  Both are sized to fill the column they stack in; on one row they take only what they need. */
#tenderSearchBar.stuck #searchButton,
#tenderSearchBar.stuck #searchButtonContainer button {
    width: auto;
}

#tenderSearchBar.stuck #searchButtonContainer button {
    padding-left: 1.5em;
    padding-right: 1.5em;
}

#tenderSearchBar.stuck #advancedSearchLink {
    margin-top: 0;
    margin-bottom: 0;
    white-space: nowrap;
}

/*  Dropped in from above rather than appearing, so it is clear the bar has come with the user
    instead of being a second bar that was always there. */
@media (prefers-reduced-motion: no-preference) {
    #tenderSearchBar.stuck {
        animation: searchBarDropIn .2s ease-out;
    }
}

@keyframes searchBarDropIn {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

/*  After the sizing above, so the narrow screen bar is not left larger pinned than it is in the
    page. */
@media (max-width: 575px) {
    #tenderSearchBar.stuck {
        padding: 6px 12px;
    }

    #tenderSearchBar.stuck #keywordContainer input,
    #tenderSearchBar.stuck #searchButtonContainer button {
        font-size: 0.875rem;
    }

    #tenderSearchBar.stuck #searchButtonContainer button {
        padding-left: 1em;
        padding-right: 1em;
    }
}

/*  The tip under the keyword box. Its row copies the sizing of #searchFieldsContainer, with the spacer
    taking the button's place, so the tip starts where the box's text does. */
#tenderSearchBar #searchBarHintRow {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

#tenderSearchBar #searchBarKeywordsHint {
    flex: 1 1 50rem;
    max-width: 50rem;
    min-width: 0;
    margin: 6px 0 0;
    /* Matches the input's 1em left padding at its 22px font. */
    padding-left: 22px;
    font-size: 14px;
    color: #5f5f5f;
}

#tenderSearchBar .searchBarHintSpacer {
    flex: 0.2 0 11rem;
    margin-left: 8px;
}

/*  The pinned bar is kept to one thin row. */
#tenderSearchBar.stuck #searchBarHintRow {
    display: none;
}

@media (max-width: 1199px) {
    #tenderSearchBar #searchBarKeywordsHint {
        flex: 1 0 80%;
    }

    #tenderSearchBar .searchBarHintSpacer {
        margin-left: 1em;
    }
}

@media (max-width: 767px) {
    #tenderSearchBar #searchBarHintRow {
        flex-wrap: nowrap;
    }

    /* The row fills the bar here, so the tip only has to start at its left edge. */
    #tenderSearchBar #searchBarKeywordsHint {
        flex: 1 1 auto;
        max-width: none;
        padding-left: 1rem;
        font-size: 13px;
    }

    #tenderSearchBar .searchBarHintSpacer {
        display: none;
    }
}

@media (max-width: 575px) {
    #tenderSearchBar #searchBarKeywordsHint {
        padding-left: 0.875rem;
    }
}
