from django.contrib import admin
from .models import (
    AboutBanner, AboutStat, AboutSocialLink,
    AboutService, AboutFeature,
    AboutProcess, AboutProcessStep,
    AboutJourney, AboutMilestone
)


class AboutStatInline(admin.TabularInline):
    model = AboutStat
    extra = 0
    ordering = ['order']


class AboutSocialLinkInline(admin.TabularInline):
    model = AboutSocialLink
    extra = 0
    ordering = ['order']


@admin.register(AboutBanner)
class AboutBannerAdmin(admin.ModelAdmin):
    list_display = ['title', 'is_active', 'created_at']
    list_filter = ['is_active', 'created_at']
    search_fields = ['title', 'description']
    inlines = [AboutStatInline, AboutSocialLinkInline]
    readonly_fields = ['created_at', 'updated_at']


class AboutFeatureInline(admin.TabularInline):
    model = AboutFeature
    extra = 0
    ordering = ['order']


@admin.register(AboutService)
class AboutServiceAdmin(admin.ModelAdmin):
    list_display = ['title', 'is_active', 'created_at']
    list_filter = ['is_active', 'created_at']
    search_fields = ['title', 'description']
    inlines = [AboutFeatureInline]
    readonly_fields = ['created_at', 'updated_at']


class AboutProcessStepInline(admin.TabularInline):
    model = AboutProcessStep
    extra = 0
    ordering = ['order']


@admin.register(AboutProcess)
class AboutProcessAdmin(admin.ModelAdmin):
    list_display = ['title', 'is_active', 'created_at']
    list_filter = ['is_active', 'created_at']
    search_fields = ['title', 'description']
    inlines = [AboutProcessStepInline]
    readonly_fields = ['created_at', 'updated_at']


class AboutMilestoneInline(admin.TabularInline):
    model = AboutMilestone
    extra = 0
    ordering = ['order']


@admin.register(AboutJourney)
class AboutJourneyAdmin(admin.ModelAdmin):
    list_display = ['title', 'is_active', 'created_at']
    list_filter = ['is_active', 'created_at']
    search_fields = ['title', 'description']
    inlines = [AboutMilestoneInline]
    readonly_fields = ['created_at', 'updated_at']


# Register individual models for direct access
@admin.register(AboutStat)
class AboutStatAdmin(admin.ModelAdmin):
    list_display = ['banner', 'number', 'label', 'order']
    list_filter = ['banner']
    ordering = ['banner', 'order']


@admin.register(AboutSocialLink)
class AboutSocialLinkAdmin(admin.ModelAdmin):
    list_display = ['banner', 'platform', 'url', 'order']
    list_filter = ['banner', 'platform']
    ordering = ['banner', 'order']


@admin.register(AboutFeature)
class AboutFeatureAdmin(admin.ModelAdmin):
    list_display = ['service', 'title', 'order']
    list_filter = ['service']
    ordering = ['service', 'order']


@admin.register(AboutProcessStep)
class AboutProcessStepAdmin(admin.ModelAdmin):
    list_display = ['process', 'step_number', 'title', 'order']
    list_filter = ['process']
    ordering = ['process', 'order']


@admin.register(AboutMilestone)
class AboutMilestoneAdmin(admin.ModelAdmin):
    list_display = ['journey', 'year', 'title', 'order']
    list_filter = ['journey']
    ordering = ['journey', 'order']