package dev.ulfrx.recipe.ui.components.calendar

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import kotlinx.datetime.LocalDate

/**
 * Mon-anchored 7-day strip rendering [CalendarDayCell] per day. Used by every
 * surface that embeds [CalendarPill] in its collapsed form (planner, meal-plan
 * editor, future pantry/shopping pills).
 */
@Composable
fun CalendarWeekStrip(
    selectedDate: LocalDate,
    today: LocalDate,
    onSelectDate: (LocalDate) -> Unit,
    numberStyle: TextStyle,
    modifier: Modifier = Modifier,
    dayState: (LocalDate) -> DayState = { DayState() },
    locale: CalendarLocale = CalendarLocale.PL,
) {
    val days = weekStripDays(selectedDate)
    Row(
        modifier = modifier.fillMaxWidth(),
        horizontalArrangement = Arrangement.spacedBy(DayCellGap),
        verticalAlignment = Alignment.CenterVertically,
    ) {
        days.forEachIndexed { index, day ->
            Box(modifier = Modifier.weight(1f)) {
                CalendarDayCell(
                    date = day,
                    state = dayState(day),
                    isSelected = day == selectedDate,
                    isToday = day == today,
                    onClick = { onSelectDate(day) },
                    numberStyle = numberStyle,
                    header = locale.weekdaysShort[index],
                )
            }
        }
    }
}

private val DayCellGap = 4.dp
