/* Container styling for the custom search select */
.custom-select-wrapper {
    position: relative;
    width: 100%;
    display: block;
}

.custom-select-wrapper.open,
.custom-select-wrapper:has(.custom-select-dropdown.show) {
    z-index: 1080 !important;
}

/* Stylized trigger button resembling a standard form-select */
.custom-select-trigger {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-height: 42px !important;
    height: auto !important;
    padding: 0.5rem 2.5rem 0.5rem 0.875rem !important;
    font-size: 0.875rem !important;
    font-weight: 400 !important;
    line-height: 1.45 !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    color: #212529 !important;
    background-color: #fff !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.85rem center !important;
    background-size: 14px 10px !important;
    border: 1px solid #ced4da !important;
    border-radius: 0.375rem !important;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out !important;
    cursor: pointer !important;
    text-align: left !important;
    user-select: none !important;
    pointer-events: auto !important;
    box-sizing: border-box !important;
}

.custom-select-trigger .custom-select-trigger-text,
.custom-select-trigger > span {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.45 !important;
    text-align: left !important;
}

.custom-select-wrapper.open-up .custom-select-trigger {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 11 6-6 6 6'/%3e%3c/svg%3e") !important;
}

.custom-select-trigger:focus {
    border-color: #86b7fe !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

/* Custom dropdown menu style */
.custom-select-dropdown {
    position: absolute;
    top: 100%;
    bottom: auto;
    left: 0;
    right: 0;
    z-index: 999999 !important;
    display: none;
    min-width: 100%;
    margin-top: 0.25rem;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.15);
    max-height: 350px;
    overflow: hidden;
    flex-direction: column;
    box-sizing: border-box !important;
}

.custom-select-dropdown.show {
    display: flex !important;
    z-index: 999999 !important;
}

/* Dropup (open upward when constrained below) */
.custom-select-dropdown.open-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 0.25rem;
    box-shadow: 0 -0.5rem 1.25rem rgba(0, 0, 0, 0.15) !important;
}

/* Search input container inside the dropdown */
.custom-select-search-container {
    padding: 8px;
    border-bottom: 1px solid #e9ecef;
    background-color: #f8f9fa;
    flex-shrink: 0;
}

.custom-select-search-input {
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}

.custom-select-search-input:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.25);
}

/* Scrollable list of options */
.custom-select-options-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    max-height: 250px;
    flex: 1 1 auto;
    min-height: 40px;
}

/* Scrollbar customization for the options list */
.custom-select-options-list::-webkit-scrollbar {
    width: 6px;
}

.custom-select-options-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.custom-select-options-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.custom-select-options-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Style for each selectable option */
.custom-select-option {
    padding: 8px 12px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    display: flex;
    flex-direction: column;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.4 !important;
}

.custom-select-option .option-title {
    display: block !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.4 !important;
}

.custom-select-option:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.custom-select-option.selected {
    background-color: #0d6efd;
    color: #fff !important;
}

.custom-select-option.selected .option-sub-details {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Helper badge styling to make the dropdown options descriptive */
.option-sub-details {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 2px;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.35 !important;
}

/* Empty state styling */
.custom-select-no-results {
    padding: 12px;
    text-align: center;
    color: #6c757d;
    font-size: 0.875rem;
    display: none;
}

/* Utility class to visually hide original select while maintaining accessibility */
.sr-select-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/* ==========================================================================
   Input Group & Country Code Integration
   Ensures the country code select and contact number input always sit
   side-by-side on the same line across ALL pages, modals, and screen sizes.
   ========================================================================== */

.input-group:has(.custom-select-wrapper),
.input-group:has(.country_code_select),
.input-group.custom-select-input-group,
.input-group.has-country-code-select {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    width: 100% !important;
}

/* Input group prepend containing country code or custom select */
.input-group > .input-group-prepend {
    display: flex !important;
    align-items: stretch !important;
    flex: 0 0 auto !important;
    margin-right: -1px !important;
    z-index: 2 !important;
}

/* Specific sizing for country code select wrapper inside input-group or prepend */
.input-group-prepend .custom-select-wrapper,
.input-group .country-code-select-wrapper,
.input-group > .country-code-select-wrapper,
.country-code-select-wrapper {
    position: relative !important;
    display: flex !important;
    align-items: stretch !important;
    width: 110px !important;
    min-width: 105px !important;
    max-width: 130px !important;
    flex: 0 0 110px !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* General custom select inside input-group (not country code) */
.input-group > .custom-select-wrapper:not(.country-code-select-wrapper) {
    position: relative !important;
    flex: 1 1 auto !important;
    width: 1% !important;
    min-width: 0 !important;
}

/* Trigger styling inside input group for country code */
.input-group-prepend .custom-select-wrapper .custom-select-trigger,
.input-group .country-code-select-wrapper .custom-select-trigger,
.country-code-select-wrapper .custom-select-trigger {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 38px !important;
    max-height: 44px !important;
    line-height: normal !important;
    padding: 0 1.35rem 0 0.65rem !important;
    border-radius: 0.375rem 0 0 0.375rem !important;
    border-right: none !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    background-position: right 0.45rem center !important;
    background-size: 11px 8px !important;
    font-size: 0.875rem !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

.country-code-select-wrapper .custom-select-trigger .custom-select-trigger-text,
.country-code-select-wrapper .custom-select-trigger > span {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Native select fallback before JS initializes */
.input-group > .input-group-prepend select.country_code_select:not(.sr-select-hidden),
.input-group > select.country_code_select:not(.sr-select-hidden) {
    display: block !important;
    width: 110px !important;
    min-width: 105px !important;
    max-width: 130px !important;
    flex: 0 0 110px !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-right: none !important;
}

/* Sibling mobile input inside input group - fills remaining space on same line */
.input-group > .form-control:not(.custom-select-trigger),
.input-group > input.form-control,
.input-group > input[type="number"],
.input-group > input[type="text"] {
    flex: 1 1 auto !important;
    width: 1% !important;
    min-width: 0 !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    margin-bottom: 0 !important;
    position: relative !important;
    z-index: 1 !important;
}

.input-group-append,
.input-group-prepend {
    color: unset !important;
}

/* ==========================================================================
   Universal Multi-Line Responsive Select / Dropdown Styles Across Project
   Applies to Select2, HTML select/form-select, and custom selects.
   ========================================================================== */

/* 1. Universal Select2 Single-Selection Multi-Line Responsive Styling */
.select2-container--default .select2-selection--single,
.select2-container .select2-selection--single {
    min-height: 42px !important;
    height: auto !important;
    padding: 0.45rem 2.5rem 0.45rem 0.875rem !important;
    display: flex !important;
    align-items: center !important;
    border: 1px solid var(--color-border, #ced4da) !important;
    border-radius: var(--radius-md, 8px) !important;
    background-color: #fff !important;
    box-sizing: border-box !important;
    position: relative !important;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container .select2-selection--single .select2-selection__rendered {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1.45 !important;
    font-size: 0.875rem !important;
    color: var(--color-text, #172033) !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    overflow: visible !important;
    text-overflow: clip !important;
    text-align: left !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow,
.select2-container .select2-selection--single .select2-selection__arrow {
    height: 20px !important;
    width: 20px !important;
    position: absolute !important;
    top: 50% !important;
    right: 0.85rem !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b,
.select2-container .select2-selection--single .select2-selection__arrow b {
    position: static !important;
    margin: 0 !important;
}

/* 2. Universal Select2 Multiple-Selection Multi-Line Responsive Styling */
.select2-container--default .select2-selection--multiple,
.select2-container .select2-selection--multiple {
    min-height: 42px !important;
    height: auto !important;
    padding: 0.35rem 0.5rem !important;
    border: 1px solid var(--color-border, #ced4da) !important;
    border-radius: var(--radius-md, 8px) !important;
    box-sizing: border-box !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered,
.select2-container .select2-selection--multiple .select2-selection__rendered {
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
}

/* 3. Universal Select2 Results Options Wrapping */
.select2-container--default .select2-results__option {
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.4 !important;
    padding: 8px 12px !important;
}

/* 4. Native HTML Select Element Multi-Line & Responsive Height */
select.form-control:not(.country_code_select):not(.sr-select-hidden):not(.dashboard-select-sm),
select.form-select:not(.country_code_select):not(.sr-select-hidden):not(.dashboard-select-sm) {
    min-height: 42px !important;
    height: auto !important;
    padding: 0.5rem 2.5rem 0.5rem 0.875rem !important;
    line-height: 1.45 !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    box-sizing: border-box !important;
}