from django.db import models
from django.utils import timezone


class AboutBanner(models.Model):
    """Model for About Us banner section"""
    title = models.CharField(max_length=200)
    subtitle = models.CharField(max_length=100, blank=True)
    description = models.TextField()
    badge_text = models.CharField(max_length=100, default="Enterprise Software Solutions")
    badge_icon = models.CharField(max_length=50, default="fa-solid fa-building")
    cta_text = models.CharField(max_length=100, default="Discover Enterprise Solutions")
    cta_link = models.CharField(max_length=100, default="services")
    cta_icon = models.CharField(max_length=50, default="fa-solid fa-arrow-trend-up")
    image = models.ImageField(upload_to='about/banner/', null=True, blank=True)
    is_active = models.BooleanField(default=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = "About Banner"
        verbose_name_plural = "About Banners"

    def __str__(self):
        return self.title


class AboutStat(models.Model):
    """Model for About Us statistics"""
    banner = models.ForeignKey(AboutBanner, on_delete=models.CASCADE, related_name='stats')
    number = models.CharField(max_length=20)
    label = models.CharField(max_length=100)
    order = models.PositiveIntegerField(default=0)

    class Meta:
        ordering = ['order']
        verbose_name = "About Statistic"
        verbose_name_plural = "About Statistics"

    def __str__(self):
        return f"{self.number} - {self.label}"


class AboutSocialLink(models.Model):
    """Model for About Us social links"""
    banner = models.ForeignKey(AboutBanner, on_delete=models.CASCADE, related_name='social_links')
    platform = models.CharField(max_length=50)
    url = models.URLField()
    icon = models.CharField(max_length=50)
    aria_label = models.CharField(max_length=100)
    order = models.PositiveIntegerField(default=0)

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

    def __str__(self):
        return f"{self.platform} - {self.banner.title}"


class AboutService(models.Model):
    """Model for About Us service section"""
    title = models.CharField(max_length=200)
    subtitle = models.CharField(max_length=100, blank=True)
    description = models.TextField()
    badge_text = models.CharField(max_length=100, default="About Our Company")
    badge_icon = models.CharField(max_length=50, default="fa-solid fa-users")
    image = models.ImageField(upload_to='about/services/', null=True, blank=True)
    cta_text = models.CharField(max_length=100, default="Explore Our Solutions")
    cta_link = models.CharField(max_length=100, default="service-single")
    is_active = models.BooleanField(default=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = "About Service"
        verbose_name_plural = "About Services"

    def __str__(self):
        return self.title


class AboutFeature(models.Model):
    """Model for About Us features"""
    service = models.ForeignKey(AboutService, on_delete=models.CASCADE, related_name='features')
    title = models.CharField(max_length=100)
    description = models.CharField(max_length=200)
    icon = models.CharField(max_length=50)
    order = models.PositiveIntegerField(default=0)

    class Meta:
        ordering = ['order']
        verbose_name = "About Feature"
        verbose_name_plural = "About Features"

    def __str__(self):
        return f"{self.title} - {self.service.title}"


class AboutProcess(models.Model):
    """Model for About Us process section"""
    title = models.CharField(max_length=200)
    subtitle = models.CharField(max_length=100, blank=True)
    description = models.TextField()
    badge_text = models.CharField(max_length=100, default="Our Methodology")
    badge_icon = models.CharField(max_length=50, default="fa-solid fa-cogs")
    image = models.ImageField(upload_to='about/process/', null=True, blank=True)
    cta_text = models.CharField(max_length=100, default="View Our Services")
    cta_link = models.CharField(max_length=100, default="service-single")
    is_active = models.BooleanField(default=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = "About Process"
        verbose_name_plural = "About Processes"

    def __str__(self):
        return self.title


class AboutProcessStep(models.Model):
    """Model for About Us process steps"""
    process = models.ForeignKey(AboutProcess, on_delete=models.CASCADE, related_name='steps')
    step_number = models.CharField(max_length=10)
    title = models.CharField(max_length=100)
    description = models.CharField(max_length=200)
    order = models.PositiveIntegerField(default=0)

    class Meta:
        ordering = ['order']
        verbose_name = "About Process Step"
        verbose_name_plural = "About Process Steps"

    def __str__(self):
        return f"Step {self.step_number}: {self.title}"


class AboutJourney(models.Model):
    """Model for About Us journey section"""
    title = models.CharField(max_length=200)
    subtitle = models.CharField(max_length=100, blank=True)
    description = models.TextField()
    badge_text = models.CharField(max_length=100, default="Our Journey")
    badge_icon = models.CharField(max_length=50, default="fa-solid fa-rocket")
    image = models.ImageField(upload_to='about/journey/', null=True, blank=True)
    cta_text = models.CharField(max_length=100, default="Explore Solutions")
    cta_link = models.CharField(max_length=100, default="services")
    is_active = models.BooleanField(default=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = "About Journey"
        verbose_name_plural = "About Journeys"

    def __str__(self):
        return self.title


class AboutMilestone(models.Model):
    """Model for About Us milestones"""
    journey = models.ForeignKey(AboutJourney, on_delete=models.CASCADE, related_name='milestones')
    year = models.CharField(max_length=10)
    title = models.CharField(max_length=100)
    description = models.CharField(max_length=200)
    order = models.PositiveIntegerField(default=0)

    class Meta:
        ordering = ['order']
        verbose_name = "About Milestone"
        verbose_name_plural = "About Milestones"

    def __str__(self):
        return f"{self.year}: {self.title}"