from sqlalchemy import Column, Integer, String, ForeignKey, Boolean, Float, JSON, Date
from sqlalchemy.orm import relationship
from app.db.base import Base

# 1. Kategória (Autó, Motor, Kisteher...)
class VehicleCategory(Base):
    __tablename__ = "vehicle_categories"
    __table_args__ = {"schema": "data"}
    id = Column(Integer, primary_key=True)
    name_key = Column(String, nullable=False) # i18n kulcs: 'CAR', 'MOTORCYCLE'

# 2. Márka (Audi, Honda, BMW...)
class VehicleMake(Base):
    __tablename__ = "vehicle_makes"
    __table_args__ = {"schema": "data"}
    id = Column(Integer, primary_key=True)
    name = Column(String, unique=True, nullable=False)
    logo_url = Column(String, nullable=True)

# 3. Modell és Generáció (pl. Audi A3 -> A3 8V)
class VehicleModel(Base):
    __tablename__ = "vehicle_models"
    __table_args__ = {"schema": "data"}
    id = Column(Integer, primary_key=True)
    make_id = Column(Integer, ForeignKey("data.vehicle_makes.id"))
    category_id = Column(Integer, ForeignKey("data.vehicle_categories.id"))
    name = Column(String, nullable=False)
    generation_name = Column(String, nullable=True) # pl: "8V Facelift"
    production_start_year = Column(Integer, nullable=True)
    production_end_year = Column(Integer, nullable=True)

# 4. Motor és Hajtáslánc (Technikai specifikációk)
class VehicleEngine(Base):
    __tablename__ = "vehicle_engines"
    __table_args__ = {"schema": "data"}
    id = Column(Integer, primary_key=True)
    model_id = Column(Integer, ForeignKey("data.vehicle_models.id"))
    
    engine_code = Column(String, nullable=True)
    fuel_type = Column(String, nullable=False)   # 'Petrol', 'Diesel', 'Hybrid', 'EV'
    displacement_ccm = Column(Integer, nullable=True)
    power_kw = Column(Integer, nullable=True)
    torque_nm = Column(Integer, nullable=True)
    transmission_type = Column(String, nullable=True) # 'Manual', 'Automatic'
    gears_count = Column(Integer, nullable=True)
    drive_type = Column(String, nullable=True) # 'FWD', 'RWD', 'AWD'

# 5. Opciók Katalógusa (Gyári extrák listája)
class VehicleOptionCatalog(Base):
    __tablename__ = "vehicle_options_catalog"
    __table_args__ = {"schema": "data"}
    id = Column(Integer, primary_key=True)
    category = Column(String) # 'Security', 'Comfort', 'Multimedia'
    name_key = Column(String) # 'MATRIX_LED'