"""
Site Configuration Models
Dynamic settings for logo, favicon, social media, emails, etc.
All manageable from admin panel
"""
from django.db import models
from django.core.validators import EmailValidator, URLValidator
from django.core.cache import cache


class HeroImage(models.Model):
    POSITION_CHOICES = [
        ('LEFT', 'Left Side'),
        ('RIGHT', 'Right Side'),
    ]

    image = models.ImageField(upload_to='hero_ads/')
    link = models.URLField(blank=True, help_text="Clickable link for the ad")
    position = models.CharField(max_length=10, choices=POSITION_CHOICES, default='LEFT')
    is_active = models.BooleanField(default=True)
    display_order = models.PositiveIntegerField(default=0)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        ordering = ['position', 'display_order', '-created_at']

    def __str__(self):
        return f"{self.get_position_display()} - {self.image.name}"






class SocialMediaPost(models.Model):
    """
    Social media feed/posts to display on site
    """
    PLATFORM_CHOICES = [
        ('FACEBOOK', 'Facebook'),
        ('TWITTER', 'Twitter'),
        ('INSTAGRAM', 'Instagram'),
        ('LINKEDIN', 'LinkedIn'),
    ]
    
    platform = models.CharField(max_length=20, choices=PLATFORM_CHOICES)
    post_url = models.URLField()
    embed_code = models.TextField(blank=True, help_text='Embed code from social platform')
    
    image = models.ImageField(upload_to='social_posts/', blank=True)
    caption = models.TextField(blank=True)
    
    is_featured = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    
    display_order = models.IntegerField(default=0)
    created_at = models.DateTimeField(auto_now_add=True)
    
    class Meta:
        ordering = ['display_order', '-created_at']
    
    def __str__(self):
        return f"{self.platform} - {self.caption[:50]}"
