/**
 * Location Search Dropdown Styles
 * 
 * @package Flatsome Child
 */

/* Container */
.adt-location-search-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Flatsome search form integration */
.searchform .flex-col.flex-grow {
    position: relative;
}

.searchform .flex-col.flex-grow .adt-location-search-input {
    width: 100%;
}

/* Main dropdown container */
.adt-location-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease-in-out;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(176, 43, 44, 0.15);
    margin-top: 0;
    overflow: hidden;
    min-width: 280px;
}

.adt-location-dropdown.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown content */
.adt-location-dropdown-content {
    max-height: 300px;
    overflow-y: auto;
}

/* Loading state */
.adt-location-dropdown-loading {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    display: none;
    background: linear-gradient(90deg, #f8f9fa 0%, #ffffff 50%, #f8f9fa 100%);
}

.adt-location-dropdown-loading .loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #b02b2c;
    border-radius: 50%;
    animation: adt-spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 10px;
}

.adt-location-dropdown-loading .loading-text {
    font-weight: 500;
}

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

/* Results list */
.adt-location-dropdown-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
}

.adt-location-dropdown-list.visible {
    display: block;
}

/* Individual dropdown items */
.adt-location-dropdown-item {
    padding: 14px 18px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    transition: all 0.15s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.adt-location-dropdown-item:hover,
.adt-location-dropdown-item.selected {
    background-color: #f8f9fa;
    border-left: 3px solid #b02b2c;
    padding-left: 15px;
}

.adt-location-dropdown-item:active {
    background-color: #e9ecef;
    transform: translateY(1px);
}

/* Location name styling */
.adt-location-dropdown-item .location-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
    margin-bottom: 2px;
}

.adt-location-dropdown-item .location-name strong {
    background: linear-gradient(120deg, #b02b2c 0%, #8a2223 100%);
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(176, 43, 44, 0.3);
}

/* Parent location (region/country) */
.adt-location-dropdown-item .location-parent {
    font-size: 13px;
    color: #6c757d;
    line-height: 1.3;
    font-weight: 400;
}

.adt-location-dropdown-item .location-parent::before {
    content: "📍 ";
    margin-right: 2px;
}

/* No results message */
.adt-location-dropdown-no-results {
    padding: 12px 16px;
    color: #666;
    font-style: italic;
    text-align: center;
}

/* Fallback search option */
.adt-location-fallback {
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.adt-location-fallback:hover {
    background: #e9ecef;
}

.adt-location-fallback .fallback-icon {
    margin-right: 8px;
    opacity: 0.7;
}

/* Search input modifications */
input[data-location-search="true"] {
    position: relative;
    z-index: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .adt-location-dropdown {
        border-radius: 6px;
        margin-top: 2px;
    }
    
    .adt-location-dropdown-item {
        padding: 14px 16px;
    }
    
    .adt-location-dropdown-item .location-name {
        font-size: 15px;
    }
    
    .adt-location-dropdown-content {
        max-height: 250px;
    }
}

/* Custom scrollbar for webkit browsers */
.adt-location-dropdown-content::-webkit-scrollbar {
    width: 6px;
}

.adt-location-dropdown-content::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.adt-location-dropdown-content::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.adt-location-dropdown-content::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .adt-location-dropdown {
        background: #2d3748;
        border-color: #4a5568;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .adt-location-dropdown-item:hover,
    .adt-location-dropdown-item.selected {
        background-color: #4a5568;
    }
    
    .adt-location-dropdown-item .location-name {
        color: #e2e8f0;
    }
    
    .adt-location-dropdown-item .location-parent {
        color: #a0aec0;
    }
    
    .adt-location-dropdown-loading {
        color: #a0aec0;
    }
    
    .adt-location-dropdown-no-results {
        color: #a0aec0;
    }
    
    .adt-location-dropdown-item .location-name strong {
        background-color: #744210;
        color: #faf089;
    }
}

/* Integration with Flatsome theme */
.header-search-form .adt-location-search-container {
    flex-grow: 1;
}

.searchform .flex-grow .adt-location-search-container {
    width: 100%;
}

.searchform .flex-col.flex-grow.adt-location-search-container {
    position: relative;
}

/* Ensure dropdown appears above other elements including Flatsome overlays */
.adt-location-dropdown {
    z-index: 999999 !important;
}

/* Flatsome search form specific adjustments */
.searchform .adt-location-dropdown {
    top: calc(100% + 4px);
    left: 0;
    right: 0;
}

/* For header search */
.header-search .adt-location-dropdown {
    width: 100%;
    min-width: 300px;
}

/* Animation enhancements */
.adt-location-dropdown-item {
    transform: translateX(0);
    transition: all 0.15s ease;
}

.adt-location-dropdown.visible .adt-location-dropdown-item {
    animation: adt-slideInItem 0.2s ease-out forwards;
}

@keyframes adt-slideInItem {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus styles for accessibility */
.adt-location-dropdown-item:focus {
    outline: 2px solid #b02b2c;
    outline-offset: -2px;
}

/* Loading text fade in */
.adt-location-dropdown-loading .loading-text {
    animation: adt-fadeIn 0.3s ease-in;
}

@keyframes adt-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
