from django.db import models

class SiteSettings(models.Model):
    company_name = models.CharField(max_length=150, default="SONICTECH")
    tagline = models.CharField(max_length=255, default="Innovative Digital & IT Solutions")
    phone = models.CharField(max_length=50, default="+255 754 123 456")
    secondary_phone = models.CharField(max_length=50, blank=True, default="+255 689 987 654")
    email = models.EmailField(default="info@sonictech.co.tz")
    support_email = models.EmailField(default="support@sonictech.co.tz")
    address = models.CharField(max_length=255, default="Ali Hassan Mwinyi Rd, Victoria, Dar es Salaam, Tanzania")
    working_hours = models.CharField(max_length=100, default="Mon - Fri: 8:00 AM - 5:30 PM, Sat: 9:00 AM - 1:00 PM")
    footer_about = models.TextField(default="SONICTECH is a premier technology partner delivering cutting-edge software development, enterprise solutions, mobile applications, and digital transformation for visionary businesses in Tanzania and East Africa.")
    copyright_text = models.CharField(max_length=255, default="© 2026 SONICTECH. All Rights Reserved.")
    logo = models.ImageField(upload_to='settings/', blank=True, null=True)

    class Meta:
        verbose_name = "Site Settings"
        verbose_name_plural = "Site Settings"

    def __str__(self):
        return f"{self.company_name} Settings"


class SocialLink(models.Model):
    PLATFORM_CHOICES = [
        ('facebook', 'Facebook'),
        ('twitter', 'X (Twitter)'),
        ('instagram', 'Instagram'),
        ('linkedin', 'LinkedIn'),
        ('github', 'GitHub'),
        ('youtube', 'YouTube'),
        ('whatsapp', 'WhatsApp'),
    ]
    platform = models.CharField(max_length=50, choices=PLATFORM_CHOICES)
    url = models.URLField()
    icon = models.CharField(max_length=50, default='globe', help_text="Lucide icon name e.g. facebook, twitter, instagram, linkedin")
    order = models.PositiveIntegerField(default=0)
    is_active = models.BooleanField(default=True)

    class Meta:
        ordering = ['order']
        verbose_name = "Social Link"
        verbose_name_plural = "Social Links"

    def __str__(self):
        return f"{self.get_platform_display()} ({self.url})"


class SEOData(models.Model):
    page_name = models.CharField(max_length=100, help_text="e.g. Home, About, Services, Contact")
    page_path = models.CharField(max_length=100, unique=True, help_text="e.g. /, /about, /services")
    meta_title = models.CharField(max_length=200)
    meta_description = models.TextField()
    keywords = models.CharField(max_length=300, help_text="Comma-separated keywords")
    og_title = models.CharField(max_length=200, blank=True)
    og_description = models.TextField(blank=True)
    canonical_url = models.URLField(blank=True)

    class Meta:
        verbose_name = "SEO Meta"
        verbose_name_plural = "SEO Meta Settings"

    def __str__(self):
        return f"SEO: {self.page_name} ({self.page_path})"
