/* Custom Typeahead Styles - typeahead-custom.css */

.typeahead-wrapper {
    position: relative;
    width: 100%;
}

/* --- Multi-select Specific Styles (mostly unchanged) --- */
.typeahead-input-container {
    min-height: calc(2.25rem + 2px);
    line-height: 1.5;
    height: auto;
    overflow-x: auto;
    padding: 0; /* JS will dynamically set this */
    position: relative;
    cursor: text;
    border-radius: 0.25rem;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
    border: 1px solid #ced4da;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.typeahead-wrapper:focus-within .typeahead-input-container {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: 0;
}
.typeahead-selected-items-wrapper {
    padding: 0.375rem 0.75rem;
    padding-bottom: 0.125rem;
    padding-right: 2.5rem;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}
.typeahead-input.typeahead-multi-input {
    border: 0 !important;
    box-shadow: none !important;
    padding: 0.375rem 0.75rem !important;
    outline: none !important;
    background-color: transparent !important;
    width: 100%;
    box-sizing: border-box;
    height: auto;
    margin: 0;
    border-radius: 0;
    padding-right: 2.5rem !important;
}
.typeahead-clear-all-btn {
    position: absolute;
    top: 0.375rem;
    right: 0.75rem;
    z-index: 2;
    width: 1.2em;
    height: 1.2em;
    line-height: 1.15em;
    border-radius: 100%;
    background-color: #6c757d;
    color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    outline: none;
    transition: all 0.15s ease-in-out;
    transform: translateY(-0.05em);
}
.typeahead-clear-all-btn:hover,
.typeahead-clear-all-btn:focus {
    background-color: #343a40;
    color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    border-radius: 100%;
}

/* --- Single-select Specific Styles (REFACTORED) --- */

/* Main display element for single select */
.typeahead-single-display {
    height: calc(2.25rem + 2px);
    line-height: 1.5;
    padding: 0.375rem 0.75rem;
    padding-right: 2.5rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    position: relative;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.typeahead-single-display:focus {
    color: #495057;
    background-color: #fff;
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Style for the text inside the single-select display */
.typeahead-single-text {
    flex-grow: 1;
}
.typeahead-single-text.typeahead-placeholder {
    color: #6c757d;
}

/* Clear button for single select */
.typeahead-single-clear {
    position: absolute;
    top: 50%;
    right: 1.25rem;
    transform: translateY(-50%) translateX(50%);
    z-index: 2;
    width: 1.2em;
    height: 1.2em;
    line-height: 1.15em;
    border-radius: 100%;
    background-color: #6c757d;
    color: #f8f9fa;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    outline: none;
    transition: all 0.15s ease-in-out;
}
.typeahead-single-clear:hover,
.typeahead-single-clear:focus {
    background-color: #343a40;
    color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    border-radius: 100%;
}

/* Dropdown arrow for single select */
.typeahead-single-display::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 0.3em solid transparent;
    border-right: 0.3em solid transparent;
    border-top: 0.3em solid #343a40;
    pointer-events: none;
}

/* NEW: Container for the dropdown content (search input + list) */
.typeahead-dropdown-container {
    /* This now acts as the .dropdown-menu */
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    width: 100%;
    border: 1px solid #ced4da;
    border-top: 0;
    border-bottom-right-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
    background-color: #fff;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
    padding: 0; /* Remove padding from dropdown-menu default */
    margin: 0;
}
.typeahead-wrapper:focus-within .typeahead-dropdown-container {
    border-color: #80bdff;
}

/* NEW: Wrapper for the search input inside the dropdown */
.typeahead-search-wrapper {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #dee2e6;
}

/* NEW: Styling for the search input itself */
.typeahead-search-input {
    width: 100%;
    height: calc(2.25rem + 2px);
    /* No need for extra styling if it has .form-control */
}

/* --- Common Styles for Both --- */
.typeahead-chip {
    font-size: 85%;
    margin-bottom: 0.25rem;
}
.badge-primary {
    background-color: #0056b3 !important;
}

/* The suggestions list is now simpler */
.typeahead-suggestions-list {
    max-height: 250px; /* Or whatever height you prefer */
    overflow-y: auto;
    padding-left: 0; /* Remove default ul padding */
    list-style: none; /* Remove default ul bullets */
    margin: 0;
}
/* Multi-select still needs its own dropdown styles */
.typeahead-input-container + .typeahead-suggestions-list.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    border-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    background-color: #fff;
    border: 1px solid #ced4da;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
    z-index: 10;
}

.typeahead-suggestions-list.show,
.typeahead-dropdown-container.show {
    display: block;
}

.typeahead-suggestions-list li {
    cursor: pointer;
    /* .dropdown-item class handles padding and hover states */
}

.typeahead-suggestions-list li.typeahead-active {
    background-color: #e9ecef;
    color: #16181b;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.typeahead-chip .close {
    font-size: 1rem;
    line-height: 1;
    margin-left: 0.5rem;
    color: inherit;
    opacity: 0.8;
}

.typeahead-no-results {
    padding: 0.5rem 0.75rem;
    font-style: italic;
    color: #6c757d;
}

.typeahead-chip .close:hover {
    opacity: 1;
}

.typeahead-no-results {
    font-style: italic;
    color: #6c757d;
    cursor: default !important;
}
