from django.db import models

# ======== PRODUCT MODEL ========
class Product(models.Model):
    name_uz = models.CharField(max_length=255)
    name_ru = models.CharField(max_length=255)
    image = models.ImageField(upload_to='products/')
    slug = models.CharField(max_length=255)

    # Description (uz & ru)
    description_uz = models.TextField(blank=True, null=True)
    description_ru = models.TextField(blank=True, null=True)
    
    def __str__(self):
        return f"{self.name_uz} / {self.name_ru}"


# ======== PRODUCT FEATURES (KEY-VALUE) ========
class ProductFeature(models.Model):
    product = models.ForeignKey(Product, related_name='features', on_delete=models.CASCADE)

    key_uz = models.CharField(max_length=255,default='salom')
    key_ru = models.CharField(max_length=255 , default='salom')

    value_uz = models.CharField(max_length=255, default='salom')
    value_ru = models.CharField(max_length=255, default='salom')

    def __str__(self):
        return f"{self.product.name_uz} - {self.key_uz}"


# ======== CONTACT FORM DATA ========
class ContactMessage(models.Model):
    name = models.CharField(max_length=255)
    phone = models.CharField(max_length=20)
    message = models.TextField()
    product_name = models.CharField(max_length=255, blank=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f"Message from {self.name}"

# ======== FAQ MODEL ========
class FAQ(models.Model):
    question_uz = models.CharField(max_length=255)
    question_ru = models.CharField(max_length=255)
    answer_uz = models.TextField()
    answer_ru = models.TextField()

    def __str__(self):
        return f"FAQ: {self.question_uz}"