from datetime import date, time

from pydantic import BaseModel

from app.models.reservation import ReservationStatus
from app.schemas.room import RoomRead
from app.schemas.table import TableCombinationRead, TableRead


class OccupancyWindow(BaseModel):
    reservation_id: int
    customer_name: str
    guests: int
    status: ReservationStatus
    start_time: time
    end_time: time


class TableFloorState(BaseModel):
    table_id: int
    table_name: str
    is_occupied_now: bool
    occupancy_windows: list[OccupancyWindow]


class FloorPlanReservation(BaseModel):
    reservation_id: int
    customer_name: str
    guests: int
    start_time: time
    duration_minutes: int
    status: ReservationStatus
    assigned_table_id: int | None
    assigned_combination_id: int | None
    assignment_label: str | None
    requires_table_join: bool = False
    service_summary: str | None = None
    service_steps: list[str] = []


class FloorPlanResponse(BaseModel):
    date: date
    room: RoomRead
    tables: list[TableRead]
    table_combinations: list[TableCombinationRead]
    reservations: list[FloorPlanReservation]
    table_states: list[TableFloorState]
