/* custom-dropdown.css - Base Styles */

/* Reset and base styles */
.custom-dropdown-container {
    position: relative;
    display: block;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 1.42857143;
}

.custom-dropdown-container *,
.custom-dropdown-container *::before,
.custom-dropdown-container *::after {
    box-sizing: border-box;
}

/* Selection container */
.custom-dropdown-selection {
    position: relative;
    display: block;
    width: 100%;
    min-height: 38px;
    padding: 8px 32px 8px 12px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    outline: none;
}

.custom-dropdown-selection:hover {
    border-color: #bbb;
}

.custom-dropdown-selection:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.custom-dropdown-container--open .custom-dropdown-selection {
    border-color: var(--primary-color);
}

/* Selection content */
.custom-dropdown-selection__rendered {
    display: block;
    padding-right: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.custom-dropdown-selection__placeholder {
    color: #999;
}

/* Selection arrow */
.custom-dropdown-selection__arrow {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    pointer-events: none;
}

.custom-dropdown-selection__arrow b {
    display: block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #666;
    transition: transform 0.2s ease-in-out;
}

.custom-dropdown-container--open .custom-dropdown-selection__arrow b {
    transform: rotate(180deg);
}

/* Clear button */
.custom-dropdown-selection__clear {
    position: absolute;
    top: 50%;
    right: 32px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease-in-out;
}

.custom-dropdown-selection__clear:hover {
    background-color: #f5f5f5;
    color: #333;
}

/* Multiple selection choices */
.custom-dropdown-selection__choice {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 2px 8px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    font-size: 12px;
    line-height: 1.4;
    vertical-align: middle;
}

.custom-dropdown-selection__choice__text {
    display: inline-block;
    margin-right: 4px;
}

.custom-dropdown-selection__choice__remove {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 12px;
    text-align: center;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease-in-out;
}

.custom-dropdown-selection__choice__remove:hover {
    background-color: #dc3545;
    color: #fff;
}

/* Dropdown container */
.custom-dropdown-dropdown {
    width: 100%;
    position: absolute;
    z-index: 9999;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow: hidden;
    animation: dropdownFadeIn 0.2s ease-out;
}

.custom-dropdown-dropdown--above {
    animation: dropdownFadeInUp 0.2s ease-out;
}

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

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

/* Search container */
.custom-dropdown-search {
    padding: 8px;
    border-bottom: 1px solid #eee;
    background-color: #fafafa;
}

.custom-dropdown-search__field {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease-in-out;
}

.custom-dropdown-search__field:focus {
    border-color: var(--primary-color);
}

/* Results container */
.custom-dropdown-results {
    max-height: 250px;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    list-style: none;
}

.custom-dropdown-results__option {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.2s ease-in-out;
    line-height: 1.4;
}

.custom-dropdown-results__option:last-child {
    border-bottom: none;
}

.custom-dropdown-results__option:hover,
.custom-dropdown-results__option--highlighted {
    background-color: #f8f9fa;
}

.custom-dropdown-results__option--selected {
    background-color: var(--primary-color);
    color: #fff;
}

.custom-dropdown-results__option--selected:hover,
.custom-dropdown-results__option--selected.custom-dropdown-results__option--highlighted {
    background-color: #0056b3;
}

.custom-dropdown-results__option--disabled {
    color: #999;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

.custom-dropdown-results__option--disabled:hover {
    background-color: #f5f5f5;
}

.custom-dropdown-results__option--no-results,
.custom-dropdown-results__option--loading,
.custom-dropdown-results__option--error {
    text-align: center;
    color: #999;
    font-style: italic;
    cursor: default;
}

.custom-dropdown-results__option--loading {
    color: var(--primary-color);
}

.custom-dropdown-results__option--error {
    color: #dc3545;
}

/* Loading animation */
.custom-dropdown-loading {
    position: relative;
    display: inline-block;
    padding-left: 20px;
}

.custom-dropdown-loading::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

/* Disabled state */
.custom-dropdown-disabled .custom-dropdown-selection {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.custom-dropdown-disabled .custom-dropdown-selection:hover {
    border-color: #ddd;
}

/* RTL support */
.custom-dropdown-container[dir="rtl"] .custom-dropdown-selection {
    padding: 8px 12px 8px 32px;
}

.custom-dropdown-container[dir="rtl"] .custom-dropdown-selection__arrow {
    left: 12px;
    right: auto;
}

.custom-dropdown-container[dir="rtl"] .custom-dropdown-selection__clear {
    left: 32px;
    right: auto;
}

.custom-dropdown-container[dir="rtl"] .custom-dropdown-selection__choice {
    margin: 2px 0 2px 4px;
}

/* Responsive design */
@media (max-width: 768px) {
    .custom-dropdown-dropdown {
        max-height: 200px;
    }
    
    .custom-dropdown-results {
        max-height: 150px;
    }
    
    .custom-dropdown-results__option {
        padding: 12px;
        font-size: 16px;
    }
    
    .custom-dropdown-search__field {
        font-size: 16px;
        padding: 8px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .custom-dropdown-selection {
        border-width: 2px;
    }
    
    .custom-dropdown-results__option--selected {
        background-color: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .custom-dropdown-selection,
    .custom-dropdown-selection__arrow b,
    .custom-dropdown-selection__clear,
    .custom-dropdown-selection__choice__remove,
    .custom-dropdown-search__field,
    .custom-dropdown-results__option {
        transition: none;
    }
    
    .custom-dropdown-dropdown {
        animation: none;
    }
    
    .custom-dropdown-loading::before {
        animation: none;
    }
}

