/**
 * Legacy TopLine autocomplete styling for header Engageware search.
 * Loaded only when TOPLINE_ENGAGEWARE_SEARCH_AUTOCOMPLETE_MODE is 'custom'.
 * Revert: set mode to 'custom' in includes/engageware-search-config.php
 */
/* Hide empty shells only — keep .hdr-search-menu-source visible for Engageware + cloning */
header.site-header .hdr-search .silvercloud-acsearch-bar .sc-autocomplete-items:not(.hdr-search-menu-source):not(.hdr-search-dropdown-live) {
    display: none !important;
    position: absolute !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

header.site-header .hdr-search .silvercloud-acsearch-bar .sc-autocomplete-items.hdr-search-menu-source {
    display: block !important;
    visibility: visible !important;
    pointer-events: none !important;
}

header.site-header .hdr-search .silvercloud-acsearch-bar input::placeholder {
    color: var(--gray-500) !important;
    opacity: 1;
}

/* Hide suggestions when search closed; JS positions live menu when open */
header.site-header .hdr-search-wrap:not(.is-open) .sc-autocomplete-items {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Dropdown anchored to search pill — no viewport fixed math */
header.site-header .hdr-search-wrap.is-open #hdr-search-form {
    overflow: visible !important;
}

header.site-header .hdr-search-wrap.is-open #hdr-search-form .sc-autocomplete-items.hdr-search-dropdown-live {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: absolute !important;
    top: calc(100% + 12px) !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    transform: none !important;
    z-index: 100001 !important;
    background: var(--white) !important;
    border: 1px solid var(--gray-200) !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 32px rgba(12, 35, 51, 0.18) !important;
    max-height: min(560px, calc(100vh - 160px)) !important;
    padding: 8px 0 32px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
}

header.site-header .hdr-search-wrap.is-open .silvercloud-acsearch-bar .sc-autocomplete-items.hdr-search-menu-source {
    display: block !important;
    visibility: visible !important;
}

/* Hide Engageware submit visually but keep clickable for our red button */
header.site-header .hdr-search .silvercloud-acsearch-bar form > button,
header.site-header .hdr-search .silvercloud-acsearch-bar > div > button,
header.site-header .hdr-search .silvercloud-acsearch-bar .sc-search-button,
header.site-header .hdr-search .silvercloud-acsearch-bar [class*="search-btn"]:not(.ui-menu-item):not([role="option"]),
header.site-header .hdr-search .silvercloud-acsearch-bar [class*="SearchButton"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: auto !important;
}

/* Dropdown host on body — JS sets top/left under search pill */
#hdr-search-dropdown-host,
header.site-header .hdr-search-dropdown-host {
    display: none;
    position: fixed;
    margin: 0;
    padding: 0;
    z-index: 100001;
    pointer-events: none;
    box-sizing: border-box;
    transform: none !important;
}

/* Host on body receives cloned menu content; JS sets fixed coords */
body.hdr-search-is-open #hdr-search-dropdown-host:not(:empty) {
    display: block !important;
    pointer-events: auto !important;
    background: var(--white, #fff) !important;
    border: 1px solid var(--gray-200, #e2e8f0) !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 32px rgba(12, 35, 51, 0.18) !important;
    max-height: min(560px, calc(100vh - 160px)) !important;
    padding: 8px 0 32px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
}

#hdr-search-dropdown-host .sc-autocomplete-item {
    display: block !important;
    visibility: visible !important;
    height: auto !important;
    min-height: 52px !important;
    overflow: visible !important;
    opacity: 1 !important;
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--gray-100, #f5f5f5) !important;
}

#hdr-search-dropdown-host .sc-autocomplete-item:last-child {
    border-bottom: none !important;
}

#hdr-search-dropdown-host a.sc-autocomplete-link {
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px !important;
    text-decoration: none !important;
    color: var(--navy, #0c2333) !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
}

#hdr-search-dropdown-host a.sc-autocomplete-link:hover {
    color: var(--red, #D52330) !important;
}

#hdr-search-dropdown-host .sc-autocomplete-icon {
    flex-shrink: 0 !important;
    width: 20px !important;
    height: 20px !important;
    color: var(--gray-500, #737373) !important;
}

#hdr-search-dropdown-host sc-highlight {
    font-weight: 600 !important;
    color: var(--red, #D52330) !important;
}

/* Engageware autocomplete list inside body host */
#hdr-search-dropdown-host .sc-autocomplete-items,
header.site-header .hdr-search-dropdown-host .sc-autocomplete-items {
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: none !important;
    max-height: min(520px, calc(100vh - 180px)) !important;
    margin: 0 !important;
    padding: 8px 0 32px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    background: var(--white) !important;
    border: 1px solid var(--gray-200) !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 32px rgba(12, 35, 51, 0.18) !important;
    z-index: 100000 !important;
    box-sizing: border-box !important;
}

body > .sc-autocomplete-items.hdr-search-dropdown-live .sc-autocomplete-item,
header.site-header .hdr-search-wrap.is-open .sc-autocomplete-item,
#hdr-search-dropdown-host .sc-autocomplete-item,
header.site-header .hdr-search-dropdown-host .sc-autocomplete-item {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border-bottom: 1px solid var(--gray-100) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    white-space: normal !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
}

#hdr-search-dropdown-host .sc-autocomplete-item:last-child,
header.site-header .hdr-search-dropdown-host .sc-autocomplete-item:last-child {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 4px !important;
}

body > .sc-autocomplete-items.hdr-search-dropdown-live a.sc-autocomplete-link,
#hdr-search-dropdown-host a.sc-autocomplete-link,
header.site-header .hdr-search-dropdown-host a.sc-autocomplete-link {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
    padding: 14px 16px !important;
    color: var(--navy) !important;
    text-decoration: none !important;
    font-family: var(--font) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    text-align: left !important;
    cursor: pointer;
    box-sizing: border-box;
}

#hdr-search-dropdown-host a.sc-autocomplete-link span,
header.site-header .hdr-search-dropdown-host a.sc-autocomplete-link span {
    flex: 1 1 auto;
    text-align: left;
    line-height: 1.5;
    overflow: visible;
}

#hdr-search-dropdown-host a.sc-autocomplete-link:hover,
#hdr-search-dropdown-host a.sc-autocomplete-link:focus,
header.site-header .hdr-search-dropdown-host a.sc-autocomplete-link:hover,
header.site-header .hdr-search-dropdown-host a.sc-autocomplete-link:focus {
    background: var(--gray-50, #f8fafc) !important;
}

#hdr-search-dropdown-host .sc-autocomplete-icon,
header.site-header .hdr-search-dropdown-host .sc-autocomplete-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px !important;
    height: 32px !important;
    line-height: 1 !important;
    margin: 0 !important;
    vertical-align: middle;
}

#hdr-search-dropdown-host .sc-autocomplete-icon svg,
header.site-header .hdr-search-dropdown-host .sc-autocomplete-icon svg {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

#hdr-search-dropdown-host sc-highlight,
header.site-header .hdr-search-dropdown-host sc-highlight {
    font-weight: 700;
    font-style: italic;
    background: transparent !important;
}

.hdr-search-suggestions .sc-autocomplete-items,
body.hdr-search-is-open #hdr-search-suggestions .sc-autocomplete-items,
body.hdr-search-is-open .hdr-search-suggestions .sc-autocomplete-items.hdr-search-dropdown-live {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    width: 100% !important;
    max-width: none !important;
    margin: 12px 0 0 !important;
    padding: 8px 0 16px !important;
    background: var(--white) !important;
    border: 1px solid var(--gray-200) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(12, 35, 51, 0.1) !important;
    max-height: min(400px, 50vh) !important;
    overflow-y: auto !important;
    pointer-events: auto !important;
    z-index: 3012 !important;
}

.hdr-search-panel__pill {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    position: relative;
    background: var(--white);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-full);
    padding: 0 18px;
    min-height: 52px;
}

.hdr-search-panel__pill:focus-within {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(12, 35, 51, 0.08);
}

.hdr-search-panel__proxy {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    line-height: 1.5;
    color: #0c2333;
    -webkit-text-fill-color: #0c2333;
    min-height: 44px;
    padding: 10px 0;
    margin: 0;
    position: relative;
    z-index: 2;
    cursor: text;
    pointer-events: auto;
}

.hdr-search-panel__proxy::placeholder {
    color: var(--gray-500);
    opacity: 1;
}

.hdr-search-panel__proxy::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

/* Engageware layer — invisible but sized so API receives keystrokes */
.hdr-search-panel__field--ew {
    position: absolute;
    inset: 0;
    opacity: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 1;
}

.hdr-search-panel__field--ew .silvercloud-acsearch-bar,
.hdr-search-panel__field--ew .silvercloud-acsearch-bar form {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 52px !important;
    overflow: visible !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

.hdr-search-panel__field .silvercloud-acsearch-bar,
.hdr-search-panel__field .silvercloud-acsearch-bar form,
.hdr-search-panel__field .silvercloud-acsearch-bar > div {
    width: 100% !important;
    max-width: none !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    overflow: visible !important;
}

.hdr-search-panel__field .silvercloud-acsearch-bar > .sc-autocomplete-icon,
.hdr-search-panel__field .silvercloud-acsearch-bar form > .sc-autocomplete-icon {
    display: none !important;
}

.hdr-search-panel__field--ew .silvercloud-acsearch-bar input[type="search"],
.hdr-search-panel__field--ew .silvercloud-acsearch-bar input[type="text"] {
    width: 100% !important;
    height: 52px !important;
    opacity: 0 !important;
    padding: 0 18px !important;
    border: none !important;
    pointer-events: none !important;
}

.hdr-search-panel__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 72px;
    height: 52px;
    padding: 0 22px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--red) !important;
    color: #ffffff !important;
    cursor: pointer;
    position: relative;
    z-index: 5;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.hdr-search-panel__submit-text {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

.hdr-search-panel__submit:hover {
    background: var(--red-dark) !important;
}

/* Engageware suggestions — only when panel is open */
.hdr-search-panel.is-open .hdr-search-panel__field .sc-autocomplete-items,
.hdr-search-panel.is-open .sc-autocomplete-items {
    flex: 1 1 100% !important;
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    max-width: none !important;
    margin: 12px 0 0 !important;
    padding: 8px 0 16px !important;
    background: var(--white) !important;
    border: 1px solid var(--gray-200) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(12, 35, 51, 0.1) !important;
    max-height: min(400px, 50vh) !important;
    overflow-y: auto !important;
    z-index: 2 !important;
}

.hdr-search-panel .sc-autocomplete-item,
.hdr-search-suggestions .sc-autocomplete-item {
    display: block !important;
    min-height: 52px !important;
    overflow: visible !important;
}

.hdr-search-panel a.sc-autocomplete-link,
.hdr-search-suggestions a.sc-autocomplete-link {
    display: flex !important;
    align-items: flex-start !important;
    gap: 14px !important;
    padding: 14px 18px 16px !important;
    text-decoration: none !important;
    color: var(--navy) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    overflow: visible !important;
}

.hdr-search-panel a.sc-autocomplete-link:hover,
.hdr-search-suggestions a.sc-autocomplete-link:hover {
    color: var(--red) !important;
    background: var(--gray-50) !important;
}

/* Suggestion row icon — larger than default Engageware size */
.hdr-search-suggestions .sc-autocomplete-icon,
.hdr-search-panel .sc-autocomplete-icon {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    width: 28px !important;
    min-width: 28px !important;
    height: 28px !important;
    margin-top: 2px !important;
    overflow: visible !important;
}

.hdr-search-suggestions .sc-autocomplete-icon svg,
.hdr-search-panel .sc-autocomplete-icon svg {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
}

.hdr-search-suggestions a.sc-autocomplete-link span,
.hdr-search-panel a.sc-autocomplete-link span {
    line-height: 1.5 !important;
    padding-bottom: 2px !important;
}

.hdr-search-panel sc-highlight {
    font-weight: 600;
    color: var(--red);
