package dev.ulfrx.recipe.ui.screens.shell.search

import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.composables.icons.lucide.Lucide
import com.composables.icons.lucide.Search
import com.composeunstyled.UnstyledIcon
import dev.ulfrx.recipe.ui.components.glass.GlassTextField
import dev.ulfrx.recipe.ui.theme.RecipeTheme

/**
 * Inline bottom search pill. Delegates layout, press feedback, and text input
 * to the generic [GlassTextField]; locks the leading icon to `Lucide.Search`
 * so this file expresses "this is the app's search affordance" rather than
 * "this is a glass text field".
 */
@Composable
fun SearchPill(
    query: String,
    onQueryChange: (String) -> Unit,
    onFocusChanged: (Boolean) -> Unit,
    placeholder: String,
    modifier: Modifier = Modifier,
    height: Dp = 56.dp,
) {
    GlassTextField(
        value = query,
        onValueChange = onQueryChange,
        placeholder = placeholder,
        modifier = modifier,
        height = height,
        onFocusChanged = onFocusChanged,
        leadingContent = {
            UnstyledIcon(
                imageVector = Lucide.Search,
                contentDescription = null,
                tint = RecipeTheme.colors.content,
                modifier = Modifier.size(20.dp),
            )
        },
    )
}
