from sqlmodel import SQLModel, Field, Column, JSON
from typing import Optional, List, Dict, Any
from datetime import date, datetime
from app.core.base_model import BaseInsuranceModel

class UmbrellaInsuranceModel(BaseInsuranceModel, table=True):
    __tablename__ = "umbrella_insurance"
    
    # Personal Details (Encrypted)
    full_name: str = Field(description="Full legal name")
    date_of_birth: date = Field(description="Date of birth")
    email_address: str = Field(description="Email address")
    mobile_phone: str = Field(description="Mobile phone number")
    residential_address: str = Field(description="Residential address")
    state_of_residence: str = Field(description="State of residence")
    
    # Property & Assets
    home_ownership: str = Field(description="Own or rent home")
    homeowner_renters_provider: Optional[str] = Field(default=None, description="Current home insurance provider")
    owns_rental_property: bool = Field(description="Owns rental/investment property")
    number_of_vehicles: int = Field(ge=0, le=10, description="Number of vehicles owned")
    auto_insurance_provider: Optional[str] = Field(default=None, description="Auto insurance provider")
    owns_boat_atv_rv: bool = Field(description="Owns boat, ATV, or RV")
    
    # Household Risk Factors
    teen_drivers_in_home: bool = Field(description="Teen drivers in home")
    high_risk_pets: bool = Field(description="High risk pets")
    liability_claims_last_5_years: bool = Field(description="Liability claims in last 5 years")
    
    # Financial Overview
    annual_household_income: float = Field(gt=0, description="Annual household income")
    total_net_worth: float = Field(description="Total net worth")
    desired_coverage_amount: str = Field(description="Desired umbrella coverage amount")
    
    # Review & Submit
    preferred_contact_method: str = Field(description="Preferred contact method")
    additional_notes: Optional[str] = Field(default=None, description="Additional notes or concerns")
    transaction_no: str = Field(index=True, max_length=100, description="Transaction number")
    lead_source: Optional[str] = Field(default=None, max_length=100, description="Source of the lead")

    def get_encrypted_fields(self) -> List[str]:
        return [
            "full_name", "email_address", "mobile_phone", "residential_address",
            "homeowner_renters_provider", "auto_insurance_provider", "additional_notes"
        ]

    def get_searchable_fields(self) -> List[str]:
        return ["full_name", "email_address", "state_of_residence"]