from django.contrib import admin
from .models import SiteSettings, SocialLink, SEOData

@admin.register(SiteSettings)
class SiteSettingsAdmin(admin.ModelAdmin):
    list_display = ('company_name', 'phone', 'email', 'address')
    fieldsets = (
        ("Company Information", {
            "fields": ("company_name", "tagline", "logo")
        }),
        ("Contact & Location", {
            "fields": ("phone", "secondary_phone", "email", "support_email", "address", "working_hours")
        }),
        ("Footer & Meta", {
            "fields": ("footer_about", "copyright_text")
        }),
    )

    def has_add_permission(self, request):
        # Only allow 1 site settings instance
        return not SiteSettings.objects.exists()


@admin.register(SocialLink)
class SocialLinkAdmin(admin.ModelAdmin):
    list_display = ('platform', 'url', 'icon', 'order', 'is_active')
    list_editable = ('order', 'is_active')
    list_filter = ('platform', 'is_active')


@admin.register(SEOData)
class SEODataAdmin(admin.ModelAdmin):
    list_display = ('page_name', 'page_path', 'meta_title')
    search_fields = ('page_name', 'page_path', 'meta_title', 'keywords')
