/**
 * Accounting nested navigation — mirrors enterprise sidebar design (phases 5.1–5.12).
 * AI module stays blocked until provider is Active.
 */
import type { LucideIcon } from "lucide-react";
import {
  LayoutDashboard,
  Wallet,
  ShoppingCart,
  ShoppingBag,
  FileText,
  Briefcase,
  Building2,
  Package,
  BookOpen,
  FileBarChart2,
  Target,
  ShieldCheck,
  Sparkles,
  Settings,
  Cable,
  FolderOpen,
  Activity,
  Scale,
  Wrench,
  Users,
  Truck,
} from "lucide-react";

export type AccountingNavItem = {
  href: string;
  label: string;
  blocked?: boolean;
};

export type AccountingNavGroup = {
  id: string;
  label: string;
  icon: LucideIcon;
  href?: string;
  items?: AccountingNavItem[];
  blocked?: boolean;
};

export const ACCOUNTING_NAV: AccountingNavGroup[] = [
  {
    id: "dashboard",
    label: "داشبورد",
    icon: LayoutDashboard,
    href: "/accounting",
  },
  {
    id: "treasury",
    label: "عملیات خزانه",
    icon: Wallet,
    items: [
      { href: "/accounting/treasury/receipts-payments", label: "دریافت و پرداخت" },
      { href: "/accounting/treasury/cash-boxes", label: "صندوق‌ها" },
      { href: "/accounting/treasury/banks", label: "بانک‌ها" },
      { href: "/accounting/treasury/transfers", label: "انتقال بین حساب‌ها" },
      { href: "/accounting/treasury/reconciliation", label: "تطبیق بانکی" },
      { href: "/accounting/treasury/cheques", label: "چک‌ها" },
      { href: "/accounting/treasury/cheques/new", label: "ثبت چک" },
      { href: "/accounting/treasury/guarantees", label: "ضمانت‌ها" },
      { href: "/accounting/treasury/facilities", label: "تسهیلات و اعتبارات" },
    ],
  },
  {
    id: "purchase",
    label: "عملیات خرید",
    icon: ShoppingCart,
    items: [
      { href: "/accounting/purchase/requests", label: "درخواست خرید" },
      { href: "/accounting/purchase/orders", label: "سفارش خرید" },
      { href: "/accounting/purchase/goods-receipts", label: "رسید کالا" },
      { href: "/accounting/purchase/invoices", label: "فاکتور خرید" },
      { href: "/accounting/purchase/returns", label: "مرجوعی خرید" },
      { href: "/accounting/purchase/prepayments", label: "پیش‌پرداخت‌ها" },
    ],
  },
  {
    id: "sales",
    label: "عملیات فروش",
    icon: ShoppingBag,
    items: [
      { href: "/accounting/sales/opportunities", label: "فرصت‌های فروش" },
      { href: "/accounting/sales/proformas", label: "پیش‌فاکتور" },
      { href: "/accounting/sales/orders", label: "سفارش فروش" },
      { href: "/accounting/sales/invoices", label: "فاکتور فروش" },
      { href: "/accounting/sales/returns", label: "مرجوعی فروش" },
      { href: "/accounting/sales/pre-receipts", label: "پیش‌دریافت‌ها" },
    ],
  },
  {
    id: "customers",
    label: "مشتریان",
    icon: Users,
    items: [
      { href: "/accounting/customers", label: "لیست مشتریان" },
      { href: "/accounting/sales/settlements", label: "تسویه حساب مشتریان" },
      { href: "/accounting/sales/pre-receipts", label: "پیش‌دریافت‌ها" },
      { href: "/accounting/sales/invoices", label: "فاکتور فروش" },
    ],
  },
  {
    id: "suppliers",
    label: "تأمین‌کنندگان",
    icon: Truck,
    items: [
      { href: "/accounting/suppliers", label: "لیست تأمین‌کنندگان" },
      { href: "/accounting/purchase/settlements", label: "تسویه با تأمین‌کننده" },
      { href: "/accounting/purchase/prepayments", label: "پیش‌پرداخت‌ها" },
      { href: "/accounting/purchase/invoices", label: "فاکتور خرید" },
    ],
  },
  {
    id: "vouchers",
    label: "اسناد حسابداری",
    icon: FileText,
    items: [
      { href: "/accounting/vouchers/new", label: "صدور سند" },
      { href: "/accounting/vouchers", label: "لیست اسناد" },
      { href: "/accounting/vouchers?source=auto", label: "اسناد سیستمی" },
      { href: "/accounting/vouchers?status=draft", label: "اسناد پیش‌نویس" },
      { href: "/accounting/vouchers/recurring", label: "اسناد تکراری" },
      { href: "/accounting/vouchers/adjustments", label: "اسناد اصلاحی" },
      { href: "/accounting/vouchers?status=reversed", label: "اسناد برگشتی" },
      { href: "/accounting/vouchers?status=posted", label: "تأیید و ثبت اسناد" },
      { href: "/accounting/vouchers/templates", label: "الگوی سند" },
    ],
  },
  {
    id: "payroll",
    label: "حقوق و دستمزد",
    icon: Briefcase,
    items: [
      { href: "/accounting/payroll/employees", label: "کارمندان" },
      { href: "/accounting/payroll/contracts", label: "تعریف قرارداد" },
      { href: "/accounting/payroll/structures", label: "ساختار حقوق" },
      { href: "/accounting/payroll/items", label: "اقلام حقوق و مزایا" },
      { href: "/accounting/payroll/calculate", label: "محاسبه حقوق" },
      { href: "/accounting/payroll/payments", label: "پرداخت حقوق" },
      { href: "/accounting/payroll/allocation", label: "تسهیم هزینه حقوق" },
      { href: "/accounting/payroll/reports", label: "گزارش‌های حقوق" },
    ],
  },
  {
    id: "assets",
    label: "دارایی‌های ثابت",
    icon: Building2,
    items: [
      { href: "/accounting/assets", label: "ثبت دارایی" },
      { href: "/accounting/assets/dashboard", label: "داشبورد دارایی" },
      { href: "/accounting/assets/depreciate", label: "محاسبه استهلاک" },
      { href: "/accounting/assets/schedule", label: "برنامه استهلاک" },
      { href: "/accounting/assets/transfers", label: "انتقال دارایی" },
      { href: "/accounting/assets/accumulated", label: "استهلاک انباشته" },
      { href: "/accounting/assets/valuation", label: "ارزش‌گذاری دارایی" },
      { href: "/accounting/assets/dispose", label: "معرفی و فروش دارایی" },
    ],
  },
  {
    id: "inventory",
    label: "حسابداری انبار",
    icon: Package,
    items: [
      { href: "/accounting/inventory/items", label: "کارت کالا / خدمت" },
      { href: "/accounting/inventory/movements", label: "گردش کالا" },
      { href: "/accounting/inventory/valuation", label: "ارزش‌گذاری موجودی" },
      { href: "/accounting/inventory/settings", label: "تنظیمات انبار" },
      { href: "/accounting/inventory/transfers", label: "انتقال انبار" },
      { href: "/accounting/inventory/receipts-issues", label: "رسید ورود و خروج" },
      { href: "/accounting/inventory/issues", label: "خروج / هزینه‌کرد کالا" },
      { href: "/accounting/inventory/adjustments", label: "تعدیل موجودی" },
      { href: "/accounting/inventory/reports", label: "گزارش‌های انبار" },
    ],
  },
  {
    id: "coa",
    label: "حساب‌ها و سرفصل‌ها",
    icon: BookOpen,
    items: [
      { href: "/accounting/chart-of-accounts", label: "دسته‌بندی حساب‌ها" },
      { href: "/accounting/chart-of-accounts?level=ledger", label: "حساب‌های کل" },
      { href: "/accounting/chart-of-accounts?level=subsidiary", label: "حساب‌های معین" },
      { href: "/accounting/chart-of-accounts?level=detail", label: "حساب‌های تفصیلی" },
      { href: "/accounting/cost-centers", label: "مراکز هزینه" },
      { href: "/accounting/projects", label: "پروژه‌ها" },
      { href: "/accounting/chart-of-accounts", label: "تنظیمات ساختار" },
      { href: "/accounting/ledger", label: "دفتر کل" },
    ],
  },
  {
    id: "reports",
    label: "گزارشات مالی",
    icon: FileBarChart2,
    items: [
      { href: "/accounting/reports?type=balance-sheet", label: "ترازنامه" },
      { href: "/accounting/reports?type=income-statement", label: "سود و زیان" },
      { href: "/accounting/reports?type=cash-flow", label: "جریان وجوه نقد" },
      { href: "/accounting/reports?type=equity", label: "تغییرات حقوق صاحبان سهام" },
      { href: "/accounting/reports?type=trial-balance", label: "تراز آزمایشی" },
      { href: "/accounting/reports?type=subsidiary", label: "گزارش معین" },
      { href: "/accounting/reports?type=detail", label: "گزارش تفصیلی" },
      { href: "/accounting/reports?type=analytical", label: "گزارش تحلیلی" },
    ],
  },
  {
    id: "budget",
    label: "بودجه و کنترل مالی",
    icon: Target,
    items: [
      { href: "/accounting/budget/definitions", label: "تعریف بودجه" },
      { href: "/accounting/budget/operational", label: "بودجه‌ریزی عملیاتی" },
      { href: "/accounting/budget/control", label: "کنترل بودجه" },
      { href: "/accounting/budget/variance", label: "تحلیل انحراف بودجه" },
      { href: "/accounting/budget/performance", label: "مقایسه عملکرد" },
      { href: "/accounting/budget/forecast", label: "پیش‌بینی مالی" },
      { href: "/accounting/budget/scenarios", label: "سناریوهای مالی" },
      { href: "/accounting/budget/reports", label: "گزارش بودجه" },
    ],
  },
  {
    id: "compliance",
    label: "کنترل و انطباق",
    icon: ShieldCheck,
    items: [
      { href: "/accounting/compliance/policies", label: "سیاست‌ها و قوانین" },
      { href: "/accounting/compliance/approvals", label: "گردش تأیید" },
      { href: "/accounting/compliance/sod", label: "تفکیک وظایف (SoD)" },
      { href: "/accounting/compliance/controls", label: "کنترل‌های داخلی" },
      { href: "/accounting/compliance/risks", label: "مدیریت ریسک" },
      { href: "/accounting/audit", label: "انطباق و حسابرسی" },
      { href: "/accounting/compliance/records", label: "اسناد و سوابق" },
      { href: "/accounting/compliance/violations", label: "گزارش تخلفات" },
    ],
  },
  {
    id: "ai",
    label: "هوش مصنوعی",
    icon: Sparkles,
    blocked: true,
    items: [
      { href: "/accounting/ai", label: "دستیار حسابداری", blocked: true },
      { href: "/accounting/ai/qa", label: "پرسش و پاسخ", blocked: true },
      { href: "/accounting/ai/analytics", label: "تحلیل هوشمند", blocked: true },
      { href: "/accounting/ai/forecasts", label: "پیش‌بینی‌ها", blocked: true },
      { href: "/accounting/ai/anomalies", label: "کشف ناهنجاری", blocked: true },
      { href: "/accounting/ai/reconciliation", label: "تطبیق هوشمند", blocked: true },
      { href: "/accounting/ai/documents", label: "تحلیل اسناد", blocked: true },
      { href: "/accounting/ai/recommendations", label: "پیشنهادهای هوشمند", blocked: true },
    ],
  },
  {
    id: "settings",
    label: "تنظیمات سیستم",
    icon: Settings,
    items: [
      { href: "/accounting/settings/company", label: "اطلاعات شرکت" },
      { href: "/accounting/fiscal", label: "دوره‌های مالی" },
      { href: "/accounting/currencies", label: "ارزها و نرخ‌ها" },
      { href: "/accounting/settings", label: "تنظیمات حسابداری" },
      { href: "/accounting/settings/auto-posting", label: "اسناد اتوماتیک" },
      { href: "/accounting/settings/tax", label: "تنظیمات مالیاتی" },
      { href: "/accounting/settings/general", label: "تنظیمات عمومی" },
      { href: "/dashboard/settings", label: "کاربران و دسترسی" },
      { href: "/accounting/settings/backup", label: "پشتیبان‌گیری" },
    ],
  },
  {
    id: "integration",
    label: "یکپارچه‌سازی",
    icon: Cable,
    items: [
      { href: "/accounting/integration/bank", label: "اتصال بانک" },
      { href: "/accounting/integration/gateway", label: "درگاه پرداخت" },
      { href: "/accounting/integration/crm", label: "اتصال CRM" },
      { href: "/accounting/integration/inventory", label: "اتصال انبار" },
      { href: "/accounting/integration/payroll", label: "اتصال حقوق" },
      { href: "/accounting/integration/webhooks", label: "وب‌سرویس‌ها" },
      { href: "/accounting/integration/import-export", label: "ورود / خروج داده" },
      { href: "/accounting/integration/reports", label: "گزارش یکپارچگی" },
    ],
  },
  {
    id: "documents",
    label: "مدیریت اسناد",
    icon: FolderOpen,
    items: [
      { href: "/accounting/documents/financial", label: "اسناد مالی" },
      { href: "/accounting/documents/purchase", label: "اسناد خرید" },
      { href: "/accounting/documents/sales", label: "اسناد فروش" },
      { href: "/accounting/documents/hr", label: "اسناد پرسنلی" },
      { href: "/accounting/documents/categories", label: "دسته‌بندی" },
      { href: "/accounting/documents/search", label: "جستجوی اسناد" },
      { href: "/accounting/documents/versions", label: "نسخه‌های سند" },
      { href: "/accounting/documents/retention", label: "نگهداری" },
    ],
  },
  {
    id: "monitoring",
    label: "مانیتورینگ و نظارت",
    icon: Activity,
    items: [
      { href: "/accounting/monitoring", label: "داشبورد نظارتی" },
      { href: "/accounting/monitoring/recent", label: "عملیات اخیر" },
      { href: "/accounting/monitoring/alerts", label: "هشدارها" },
      { href: "/accounting/monitoring/activity", label: "فعالیت کاربران" },
      { href: "/accounting/audit", label: "لاگ سیستم" },
      { href: "/accounting/monitoring/health", label: "وضعیت سرویس" },
      { href: "/accounting/monitoring/kpis", label: "شاخص‌های کلیدی" },
      { href: "/accounting/monitoring/performance", label: "عملکرد سیستم" },
    ],
  },
  {
    id: "setup",
    label: "راه‌اندازی",
    icon: Wrench,
    href: "/accounting/setup",
  },
];

export const ACCOUNTING_QUICK_BAR: AccountingNavItem[] = [
  { href: "/accounting/vouchers/new", label: "صدور سند" },
  { href: "/accounting/treasury/receipts-payments", label: "دریافت/پرداخت" },
  { href: "/accounting/sales/invoices", label: "فاکتور فروش" },
  { href: "/accounting/treasury/cheques/new", label: "ثبت چک" },
  { href: "/accounting/reports", label: "گزارشات" },
  { href: "/accounting", label: "داشبورد" },
];

export const LEGACY_SHORTCUTS = [
  { href: "/accounting/ledger", label: "دفتر کل", icon: Scale },
];
