/* SearchBuddy Field Injection Styles - Updated for No-Wrapper Structure */

.searchbuddy-enhanced-field {
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

/* Modern dropdown styling */
.searchbuddy-results-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    max-height: 320px;
    overflow: hidden;
    z-index: 999999;
    margin: 0;
    padding: 8px 0;
    list-style: none;
    display: none;
    box-sizing: border-box;
    backdrop-filter: blur(10px);
    animation: slideDown 0.2s ease-out;
}

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

.searchbuddy-results-dropdown .result-item {
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
    line-height: 1.5;
    color: #2c3e50;
    border: none;
    margin: 0 8px;
    border-radius: 8px;
    position: relative;
    display: flex;
    align-items: center;
    min-height: 48px;
}

.searchbuddy-results-dropdown .result-item:before {
    content: "📍";
    margin-right: 12px;
    font-size: 16px;
    opacity: 0.7;
}

.searchbuddy-results-dropdown .result-item:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.searchbuddy-results-dropdown .result-item.selected {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.searchbuddy-results-dropdown .result-item:hover:before,
.searchbuddy-results-dropdown .result-item.selected:before {
    opacity: 1;
}

/* Loading state */
.searchbuddy-results-dropdown .result-item:only-child {
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Scrollbar styling for webkit browsers */
.searchbuddy-results-dropdown::-webkit-scrollbar {
    width: 6px;
}

.searchbuddy-results-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.searchbuddy-results-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.searchbuddy-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Enhanced input field styling */
.searchbuddy-enhanced-field:focus + .searchbuddy-results-dropdown {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .searchbuddy-results-dropdown {
        border-radius: 8px;
        margin: 0 4px;
        left: -4px;
        right: -4px;
    }
    
    .searchbuddy-results-dropdown .result-item {
        padding: 16px 16px;
        margin: 0 4px;
    }
}

.searchbuddy-result-item .address-line {
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
}

.searchbuddy-result-item .postcode {
    font-size: 0.9em;
    color: #666;
}

.searchbuddy-loading,
.searchbuddy-no-results,
.searchbuddy-error {
    padding: 12px 16px;
    text-align: center;
    font-style: italic;
    color: #666;
}

.searchbuddy-loading {
    color: #2563eb;
}

.searchbuddy-error {
    color: #dc2626;
}

.searchbuddy-no-results {
    color: #6b7280;
}

/* Ensure the wrapper doesn't break form layouts */
.searchbuddy-field-wrapper input[type="text"],
.searchbuddy-field-wrapper input[type="email"],
.searchbuddy-field-wrapper input[type="search"] {
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .searchbuddy-results-dropdown {
        max-height: 200px;
    }
    
    .searchbuddy-result-item {
        padding: 10px 12px;
    }
}

/* Integration with popular form builders */

/* Elementor compatibility */
.elementor-field-group {
    position: relative;
}

.elementor-field-group .searchbuddy-field-wrapper {
    width: 100%;
}

.elementor-field-group .searchbuddy-enhanced-field {
    width: 100%;
}

.elementor-field-group .searchbuddy-results-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 999999;
}

/* Ensure Elementor field groups can contain absolutely positioned elements */
.elementor-field-group-SearchBuddyHelp {
    position: relative;
    overflow: visible;
}

/* WP-Forms compatibility */
.wpforms-field .searchbuddy-field-wrapper {
    width: 100%;
}

/* Gravity Forms compatibility */
.gfield .searchbuddy-field-wrapper {
    width: 100%;
}

/* Contact Form 7 compatibility */
.wpcf7-form-control-wrap .searchbuddy-field-wrapper {
    width: 100%;
}

/* Ninja Forms compatibility */
.nf-field-container .searchbuddy-field-wrapper {
    width: 100%;
}

/* Fluent Forms compatibility */
.ff-el-input--content .searchbuddy-field-wrapper {
    width: 100%;
}

/* WooCommerce compatibility */
.woocommerce-input-wrapper .searchbuddy-field-wrapper {
    width: 100%;
}

/* Ensure dropdown appears above modals and overlays */
.searchbuddy-results-dropdown {
    z-index: 999999;
}

/* Handle cases where the parent has overflow hidden */
.searchbuddy-field-wrapper {
    overflow: visible;
}

/* Accessibility improvements */
.searchbuddy-result-item:focus {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
    background-color: #f8f9fa;
}

/* Loading animation */
.searchbuddy-loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid #2563eb;
    border-radius: 50%;
    border-top-color: transparent;
    animation: searchbuddy-spin 1s linear infinite;
}

@keyframes searchbuddy-spin {
    to {
        transform: rotate(360deg);
    }
}
