/**
 * County Live Search Styles - Bootstrap Integration with Dark Mode Support
 * Compatible with Bootstrap 5.3+ and CSS custom properties
 */

/* Container styling */
.county-search-container {
    position: relative;
}

/* Dropdown base styles */
.county-search-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1050 !important;
    
    /* Use Bootstrap variables for consistent theming */
    background-color: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: var(--bs-border-radius, 0.375rem);
    box-shadow: var(--bs-box-shadow, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075));
    
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    
    /* Smooth transitions */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.15s ease-in-out;
}

/* Show state */
.county-search-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown items */
.county-search-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--bs-body-color, #212529);
    text-decoration: none;
    display: flex !important;
    align-items: center;
    transition: background-color 0.15s ease-in-out;
    font-size: 0.875rem;
}

.county-search-item:hover,
.county-search-item.active {
    background-color: var(--bs-primary, #0d6efd);
    color: var(--bs-white, #fff);
}

.county-search-item:hover .text-muted,
.county-search-item.active .text-muted {
    color: rgba(255, 255, 255, 0.75) !important;
}

.county-search-item:hover .text-primary,
.county-search-item.active .text-primary {
    color: var(--bs-white, #fff) !important;
}

/* No results and loading states */
.county-search-item.no-results {
    cursor: default;
    color: var(--bs-text-muted, #6c757d);
    font-style: italic;
}

.county-search-item.no-results:hover {
    background-color: transparent;
    color: var(--bs-text-muted, #6c757d);
}

.county-search-loading {
    color: var(--bs-text-muted, #6c757d);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Input states */
.county-search-container input.dropdown-active {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: var(--bs-primary, #0d6efd);
}

/* Highlighted search terms */
.county-search-item strong {
    font-weight: 600;
}

/* Icons */
.county-search-item .fa {
    width: 1rem;
    text-align: center;
}

/* Responsive design */
@media (max-width: 576px) {
    .county-search-dropdown {
        font-size: 0.875rem;
        max-height: 250px;
    }
    
    .county-search-item {
        padding: 0.75rem 0.5rem;
    }
}

/* Dark mode support - automatically activated when parent has data-bs-theme="dark" */
[data-bs-theme="dark"] .county-search-dropdown {
    background-color: var(--bs-dark, #212529);
    border-color: var(--bs-border-color-translucent, rgba(255, 255, 255, 0.15));
    color: var(--bs-body-color, #dee2e6);
}

[data-bs-theme="dark"] .county-search-item {
    color: var(--bs-body-color, #dee2e6);
}

[data-bs-theme="dark"] .county-search-item:hover,
[data-bs-theme="dark"] .county-search-item.active {
    background-color: var(--bs-primary, #0d6efd);
    color: var(--bs-white, #fff);
}

[data-bs-theme="dark"] .county-search-item.no-results {
    color: var(--bs-text-muted, #adb5bd);
}

[data-bs-theme="dark"] .county-search-item.no-results:hover {
    background-color: transparent;
    color: var(--bs-text-muted, #adb5bd);
}

[data-bs-theme="dark"] .county-search-loading {
    color: var(--bs-text-muted, #adb5bd);
}

[data-bs-theme="dark"] .county-search-container input.dropdown-active {
    border-bottom-color: var(--bs-primary, #0d6efd);
}

/* Disabled state when no country is selected */
.county-search-container input:disabled {
    background-color: var(--bs-secondary-bg, #e9ecef);
    opacity: 0.65;
    cursor: not-allowed;
}

[data-bs-theme="dark"] .county-search-container input:disabled {
    background-color: var(--bs-secondary-bg, #343a40);
}

/* Accessibility improvements */
.county-search-item:focus {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: -2px;
}

/* Animation for loading spinner */
.county-search-loading .spinner-border {
    animation-duration: 0.75s;
}

/* Scrollbar styling for webkit browsers */
.county-search-dropdown::-webkit-scrollbar {
    width: 6px;
}

.county-search-dropdown::-webkit-scrollbar-track {
    background: var(--bs-secondary-bg, #e9ecef);
}

.county-search-dropdown::-webkit-scrollbar-thumb {
    background: var(--bs-border-color, #dee2e6);
    border-radius: 3px;
}

.county-search-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--bs-text-muted, #6c757d);
}

[data-bs-theme="dark"] .county-search-dropdown::-webkit-scrollbar-track {
    background: var(--bs-secondary-bg, #343a40);
}

[data-bs-theme="dark"] .county-search-dropdown::-webkit-scrollbar-thumb {
    background: var(--bs-border-color-translucent, rgba(255, 255, 255, 0.15));
}

[data-bs-theme="dark"] .county-search-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--bs-text-muted, #adb5bd);
}
