import { Component, signal } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';

interface PhaseLink {
  route: string;
  icon: string;
  label: string;
  desc: string;
}

interface Phase {
  number: number;
  icon: string;
  title: string;
  desc: string;
  details: string;
  scenarios: string;
  color: string;
  iconBg: string;
  numberBg: string;
  linkBg: string;
  linkHover: string;
  links: PhaseLink[];
}

@Component({
  selector: 'app-accounting-guide',
  standalone: true,
  imports: [CommonModule, RouterModule, TranslateModule],
  templateUrl: './accounting-guide.html',
  styleUrl: './accounting-guide.scss',
})
export class AccountingGuide {
  expandedPhase = signal<number | null>(null);

  togglePhase(n: number): void {
    this.expandedPhase.update(v => v === n ? null : n);
  }

  phases: Phase[] = [
    {
      number: 1,
      icon: 'pi pi-cog',
      title: 'GUIDE.PHASE1_TITLE',
      desc: 'GUIDE.PHASE1_DESC',
      details: 'GUIDE.PHASE1_DETAILS',
      scenarios: 'GUIDE.PHASE1_SCENARIOS',
      color: 'blue',
      iconBg: 'bg-gradient-to-br from-blue-500 to-blue-600',
      numberBg: 'bg-blue-500',
      linkBg: 'bg-blue-500/10 text-blue-600',
      linkHover: 'hover:bg-blue-500/20',
      links: [
        { route: '/accounting/accounts', icon: 'pi pi-sitemap', label: 'NAV.CHART_OF_ACCOUNTS', desc: 'GUIDE.LINK_ACCOUNTS' },
        { route: '/accounting/fiscal-years', icon: 'pi pi-calendar', label: 'NAV.FISCAL_YEARS', desc: 'GUIDE.LINK_FISCAL' },
        { route: '/accounting/currencies', icon: 'pi pi-money-bill', label: 'NAV.CURRENCIES', desc: 'GUIDE.LINK_CURRENCIES' },
        { route: '/accounting/tax-rates', icon: 'pi pi-percentage', label: 'NAV.TAX_RATES', desc: 'GUIDE.LINK_TAX' },
        { route: '/accounting/opening-balances', icon: 'pi pi-replay', label: 'NAV.OPENING_BALANCES', desc: 'GUIDE.LINK_OPENING' },
        { route: '/accounting/cost-centers', icon: 'pi pi-chart-pie', label: 'NAV.COST_CENTERS', desc: 'GUIDE.LINK_COST_CENTERS' },
      ],
    },
    {
      number: 2,
      icon: 'pi pi-bolt',
      title: 'GUIDE.PHASE2_TITLE',
      desc: 'GUIDE.PHASE2_DESC',
      details: 'GUIDE.PHASE2_DETAILS',
      scenarios: 'GUIDE.PHASE2_SCENARIOS',
      color: 'rose',
      iconBg: 'bg-gradient-to-br from-rose-500 to-rose-600',
      numberBg: 'bg-rose-500',
      linkBg: 'bg-rose-500/10 text-rose-600',
      linkHover: 'hover:bg-rose-500/20',
      links: [
        { route: '/accounting/expense-categories', icon: 'pi pi-tags', label: 'NAV.EXPENSE_CATEGORIES', desc: 'GUIDE.LINK_EXP_CATS' },
        { route: '/accounting/revenue-categories', icon: 'pi pi-tags', label: 'NAV.REVENUE_CATEGORIES', desc: 'GUIDE.LINK_REV_CATS' },
        { route: '/accounting/expenses', icon: 'pi pi-minus-circle', label: 'NAV.EXPENSES', desc: 'GUIDE.LINK_EXPENSES' },
        { route: '/accounting/revenues', icon: 'pi pi-plus-circle', label: 'NAV.REVENUES', desc: 'GUIDE.LINK_REVENUES' },
        { route: '/accounting/receipt-vouchers', icon: 'pi pi-download', label: 'NAV.RECEIPT_VOUCHERS', desc: 'GUIDE.LINK_RECEIPT' },
        { route: '/accounting/payment-vouchers', icon: 'pi pi-upload', label: 'NAV.PAYMENT_VOUCHERS', desc: 'GUIDE.LINK_PAYMENT' },
      ],
    },
    {
      number: 3,
      icon: 'pi pi-book',
      title: 'GUIDE.PHASE3_TITLE',
      desc: 'GUIDE.PHASE3_DESC',
      details: 'GUIDE.PHASE3_DETAILS',
      scenarios: 'GUIDE.PHASE3_SCENARIOS',
      color: 'emerald',
      iconBg: 'bg-gradient-to-br from-emerald-500 to-emerald-600',
      numberBg: 'bg-emerald-500',
      linkBg: 'bg-emerald-500/10 text-emerald-600',
      linkHover: 'hover:bg-emerald-500/20',
      links: [
        { route: '/accounting/journal-entries', icon: 'pi pi-book', label: 'NAV.JOURNAL_ENTRIES', desc: 'GUIDE.LINK_ENTRIES' },
        { route: '/accounting/entry-templates', icon: 'pi pi-copy', label: 'NAV.ENTRY_TEMPLATES', desc: 'GUIDE.LINK_TEMPLATES' },
        { route: '/accounting/recurring-entries', icon: 'pi pi-sync', label: 'NAV.RECURRING_ENTRIES', desc: 'GUIDE.LINK_RECURRING' },
      ],
    },
    {
      number: 4,
      icon: 'pi pi-wallet',
      title: 'GUIDE.PHASE4_TITLE',
      desc: 'GUIDE.PHASE4_DESC',
      details: 'GUIDE.PHASE4_DETAILS',
      scenarios: 'GUIDE.PHASE4_SCENARIOS',
      color: 'purple',
      iconBg: 'bg-gradient-to-br from-purple-500 to-purple-600',
      numberBg: 'bg-purple-500',
      linkBg: 'bg-purple-500/10 text-purple-600',
      linkHover: 'hover:bg-purple-500/20',
      links: [
        { route: '/accounting/bank-accounts', icon: 'pi pi-building-columns', label: 'NAV.BANK_ACCOUNTS', desc: 'GUIDE.LINK_BANK' },
        { route: '/accounting/petty-cash', icon: 'pi pi-wallet', label: 'NAV.PETTY_CASH', desc: 'GUIDE.LINK_PETTY' },
        { route: '/accounting/transfers', icon: 'pi pi-arrows-h', label: 'NAV.TRANSFERS', desc: 'GUIDE.LINK_TRANSFERS' },
        { route: '/accounting/checks-received', icon: 'pi pi-inbox', label: 'NAV.CHECKS_RECEIVED', desc: 'GUIDE.LINK_CHK_RECV' },
        { route: '/accounting/checks-issued', icon: 'pi pi-send', label: 'NAV.CHECKS_ISSUED', desc: 'GUIDE.LINK_CHK_ISSUED' },
        { route: '/accounting/bank-reconciliations', icon: 'pi pi-check-square', label: 'NAV.BANK_RECONCILIATIONS', desc: 'GUIDE.LINK_RECON' },
      ],
    },
    {
      number: 5,
      icon: 'pi pi-building',
      title: 'GUIDE.PHASE5_TITLE',
      desc: 'GUIDE.PHASE5_DESC',
      details: 'GUIDE.PHASE5_DETAILS',
      scenarios: 'GUIDE.PHASE5_SCENARIOS',
      color: 'amber',
      iconBg: 'bg-gradient-to-br from-amber-500 to-amber-600',
      numberBg: 'bg-amber-500',
      linkBg: 'bg-amber-500/10 text-amber-600',
      linkHover: 'hover:bg-amber-500/20',
      links: [
        { route: '/accounting/asset-categories', icon: 'pi pi-tags', label: 'NAV.ASSET_CATEGORIES', desc: 'GUIDE.LINK_ASSET_CATS' },
        { route: '/accounting/fixed-assets', icon: 'pi pi-building', label: 'NAV.FIXED_ASSETS', desc: 'GUIDE.LINK_ASSETS' },
        { route: '/accounting/allocation-rules', icon: 'pi pi-percentage', label: 'NAV.ALLOCATION_RULES', desc: 'GUIDE.LINK_ALLOC' },
      ],
    },
    {
      number: 6,
      icon: 'pi pi-search',
      title: 'GUIDE.PHASE6_TITLE',
      desc: 'GUIDE.PHASE6_DESC',
      details: 'GUIDE.PHASE6_DETAILS',
      scenarios: 'GUIDE.PHASE6_SCENARIOS',
      color: 'indigo',
      iconBg: 'bg-gradient-to-br from-indigo-500 to-indigo-600',
      numberBg: 'bg-indigo-500',
      linkBg: 'bg-indigo-500/10 text-indigo-600',
      linkHover: 'hover:bg-indigo-500/20',
      links: [
        { route: '/accounting/ledger', icon: 'pi pi-list', label: 'NAV.GENERAL_LEDGER', desc: 'GUIDE.LINK_LEDGER' },
        { route: '/accounting/budgets', icon: 'pi pi-chart-bar', label: 'NAV.BUDGETS', desc: 'GUIDE.LINK_BUDGETS' },
        { route: '/accounting/ar-ap', icon: 'pi pi-users', label: 'NAV.AR_AP', desc: 'GUIDE.LINK_ARAP' },
        { route: '/accounting/reports', icon: 'pi pi-chart-line', label: 'NAV.REPORTS', desc: 'GUIDE.LINK_REPORTS' },
      ],
    },
    {
      number: 7,
      icon: 'pi pi-lock',
      title: 'GUIDE.PHASE7_TITLE',
      desc: 'GUIDE.PHASE7_DESC',
      details: 'GUIDE.PHASE7_DETAILS',
      scenarios: 'GUIDE.PHASE7_SCENARIOS',
      color: 'teal',
      iconBg: 'bg-gradient-to-br from-teal-500 to-teal-600',
      numberBg: 'bg-teal-500',
      linkBg: 'bg-teal-500/10 text-teal-600',
      linkHover: 'hover:bg-teal-500/20',
      links: [
        { route: '/accounting/fiscal-years', icon: 'pi pi-calendar', label: 'GUIDE.LINK_CLOSE_PERIODS', desc: 'GUIDE.LINK_CLOSE_PERIODS_DESC' },
        { route: '/accounting/year-end-closing', icon: 'pi pi-lock', label: 'NAV.YEAR_END_CLOSING', desc: 'GUIDE.LINK_YEAR_END' },
        { route: '/accounting/reconciliation-rules', icon: 'pi pi-check-circle', label: 'NAV.RECONCILIATION_RULES', desc: 'GUIDE.LINK_RECON_RULES' },
      ],
    },
  ];
}
