export type Severity = 'critical' | 'warning' | 'good' | 'excellent' | 'unknown';

export interface ScreenshotAnnotation {
  type: 'highlight' | 'arrow' | 'text';
  x: number;
  y: number;
  width?: number;
  height?: number;
  label?: string;
  color?: string;
}

export interface ScreenshotEvidence {
  id: string;
  url: string;
  channel: string;
  capturedAt: string;
  caption: string;
  sourceUrl?: string;
  annotations?: ScreenshotAnnotation[];
}

export interface DiagnosisItem {
  category: string;
  detail: string;
  severity: Severity;
  evidenceIds?: string[];
}

export interface ClinicSnapshot {
  name: string;
  nameEn: string;
  established: string;
  yearsInBusiness: number;
  staffCount: number;
  leadDoctor: {
    name: string;
    credentials: string;
    rating: number;
    reviewCount: number;
  };
  overallRating: number;
  totalReviews: number;
  priceRange: { min: string; max: string; currency: string };
  certifications: string[];
  mediaAppearances: string[];
  medicalTourism: string[];
  location: string;
  nearestStation: string;
  phone: string;
  domain: string;
  logoImages?: {
    circle?: string;
    horizontal?: string;
    korean?: string;
  };
  brandColors?: {
    primary: string;
    accent: string;
    text: string;
  };
  /** 'registry' = Registry DB에서 검증된 채널로 분석. 'scrape' = 홈페이지 실시간 탐색. */
  source?: 'registry' | 'scrape';
  /** Registry에서 가져온 병원 메타데이터 */
  registryData?: {
    district?: string;    // 지역구 (강남, 압구정, 서초, 역삼)
    branches?: string;    // 분점 정보
    brandGroup?: string;  // 분류 (프리미엄/하이타깃 후보)
    websiteEn?: string;   // 영문 사이트 URL
    naverPlaceUrl?: string;
    gangnamUnniUrl?: string;
    googleMapsUrl?: string;
  };
}

export interface TopVideo {
  title: string;
  views: number;
  uploadedAgo: string;
  type: 'Short' | 'Long';
  duration?: string;
}

export interface YouTubeAudit {
  channelName: string;
  handle: string;
  subscribers: number;
  totalVideos: number;
  totalViews: number;
  weeklyViewGrowth: { absolute: number; percentage: number };
  estimatedMonthlyRevenue: { min: number; max: number };
  avgVideoLength: string;
  uploadFrequency: string;
  channelCreatedDate: string;
  subscriberRank: string;
  channelDescription: string;
  linkedUrls: { label: string; url: string }[];
  playlists: string[];
  topVideos: TopVideo[];
  diagnosis: DiagnosisItem[];
}

export interface InstagramAccount {
  handle: string;
  language: 'KR' | 'EN';
  label: string;
  posts: number;
  followers: number;
  following: number;
  category: string;
  profileLink: string;
  highlights: string[];
  reelsCount: number;
  contentFormat: string;
  profilePhoto: string;
  bio: string;
}

export interface InstagramAudit {
  accounts: InstagramAccount[];
  diagnosis: DiagnosisItem[];
}

export interface BrandInconsistency {
  field: string;
  values: { channel: string; value: string; isCorrect: boolean }[];
  impact: string;
  recommendation: string;
}

export interface FacebookPage {
  url: string;
  pageName: string;
  language: 'KR' | 'EN';
  label: string;
  followers: number;
  following: number;
  category: string;
  bio: string;
  logo: string;
  logoDescription: string;
  link: string;
  linkedDomain: string;
  reviews: number;
  recentPostAge: string;
  hasWhatsApp: boolean;
  postFrequency?: string;
  topContentType?: string;
  engagement?: string;
}

export interface FacebookAudit {
  pages: FacebookPage[];
  diagnosis: DiagnosisItem[];
  brandInconsistencies: BrandInconsistency[];
  consolidationRecommendation: string;
}

export interface OtherChannel {
  name: string;
  status: 'active' | 'inactive' | 'unknown' | 'not_found';
  details: string;
  url?: string;
}

export interface TrackingPixel {
  name: string;
  installed: boolean;
  details?: string;
}

export interface WebsiteAudit {
  primaryDomain: string;
  additionalDomains: { domain: string; purpose: string }[];
  snsLinksOnSite: boolean;
  snsLinksDetail?: { platform: string; url: string; location: string }[];
  trackingPixels: TrackingPixel[];
  mainCTA: string;
}

export interface AsIsToBeItem {
  area: string;
  asIs: string;
  toBe: string;
}

export interface PlatformStrategy {
  platform: string;
  icon: string;
  currentMetric: string;
  targetMetric: string;
  strategies: { strategy: string; detail: string }[];
}

export interface TransformationProposal {
  brandIdentity: AsIsToBeItem[];
  contentStrategy: AsIsToBeItem[];
  platformStrategies: PlatformStrategy[];
  websiteImprovements: AsIsToBeItem[];
  newChannelProposals: { channel: string; priority: string; rationale: string }[];
}

export interface RoadmapMonth {
  month: number;
  title: string;
  subtitle: string;
  tasks: { task: string; completed: boolean }[];
}

export interface KPIMetric {
  metric: string;
  current: string;
  target3Month: string;
  target12Month: string;
}

export interface ChannelScore {
  channel: string;
  icon: string;
  score: number;
  maxScore: number;
  status: Severity;
  headline: string;
}

export interface MarketingReport {
  id: string;
  createdAt: string;
  targetUrl: string;
  overallScore: number;
  clinicSnapshot: ClinicSnapshot;
  channelScores: ChannelScore[];
  youtubeAudit: YouTubeAudit;
  instagramAudit: InstagramAudit;
  facebookAudit: FacebookAudit;
  otherChannels: OtherChannel[];
  websiteAudit: WebsiteAudit;
  problemDiagnosis: DiagnosisItem[];
  transformation: TransformationProposal;
  roadmap: RoadmapMonth[];
  kpiDashboard: KPIMetric[];
  screenshots?: ScreenshotEvidence[];
}
