namespace BackOffice.Services.Content;

public interface ISitePageSettingsService
{
    Task<List<PageSettingsSummaryDto>> GetAllAsync();
    Task<PageSettingsDetailsDto?> GetByKeyAsync(string pageKey);
    Task<SaveResultDto> SaveSettingsAsync(SavePageSettingsDto dto);
    Task<SaveResultDto> SaveImageAsync(SavePageImageDto dto);
    Task DeleteImageAsync(long id);
}

// ── Summary DTO (لیست صفحات) ──
public class PageSettingsSummaryDto
{
    public long Id { get; set; }
    public string PageKey { get; set; } = string.Empty;
    public string Title { get; set; } = string.Empty;
    public bool IsActive { get; set; }
    public int ImageCount { get; set; }
    public DateTime LastModified { get; set; }
}

// ── Details DTO (تنظیمات کامل + تصاویر) ──
public class PageSettingsDetailsDto
{
    public long Id { get; set; }
    public string PageKey { get; set; } = string.Empty;
    public string Title { get; set; } = string.Empty;
    public string? MetaDescription { get; set; }
    public string? HeroTitle { get; set; }
    public string? HeroSubtitle { get; set; }
    public string? HeroImagePath { get; set; }
    public bool IsActive { get; set; }
    public string? SettingsJson { get; set; }
    public List<PageImageItemDto> Images { get; set; } = new();
}

// ── Image Item DTO ──
public class PageImageItemDto
{
    public long Id { get; set; }
    public string ImageGroup { get; set; } = string.Empty;
    public string? Title { get; set; }
    public string? Subtitle { get; set; }
    public string? Description { get; set; }
    public string ImagePath { get; set; } = string.Empty;
    public string? ThumbnailPath { get; set; }
    public string? LinkUrl { get; set; }
    public string? IconName { get; set; }
    public int SortOrder { get; set; }
    public bool IsActive { get; set; }
}

// ── Save Settings DTO ──
public class SavePageSettingsDto
{
    public string PageKey { get; set; } = string.Empty;
    public string Title { get; set; } = string.Empty;
    public string? MetaDescription { get; set; }
    public string? HeroTitle { get; set; }
    public string? HeroSubtitle { get; set; }
    public bool IsActive { get; set; } = true;
    public string? SettingsJson { get; set; }

    // Hero image upload
    public byte[]? ImageFile { get; set; }
    public string? ImageMime { get; set; }
    public string? ImageFileName { get; set; }
}

// ── Save Image DTO ──
public class SavePageImageDto
{
    public long Id { get; set; } // 0 = جدید
    public long SitePageSettingsId { get; set; }
    public string ImageGroup { get; set; } = string.Empty;
    public string? Title { get; set; }
    public string? Subtitle { get; set; }
    public string? Description { get; set; }
    public string? LinkUrl { get; set; }
    public string? IconName { get; set; }
    public int SortOrder { get; set; }
    public bool IsActive { get; set; } = true;

    // Image upload
    public byte[]? ImageFile { get; set; }
    public string? ImageMime { get; set; }
    public string? ImageFileName { get; set; }
}

// ── Save Result ──
public class SaveResultDto
{
    public long Id { get; set; }
    public bool Success { get; set; }
}
