/**
 * AI Tools Ajax Search Styles
 * Mobile-first responsive design
 */

/* Search Container */
.ai-tools-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Search Form */
.ai-tools-search-form {
    position: relative;
    width: 100%;
}

/* Search Input Container */
.ai-tools-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 50px;
    padding: 8px 16px;
    transition: none;
}

/* Remove focus styles completely */
.ai-tools-search-input-wrapper:focus-within {
    border-color: #e5e7eb;
    box-shadow: none;
    outline: none;
}

/* Search Input */
.ai-tools-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px 12px;
    font-size: 16px;
    background: transparent;
    color: #1f2937;
}

/* Remove any default focus styles */
.ai-tools-search-input:focus {
    outline: none;
    border: none;
    box-shadow: none;
}

.ai-tools-search-input::placeholder {
    color: #9ca3af;
}

/* Search/Clear Buttons */
.ai-tools-search-btn,
.ai-tools-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.ai-tools-search-btn:hover,
.ai-tools-search-clear:hover {
    transform: scale(1.1);
}

.ai-tools-search-btn svg,
.ai-tools-search-clear svg {
    width: 20px;
    height: 20px;
    fill: #6b7280;
}

.ai-tools-search-clear {
    display: none;
}

.ai-tools-search-clear.active {
    display: flex;
}

/* Loading Spinner */
.ai-tools-search-loading {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: ai-tools-spin 0.6s linear infinite;
}

.ai-tools-search-loading.active {
    display: block;
}

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

/* Results Container */
.ai-tools-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.ai-tools-search-results.active {
    display: block;
}

/* Results List */
.ai-tools-search-list {
    list-style: none;
    margin: 0;
    padding: 8px;
}

/* Result Item */
.ai-tools-result-item {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    text-decoration: none;
    color: inherit;
    gap: 12px;
}

.ai-tools-result-item:hover {
    background-color: #f3f4f6;
}

/* Result Image */
.ai-tools-result-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
}

.ai-tools-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-tools-result-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 20px;
}

/* Result Content */
.ai-tools-result-content {
    flex: 1;
    min-width: 0;
}

.ai-tools-result-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.ai-tools-result-description {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* No Results */
.ai-tools-no-results {
    padding: 24px;
    text-align: center;
    color: #6b7280;
}

/* Results Count */
.ai-tools-results-count {
    padding: 8px 16px;
    font-size: 12px;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

/* Scrollbar Styles */
.ai-tools-search-results::-webkit-scrollbar {
    width: 6px;
}

.ai-tools-search-results::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 10px;
}

.ai-tools-search-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.ai-tools-search-results::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-tools-search-wrapper {
        max-width: 100%;
        padding: 0 16px;
    }
    
    .ai-tools-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .ai-tools-search-results {
        max-height: 400px;
        border-radius: 8px;
    }
    
    .ai-tools-result-image {
        width: 50px;
        height: 50px;
    }
    
    .ai-tools-result-title {
        font-size: 15px;
    }
    
    .ai-tools-result-description {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ai-tools-search-input-wrapper {
        padding: 6px 12px;
    }
    
    .ai-tools-search-input {
        padding: 6px 8px;
        font-size: 16px;
    }
    
    .ai-tools-result-item {
        padding: 10px;
        gap: 10px;
    }
}

/* Accessibility */
.ai-tools-result-item:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .ai-tools-search-input-wrapper {
        background: #1f2937;
        border-color: #374151;
    }
    
    .ai-tools-search-input {
        color: #f9fafb;
    }
    
    .ai-tools-search-input::placeholder {
        color: #6b7280;
    }
    
    .ai-tools-search-results {
        background: #1f2937;
    }
    
    .ai-tools-result-item:hover {
        background-color: #374151;
    }
    
    .ai-tools-result-title {
        color: #f9fafb;
    }
    
    .ai-tools-result-description {
        color: #9ca3af;
    }
}