/* =========================================
   BFHD Search Section - Rebuilt (bfhd_s_)
   Isolated from legacy theme styles
   ========================================= */

/* --- Container Layout --- */

.bfhd_s_form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    font-family: 'Roboto', sans-serif;
    /* Ensure font lineage */
}

.bfhd_s_wrapper {
    display: flex;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 1200px;
    justify-content: center;
}

.bfhd_s_label {
    font-size: 18px;
    font-weight: 500;
    color: #2D3748;
    white-space: nowrap;
}

/* The White Pill Container */
.bfhd_s_pill {
    display: flex;
    align-items: center;
    background: #FFFFFF;
    padding: 6px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    flex: 1;
    max-width: 900px;
    min-height: 64px;
    /* Ensure height */
    position: relative;
    z-index: 50;
    /* Ensure dropdowns float above */
}

/* Text Input Area */
.bfhd_s_input_group {
    flex: 1.5;
    padding-left: 12px;
}

.bfhd_s_input {
    width: 100%;
    border: none;
    padding: 12px 16px;
    font-size: 15px;
    color: #2D3748;
    background: transparent;
    outline: none;
    font-family: inherit;
}

.bfhd_s_input::placeholder {
    color: #BDBDBD;
}

/* Vertical Separator */
.bfhd_s_separator {
    width: 1px;
    height: 32px;
    background-color: #E2E8F0;
    margin: 0 8px;
}

/* Select Group Wrapper */
.bfhd_s_select_group {
    flex: 1;
    position: relative;
    min-width: 0;
    /* Flexbox fix */
}

/* Search Button */
.bfhd_s_btn {
    width: 52px;
    height: 52px;
    background: #00E2C1;
    /* Primary Teal */
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 2px;
}

.bfhd_s_btn:hover {
    background: #00C4A8;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 226, 193, 0.3);
}

/* Advanced Search Link */
.bfhd_s_advanced {
    color: #8B8B8B;
    text-decoration: none;
    font-size: 15px;
    font-weight: 400;
    white-space: nowrap;
}

.bfhd_s_advanced:hover {
    color: #00E2C1;
    text-decoration: underline;
}


/* --- Choices.js Theme (Scoped to our container) --- */

/* Reset base styles for our context */
.bfhd_s_select_group .choices {
    font-size: 15px !important;
    border: none !important;
    margin-bottom: 0 !important;
    overflow: visible !important;
}

/* Inner Container (Input Box) */
.bfhd_s_select_group .choices__inner {
    background: transparent !important;
    border: none !important;
    padding: 2px 0px 2px 8px !important;
    min-height: 48px !important;
    /* Match adjacent elements */
    border-radius: 0 !important;
    display: flex !important;
    align-items: center !important;
}

/* Focus States */
.bfhd_s_select_group .choices.is-focused .choices__inner,
.bfhd_s_select_group .choices__inner:focus {
    border-color: transparent !important;
    box-shadow: none !important;
}

/* Dropdown Menu */
.bfhd_s_select_group .choices__list--dropdown,
.bfhd_s_select_group .choices__list[aria-expanded] {
    background: #FFFFFF !important;
    border: 1px solid #E8E8E8 !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12) !important;
    margin-top: 10px !important;
    padding: 8px !important;
    z-index: 9999 !important;
    overflow: hidden !important;
    word-break: break-word !important;
}

/* Items */
.bfhd_s_select_group .choices__list--dropdown .choices__item {
    padding: 10px 16px !important;
    border-radius: 10px !important;
    margin: 2px 0 !important;
    font-size: 15px !important;
    color: #4A5568 !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative !important;
    background: transparent !important;
    font-weight: 500 !important;
}

/* Item Hover */
.bfhd_s_select_group .choices__list--dropdown .choices__item--selectable.is-highlighted,
.bfhd_s_select_group .choices__list--dropdown .choices__item--selectable:hover {
    background: #EDF2F7 !important;
    color: #2D3748 !important;
}

/* Selected Item in Dropdown - KEEP VISIBLE for Checklist Behavior */
/* We target multiple variations to ensure we override Choices.js default hiding */
.bfhd_s_select_group .choices__list--dropdown .choices__item.is-selected,
.bfhd_s_select_group .choices__list[aria-expanded] .choices__item.is-selected,
.bfhd_s_select_group .choices__list--dropdown .choices__item--choice.is-selected {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    background-color: #E6F7FF !important;
    /* Ensure background stays */
}

/* Ensure hover state still works on selected items */
.bfhd_s_select_group .choices__list--dropdown .choices__item.is-selected:hover {
    background-color: #D1EEFC !important;
}

/* --- Fixed Height & Summary Styling --- */

/* Hide the default tag list completely */
.bfhd_s_select_group .choices__list--multiple {
    display: none !important;
}

/* New Summary Element */
.bfhd_s_summary {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: #4A5568;
    /* Regular text color */
    pointer-events: none;
    /* Let clicks pass through to input/container */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 30px);
    /* Leave room for arrow */
    z-index: 10;
}

.bfhd_s_summary.is-placeholder {
    color: #A0AEC0;
    /* Placeholder gray */
}

/* Ensure Input is still there but transparent/behind? 
   Actually, Choices.js puts the input inside choices__inner.
   We need the input to be clickable to open dropdown, but visible only when typing?
   Or just cover it with the summary and focus input on click? 
*/
.bfhd_s_select_group .choices__input {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 100% !important;
    width: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    opacity: 0;
    /* Hide input text unless focused? No, we need to see search text */
    cursor: pointer !important;
}

/* When searching (focused and has value), hide summary? 
   Choices.js doesn't easily toggle a class on wrapper when input has value.
   But when dropdown is OPEN, we typically want to see the search input.
*/
.bfhd_s_select_group .choices.is-open .bfhd_s_summary {
    opacity: 0.3;
    /* Fade out summary when searching */
}

.bfhd_s_select_group .choices.is-open .choices__input {
    opacity: 1 !important;
    padding-left: 12px !important;
    /* Restore padding for cursor */
    z-index: 20;
}

/* Make inner container relative for absolute positioning */
.bfhd_s_select_group .choices__inner {
    position: relative !important;
    min-height: 48px !important;
}

/* CSS Arrow */
.bfhd_s_select_group .choices::after {
    content: "" !important;
    height: 8px !important;
    width: 8px !important;
    border-style: solid !important;
    border-color: #A0AEC0 !important;
    border-width: 0 0 2px 2px !important;
    position: absolute !important;
    right: 15px !important;
    top: 50% !important;
    margin-top: -6px !important;
    transform: rotate(-45deg) !important;
    pointer-events: none !important;
    z-index: 1 !important;
}

.bfhd_s_select_group .choices.is-open::after {
    transform: rotate(135deg) !important;
    margin-top: -2px !important;
}

/* --- Styled Checkbox inside Dropdown --- */
.bfhd_s_checkbox {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #CBD5E0;
    /* Gray Border */
    border-radius: 4px;
    margin-right: 12px;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: #FFF;
}

/* Hover on item makes checkbox slightly darker gray */
.choices__item--selectable:hover .bfhd_s_checkbox {
    border-color: #A0AEC0;
}

/* Selected State: Green + Checkmark */
.is-selected .bfhd_s_checkbox {
    background-color: #00E2C1;
    /* Primary Teal */
    border-color: #00E2C1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

/* Ensure text aligns nicely */
.bfhd_s_label_text {
    flex: 1;
}

/* Update Country Count Badge for this context */
.bfhd_s_select_group .bfhd-country-count {
    background: #EDF2F7;
    color: #718096;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.is-selected .bfhd-country-count {
    background: rgba(0, 226, 193, 0.1);
    color: #00E2C1;
}

/* Responsive */
@media (max-width: 992px) {
    .bfhd_s_wrapper {
        flex-direction: column;
    }

    .bfhd_s_pill {
        width: 100%;
        height: auto;
        flex-direction: column;
        padding: 16px;
        border-radius: 24px;
        align-items: stretch;
        gap: 12px;
    }

    .bfhd_s_separator {
        display: none;
    }

    .bfhd_s_input_group,
    .bfhd_s_select_group {
        border-bottom: 1px solid #EDF2F7;
        padding-bottom: 8px;
    }

    .bfhd_s_btn {
        width: 100%;
        border-radius: 12px;
        margin-top: 8px;
    }
}