/* Location Autocomplete Styles */

/* Wrapper for input + dropdown */
.location-autocomplete-wrapper {
    position: relative;
    width: 100%;
    display: contents; /* Makes wrapper invisible to flexbox/grid */
}

/* Override for search bar - wrapper should behave like flex item */
.search-form-wrapper .location-autocomplete-wrapper,
.always-visible-fields .location-autocomplete-wrapper,
.collapsible-fields .location-autocomplete-wrapper {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
}

/* Ensure dropdown is positioned relative to wrapper, not input */
.search-form-wrapper .location-autocomplete-wrapper,
.always-visible-fields .location-autocomplete-wrapper,
.collapsible-fields .location-autocomplete-wrapper {
    position: relative;
}

/* Dropdown container */
.location-autocomplete-dropdown {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1060;
    display: none;
    width: 100% !important;
}

/* Ensure input inherits proper sizing from wrapper */
.location-autocomplete-wrapper > input {
    width: 100%;
    flex: 1 1 auto;
}

/* Special handling for search bar inputs */
.search-form-wrapper .location-autocomplete-wrapper > input,
.always-visible-fields .location-autocomplete-wrapper > input,
.collapsible-fields .location-autocomplete-wrapper > input {
    flex: 1;
    min-width: 0;
}

.location-autocomplete-dropdown.show {
    display: block;
}

/* Loading state */
.location-autocomplete-loading {
    padding: 12px 16px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

.location-autocomplete-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* No results message */
.location-autocomplete-empty {
    padding: 12px 16px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

/* Suggestion items */
.location-autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
    transition: background-color 0.15s ease;
}

.location-autocomplete-item:last-child {
    border-bottom: none;
}

.location-autocomplete-item:hover,
.location-autocomplete-item.active {
    background-color: #f8f9fa;
}

.location-autocomplete-item.selected {
    background-color: #e7f1ff;
}

/* Item content */
.location-name {
    font-size: 14px;
    font-weight: 500;
    color: #212529;
    margin-bottom: 2px;
}

.location-details {
    font-size: 12px;
    color: #6c757d;
}

/* Highlight matched text */
.location-name mark,
.location-details mark {
    background-color: #fff3cd;
    color: #856404;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Type badges */
.location-type-badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

.location-type-state {
    background-color: #d1ecf1;
    color: #0c5460;
}

.location-type-lga {
    background-color: #d4edda;
    color: #155724;
}

.location-type-ward {
    background-color: #e2e3e5;
    color: #383d41;
}

.location-type-area {
    background-color: #f8d7da;
    color: #721c24;
}

/* Scrollbar styling */
.location-autocomplete-dropdown::-webkit-scrollbar {
    width: 8px;
}

.location-autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.location-autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.location-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .location-autocomplete-dropdown {
        max-height: 250px;
        font-size: 13px;
    }
    
    .location-autocomplete-item {
        padding: 12px 14px;
    }
}

/* Accessibility - Focus states */
.location-autocomplete-item:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

/* Input with autocomplete active */
input[data-autosuggest="location"].autocomplete-active {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Popular locations section */
.location-popular-section {
    padding: 8px 16px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.location-popular-title {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.location-popular-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.location-popular-chip {
    display: inline-block;
    padding: 4px 10px;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    font-size: 12px;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s ease;
}

.location-popular-chip:hover {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

/* Recent searches section */
.location-recent-section {
    padding: 8px 16px;
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
}

.location-recent-title {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.location-clear-recent {
    color: #dc3545;
    cursor: pointer;
    font-size: 11px;
    font-weight: normal;
    text-transform: none;
}

.location-clear-recent:hover {
    text-decoration: underline;
}

/* Loading skeleton */
.location-skeleton {
    padding: 10px 16px;
}

.location-skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.location-skeleton-line:last-child {
    width: 60%;
    margin-bottom: 0;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error state */
.location-autocomplete-error {
    padding: 12px 16px;
    text-align: center;
    color: #dc3545;
    font-size: 13px;
}

.location-autocomplete-error i {
    margin-right: 6px;
}

/* Info message */
.location-autocomplete-info {
    padding: 10px 16px;
    background-color: #cfe2ff;
    color: #084298;
    font-size: 12px;
    border-bottom: 1px solid #b6d4fe;
}

.location-autocomplete-info i {
    margin-right: 6px;
}