from __future__ import annotations
from typing import Optional
from datetime import datetime
from sqlalchemy import String, Text, Integer, DateTime, Index
from sqlalchemy.orm import Mapped, mapped_column
from src.database.base import BaseModel


class FaqSectionSettings(BaseModel):
    """Singleton row holding the copy for the marketing Home page FAQ section."""

    __tablename__ = "faq_section_settings"

    heading: Mapped[str] = mapped_column(String(200), nullable=False)
    subheading: Mapped[Optional[str]] = mapped_column(String(300), nullable=True)
    intro: Mapped[Optional[str]] = mapped_column(Text, nullable=True)


class FaqItem(BaseModel):
    """A single question/answer pair shown in the marketing Home page FAQ section."""

    __tablename__ = "faq_items"
    __table_args__ = (
        Index("ix_faq_items_sort_order", "sort_order"),
        Index("ix_faq_items_deleted_at", "deleted_at"),
    )

    question: Mapped[str] = mapped_column(String(300), nullable=False)
    answer: Mapped[str] = mapped_column(Text, nullable=False)
    sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
    deleted_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True), nullable=True)
