from django.db import models
from django.contrib.auth.models import User

class MockupProject(models.Model):
    GENDER_CHOICES = [
        ('M', 'Masculino'),
        ('F', 'Feminino'),
        ('N', 'Não-binário'),
    ]
    SKIN_TONE_CHOICES = [
        ('light', 'Claro'),
        ('medium', 'Médio'),
        ('dark', 'Escuro'),
    ]
    BODY_TYPE_CHOICES = [
        ('plus', 'Plus-size'),
        ('slim', 'Magro'),
        ('athletic', 'Atlético'),
        ('muscular', 'Musculoso'),
    ]
    FORMAT_CHOICES = [
        ('9:16', '9:16 (Vertical)'),
        ('16:9', '16:9 (Horizontal)'),
    ]

    user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
    title = models.CharField(max_length=255, verbose_name="Título do Projeto")
    main_image = models.ImageField(upload_to='mockups/uploads/', verbose_name="Imagem Principal")
    complementary_image_1 = models.ImageField(upload_to='mockups/uploads/', null=True, blank=True)
    complementary_image_2 = models.ImageField(upload_to='mockups/uploads/', null=True, blank=True)
    
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, default='F', verbose_name="Gênero")
    skin_tone = models.CharField(max_length=20, choices=SKIN_TONE_CHOICES, default='medium', verbose_name="Tom de Pele")
    age = models.IntegerField(default=25, verbose_name="Idade")
    body_type = models.CharField(max_length=20, choices=BODY_TYPE_CHOICES, default='athletic', verbose_name="Tipo de Corpo")
    format = models.CharField(max_length=5, choices=FORMAT_CHOICES, default='9:16', verbose_name="Formato")
    
    created_at = models.DateTimeField(auto_now_add=True)
    status = models.CharField(max_length=20, default='pending')

    class Meta:
        verbose_name = "Projeto de Mockup"
        verbose_name_plural = "Projetos de Mockup"

    def __str__(self):
        return self.title

class MockupResult(models.Model):
    project = models.ForeignKey(MockupProject, on_delete=models.CASCADE, related_name='results')
    image = models.ImageField(upload_to='mockups/results/')
    view_type = models.CharField(max_length=10) # front, side, back
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        verbose_name = "Resultado do Mockup"
        verbose_name_plural = "Resultados dos Mockups"