from sqlalchemy import Column, Integer, String, Text, JSON, ForeignKey, DateTime, Boolean
from sqlalchemy.orm import relationship
from datetime import datetime
from ..config.database import Base

class GuestPreference(Base):
    __tablename__ = 'guest_preferences'
    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    user_id = Column(Integer, ForeignKey('users.id'), nullable=False, index=True)
    
    # Room preferences
    preferred_room_location = Column(String(100), nullable=True)  # e.g., "high floor", "near elevator", "ocean view"
    preferred_floor = Column(Integer, nullable=True)
    preferred_room_type_id = Column(Integer, ForeignKey('room_types.id'), nullable=True)
    
    # Amenity preferences
    preferred_amenities = Column(JSON, nullable=True)  # Array of amenity names
    
    # Special requests
    special_requests = Column(Text, nullable=True)  # General special requests
    
    # Service preferences
    preferred_services = Column(JSON, nullable=True)  # Array of service preferences
    
    # Communication preferences
    preferred_contact_method = Column(String(50), nullable=True)  # email, phone, sms
    preferred_language = Column(String(10), nullable=True, default='en')
    
    # Dietary preferences
    dietary_restrictions = Column(JSON, nullable=True)  # Array of dietary restrictions
    
    # Other preferences
    additional_preferences = Column(JSON, nullable=True)  # Flexible JSON for other preferences
    
    created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
    
    user = relationship('User', back_populates='guest_preferences')
    preferred_room_type = relationship('RoomType')

