/* assets/css/search.css */

.search-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-left: 2.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background-color: #fff;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #1a202c;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background-color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
                0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-height: 80vh;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.search-result {
    display: block;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    color: #1a202c;
    text-decoration: none;
    transition: background-color 0.2s;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background-color: #f8fafc;
}

.result-header {
    margin-bottom: 0.5rem;
}

.result-title {
    font-weight: 600;
    color: #2563eb;
}

.result-context {
    font-size: 0.875rem;
    color: #64748b;
}

.result-content {
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.4;
}

.result-type {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.code-icon {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4'/%3E%3C/svg%3E");
}

mark {
    background-color: #fef08a;
    padding: 0.125rem 0;
    border-radius: 0.125rem;
}

.no-results {
    padding: 2rem;
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
}

/* Loading state */
.search-input.loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z'/%3E%3C/svg%3E");
    background-position: center right 0.75rem;
    background-repeat: no-repeat;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Mobile styles */
@media (max-width: 640px) {
    .search-container {
        max-width: 100%;
    }
    
    .search-results {
        position: fixed;
        top: 4rem;
        left: 1rem;
        right: 1rem;
        max-height: calc(100vh - 5rem);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-input {
        background-color: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .search-results {
        background-color: #1a202c;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2),
                    0 2px 4px -1px rgba(0, 0, 0, 0.1);
    }
    
    .search-result {
        border-bottom-color: #4a5568;
        color: #e2e8f0;
    }
    
    .search-result:hover {
        background-color: #2d3748;
    }
    
    .result-content {
        color: #cbd5e0;
    }
    
    mark {
        background-color: #744210;
        color: #fff;
    }
}

/* Add to your existing CSS */

.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-results-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-primary);
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-top: 0.5rem;
    z-index: 50;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.search-result.code .result-content {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.search-result.heading .result-content {
    font-weight: 600;
    color: var(--primary-color);
}

mark {
    background-color: #fef08a;
    padding: 0.125rem 0;
    border-radius: 0.125rem;
    color: var(--text-primary);
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .search-results-container {
        border-color: #4a5568;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    }

    .search-result {
        border-bottom-color: #4a5568;
    }

    mark {
        background-color: #744210;
        color: #fff;
    }

    .search-result.code .result-content {
        background-color: rgba(0, 0, 0, 0.2);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .search-results-container {
        position: fixed;
        top: auto;
        left: 1rem;
        right: 1rem;
        margin-top: 0.25rem;
        max-height: 60vh;
    }
}