/**
 * Searchable Dropdown Styles
 * Enhances select elements with search functionality
 */

.searchable-dropdown {
    position: relative;
    width: 100%;
    font-family: inherit;
}

.searchable-dropdown-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    padding-right: 2rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.searchable-dropdown-input:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.searchable-dropdown-input::placeholder {
    color: #6c757d;
}

.searchable-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 300px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 0.25rem 0.25rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: none;
    margin-top: -1px;
}

.searchable-dropdown-list.show {
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.searchable-dropdown-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f0f0f0;
}

.searchable-dropdown-item:last-child {
    border-bottom: none;
}

.searchable-dropdown-item:hover,
.searchable-dropdown-item.highlighted {
    background-color: #e3f2fd;
    color: #1976d2;
}

.searchable-dropdown-item.selected {
    background-color: #bbdefb;
    color: #0d47a1;
    font-weight: 500;
}

.searchable-dropdown-item.hidden {
    display: none;
}

.searchable-dropdown-item.no-results {
    color: #6c757d;
    font-style: italic;
    cursor: default;
    padding: 1rem;
    text-align: center;
}

.searchable-dropdown-item.no-results:hover {
    background-color: transparent;
    color: #6c757d;
}

/* Scrollbar styling */
.searchable-dropdown-list::-webkit-scrollbar {
    width: 8px;
}

.searchable-dropdown-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.searchable-dropdown-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.searchable-dropdown-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .searchable-dropdown-list {
        max-height: 200px;
    }
    
    .searchable-dropdown-item {
        padding: 0.75rem 0.5rem;
    }
}

/* Loading state */
.searchable-dropdown.loading .searchable-dropdown-input {
    background-image: url('data:image/svg+xml;charset=utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 4"%3E%3Ccircle cx="2" cy="2" r="2" fill="%23007bff"%3E%3Canimate attributeName="opacity" values="1;0.3;1" dur="1.5s" repeatCount="indefinite"/%3E%3C/circle%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px 12px;
}

/* Disabled state */
.searchable-dropdown.disabled .searchable-dropdown-input {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Error state */
.searchable-dropdown.has-error .searchable-dropdown-input {
    border-color: #dc3545;
}

.searchable-dropdown.has-error .searchable-dropdown-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Integration with existing form styles */
.form-group .searchable-dropdown {
    margin-bottom: 1rem;
}

.form-group .searchable-dropdown .searchable-dropdown-input {
    margin-bottom: 0;
}

/* Multiple selection support (future enhancement) */
.searchable-dropdown.multi-select .searchable-dropdown-input {
    min-height: 38px;
}

.searchable-dropdown.multi-select .selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.searchable-dropdown.multi-select .selected-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background-color: #007bff;
    color: #fff;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.searchable-dropdown.multi-select .selected-tag .remove-tag {
    margin-left: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.searchable-dropdown.multi-select .selected-tag .remove-tag:hover {
    opacity: 0.8;
}
