<?php

namespace App\Helpers;

use Illuminate\Support\Facades\Auth;
use Throwable;

class MenuHelper
{
    public static function getMainNavItems()
    {
        $user = Auth::user();
        $items = [];

        // =========================
        // CORE
        // =========================
        $items[] = [
            'icon' => 'dashboard',
            'name' => ($user && method_exists($user, 'isDeveloper') && $user->isDeveloper())
                ? 'Developer Dashboard'
                : 'Dashboard',
            'path' => '/',
        ];

        // AI
        if (self::canAny($user, ['view ai', 'access ai', 'ai.sales', 'ai.index'])) {
            $items[] = [
                'icon' => 'ai',
                'name' => 'Intelligence',
                'path' => '/ai/sales',
                'pro'  => true,
            ];
        }

        // =========================
        // ORDERS
        // =========================
        $orderSubItems = [];

        if (self::canAny($user, ['view orders', 'create orders'])) {
            $orderSubItems[] = ['name' => 'Daftar Order', 'path' => '/orders'];
        }

        if (self::canAny($user, ['create orders'])) {
            $orderSubItems[] = ['name' => 'Buat Order', 'path' => '/orders/create', 'new' => true];
        }

        if (self::canAny($user, [
            'view delivery notes',
            'create delivery notes',
            'edit delivery notes',
            'print delivery notes',
            'manage delivery notes',
            // fallback permission lama
            'view orders',
            'create orders',
            'print spk',
            'process payments',
        ])) {
            $orderSubItems[] = ['name' => 'Surat Jalan', 'path' => '/delivery-notes', 'new' => true];
        }

        if (!empty($orderSubItems)) {
            $items[] = [
                'icon' => 'forms',
                'name' => 'Orders',
                'subItems' => $orderSubItems,
            ];
        }

        // =========================
        // CASHIER
        // =========================
        $cashierSubItems = [];

        if (self::canAny($user, ['view cashier bills', 'process payments'])) {
            $cashierSubItems[] = ['name' => 'Tagihan', 'path' => '/kasir'];
        }

        if (self::canAny($user, ['view cashier payoff', 'process payments'])) {
            $cashierSubItems[] = ['name' => 'Pelunasan', 'path' => '/kasir/pelunasan'];
        }

        if (self::canAny($user, ['view cashier history', 'manage payments', 'process payments'])) {
            $cashierSubItems[] = ['name' => 'Riwayat', 'path' => '/kasir/history'];
        }

        if (self::canAny($user, ['view cashier pricelist', 'process payments'])) {
            $cashierSubItems[] = ['name' => 'Pricelist', 'path' => '/kasir/pricelist'];
        }

        if (!empty($cashierSubItems)) {
            $items[] = [
                'icon' => 'ecommerce',
                'name' => 'Kasir',
                'subItems' => $cashierSubItems,
            ];
        }

        // =========================
        // PRODUCTION
        // =========================
        $productionSubItems = [];

        if (self::canAny($user, ['view production queue', 'update production', 'manage production'])) {
            $productionSubItems[] = ['name' => 'Antrian Cetak', 'path' => '/produksi'];
        }

        if (self::canAny($user, ['view production history', 'manage production', 'update production'])) {
            $productionSubItems[] = ['name' => 'Riwayat', 'path' => '/produksi/history'];
        }

        if (!empty($productionSubItems)) {
            $items[] = [
                'icon' => 'task',
                'name' => 'Produksi',
                'subItems' => $productionSubItems,
            ];
        }

        // =========================
        // CANCELLATION
        // =========================
        if (self::canAny($user, ['view cancellations', 'approve cancellations'])) {
            $items[] = [
                'icon' => 'authentication',
                'name' => 'Pembatalan',
                'path' => '/cancellations',
            ];
        }

        // =========================
        // ATTENDANCE
        // =========================
        if ($user) {
            $attendanceSubItems = [];

            // Absensi pribadi tetap tampil untuk semua user login.
            $attendanceSubItems[] = [
                'name' => 'Absensi',
                'path' => '/attendance',
                'new' => true,
            ];

            if (self::canAny($user, ['view attendance recap', 'manage attendance', 'view employees'])) {
                $attendanceSubItems[] = [
                    'name' => 'Rekap Absensi',
                    'path' => '/attendance/recap',
                ];
            }

            if (self::canAny($user, ['manage attendance settings', 'manage attendance', 'manage settings'])) {
                $attendanceSubItems[] = [
                    'name' => 'Pengaturan Absensi',
                    'path' => '/attendance-settings',
                ];
            }

            $items[] = [
                'icon' => 'attendance',
                'name' => 'Absensi',
                'subItems' => $attendanceSubItems,
            ];
        }

        // =========================
        // FINANCE
        // =========================
        $financeSubItems = [];

        if (self::canAny($user, ['view finance'])) {
            $financeSubItems[] = ['name' => 'Laporan Keuangan', 'path' => '/finance'];
        }

        if (self::canAny($user, ['view finance cash', 'view finance'])) {
            $financeSubItems[] = ['name' => 'Laporan Kas', 'path' => '/finance/cash'];
        }

        if (self::canAny($user, ['manage deposits', 'view finance'])) {
            $financeSubItems[] = ['name' => 'Data Setoran', 'path' => '/finance/deposits', 'new' => true];
        }

        if (!empty($financeSubItems)) {
            $items[] = [
                'icon' => 'wallet',
                'name' => 'Data Keuangan',
                'subItems' => $financeSubItems,
            ];
        }

        // =========================
        // BOOKKEEPING / PEMBUKUAN
        // =========================
        $bookkeepingSubItems = [];

        if (self::canAny($user, ['view general journal', 'view reports'])) {
            $bookkeepingSubItems[] = ['name' => 'Jurnal Umum', 'path' => '/reports/general-journal'];
        }

        if (self::canAny($user, ['view profit loss', 'view reports'])) {
            $bookkeepingSubItems[] = ['name' => 'Laba - Rugi', 'path' => '/reports/profit-loss'];
        }

        if (self::canAny($user, ['view balance sheet', 'view reports'])) {
            $bookkeepingSubItems[] = ['name' => 'Neraca', 'path' => '/reports/balance-sheet', 'new' => true];
        }

        if (!empty($bookkeepingSubItems)) {
            $items[] = [
                'icon' => 'book',
                'name' => 'Pembukuan',
                'subItems' => $bookkeepingSubItems,
            ];
        }

        // =========================
        // REPORTS
        // =========================
        $reportSubItems = [];

        if (self::canAny($user, ['view cash ledger', 'view reports'])) {
            $reportSubItems[] = ['name' => 'Buku Besar', 'path' => '/reports/cash-ledger', 'new' => false];
        }

        if (self::canAny($user, ['view receivables report', 'view reports'])) {
            $reportSubItems[] = ['name' => 'Piutang', 'path' => '/reports/receivables'];
        }

        if (self::canAny($user, ['view sales reports', 'view reports'])) {
            $reportSubItems[] = ['name' => 'Omset', 'path' => '/reports/sales', 'new' => false];
        }

        if (self::canAny($user, ['view revenue reports', 'view reports'])) {
            $reportSubItems[] = ['name' => 'Pendapatan', 'path' => '/reports/revenue'];
        }

        if (self::canAny($user, ['view purchase debt reports', 'view reports'])) {
            $reportSubItems[] = ['name' => 'Hutang', 'path' => '/reports/purchase-debt'];
        }

        if (self::canAny($user, ['view click reports', 'view reports'])) {
            $reportSubItems[] = ['name' => 'Klik', 'path' => '/reports/clicks'];
        }

        if (self::canAny($user, ['view transaction logs', 'view reports'])) {
            $reportSubItems[] = ['name' => 'Log Transaksi', 'path' => '/reports/transactions'];
        }

        if (!empty($reportSubItems)) {
            $items[] = [
                'icon' => 'charts',
                'name' => 'Laporan',
                'subItems' => $reportSubItems,
            ];
        }

        // =========================
        // PRODUCTS
        // =========================
        $productSubItems = [];

        if (self::canAny($user, ['view products', 'create products', 'edit products'])) {
            $productSubItems[] = ['name' => 'Produk', 'path' => '/products/items'];
        }

        if (self::canAny($user, ['view units', 'manage units'])) {
            $productSubItems[] = ['name' => 'Satuan', 'path' => '/products/units'];
        }

        if (self::canAny($user, ['view suppliers', 'manage suppliers'])) {
            $productSubItems[] = ['name' => 'Supplier', 'path' => '/products/suppliers'];
        }

        if (!empty($productSubItems)) {
            $items[] = [
                'icon' => 'box',
                'name' => 'Data Produk',
                'subItems' => $productSubItems,
            ];
        }

        // =========================
        // STOCK
        // =========================
        $stockSubItems = [];

        if (self::canAny($user, ['view stock categories', 'manage stock categories', 'view materials', 'manage materials'])) {
            $stockSubItems[] = ['name' => 'Kategori', 'path' => '/stock/categories'];
        }

        if (self::canAny($user, ['view materials', 'manage materials'])) {
            $stockSubItems[] = ['name' => 'Bahan', 'path' => '/stock/materials'];
        }

        if (self::canAny($user, ['view machines', 'manage machines'])) {
            $stockSubItems[] = ['name' => 'Mesin', 'path' => '/stock/machines', 'new' => true];
        }

        if (self::canAny($user, ['view stock usage', 'manage stock usage', 'view stock', 'manage stock'])) {
            $stockSubItems[] = ['name' => 'Penggunaan', 'path' => '/stock/usage'];
        }

        if (self::canAny($user, ['view damaged stock', 'manage damaged stock', 'view stock', 'manage stock'])) {
            $stockSubItems[] = ['name' => 'Bahan Rusak', 'path' => '/stock/damaged'];
        }

        if (self::canAny($user, ['view stock', 'manage stock'])) {
            $stockSubItems[] = ['name' => 'Data Stok', 'path' => '/stock'];
        }

        if (self::canAny($user, ['view stock incoming', 'manage stock incoming', 'view stock', 'manage stock'])) {
            $stockSubItems[] = ['name' => 'Stok Masuk', 'path' => '/stock/incoming'];
        }

        if (!empty($stockSubItems)) {
            $items[] = [
                'icon' => 'database',
                'name' => 'Bahan & Stock',
                'subItems' => $stockSubItems,
            ];
        }

        // =========================
        // PURCHASES
        // =========================
        if (self::canAny($user, ['view purchases', 'create purchases', 'edit purchases', 'manage purchases', 'view stock'])) {
            $items[] = [
                'icon' => 'cart',
                'name' => 'Pembelian',
                'path' => '/purchases',
            ];
        }

        // =========================
        // EXPENSES
        // =========================
        $expenseSubItems = [];

        if (self::canAny($user, ['view expenses', 'create expenses', 'edit expenses', 'manage expenses'])) {
            $expenseSubItems[] = ['name' => 'Data Pengeluaran', 'path' => '/expenses'];
        }

        if (self::canAny($user, ['view expense categories', 'manage expense categories', 'view expenses'])) {
            $expenseSubItems[] = ['name' => 'Jenis Pengeluaran', 'path' => '/expense-categories'];
        }

        if (!empty($expenseSubItems)) {
            $items[] = [
                'icon' => 'receipt',
                'name' => 'Pengeluaran',
                'subItems' => $expenseSubItems,
            ];
        }

        return $items;
    }

    public static function getOthersItems()
    {
        $user = Auth::user();
        $items = [];

        if (!$user) return $items;

        // =========================
        // MASTER DATA
        // =========================
        $masterDataSubItems = [];

        if (self::canAny($user, ['view customers', 'manage customers'])) {
            $masterDataSubItems[] = ['name' => 'Pelanggan', 'path' => '/customers'];
        }

        if (self::canAny($user, ['view vehicles', 'create vehicles', 'edit vehicles', 'manage vehicles', 'manage settings', 'create orders', 'view orders'])) {
            $masterDataSubItems[] = ['name' => 'Kendaraan', 'path' => '/vehicles'];
        }

        if (self::canAny($user, ['view tax settings', 'manage tax settings', 'view ppn', 'manage ppn', 'manage settings', 'process payments'])) {
            $masterDataSubItems[] = ['name' => 'PPN / Pajak', 'path' => '/tax-settings'];
        }

        if (self::canAny($user, ['view payment accounts', 'manage payment accounts'])) {
            $masterDataSubItems[] = ['name' => 'Rekening', 'path' => '/payment-accounts'];
        }

        if (self::canAny($user, ['view users', 'manage users'])) {
            $masterDataSubItems[] = ['name' => 'Users', 'path' => '/users'];
        }

        if (self::canAny($user, ['manage roles', 'manage permissions', 'manage users'])) {
            $masterDataSubItems[] = ['name' => 'Roles', 'path' => '/roles'];
        }

        if (self::canAny($user, ['manage backups'])) {
            $masterDataSubItems[] = ['name' => 'Backup DB', 'path' => '/backups'];
        }

        if (self::canAny($user, ['view settings', 'edit settings', 'manage settings'])) {
            $masterDataSubItems[] = ['name' => 'Pengaturan', 'path' => '/settings'];
        }

        if (!empty($masterDataSubItems)) {
            $items[] = [
                'icon' => 'settings',
                'name' => 'Master Data',
                'subItems' => $masterDataSubItems,
            ];
        }

        // =========================
        // EMPLOYEE / SDM
        // =========================
        $employeeSubItems = [];

        if (self::canAny($user, ['view employees', 'create employees', 'edit employees'])) {
            $employeeSubItems[] = ['name' => 'Karyawan', 'path' => '/employees'];
        }

        if (self::canAny($user, ['view salaries', 'create salaries', 'edit salaries'])) {
            $employeeSubItems[] = ['name' => 'Gaji & Slip', 'path' => '/salaries'];
        }

        if (!empty($employeeSubItems)) {
            $items[] = [
                'icon' => 'user-profile',
                'name' => 'SDM',
                'subItems' => $employeeSubItems,
            ];
        }

        // =========================
        // MENU GUIDE
        // =========================
        $items[] = [
            'icon' => 'info',
            'name' => 'Panduan Menu',
            'path' => '/panduan-menu',
        ];

        return $items;
    }

    public static function getMenuGroups()
    {
        $groups = [
            ['title' => 'Menu', 'items' => self::getMainNavItems()],
        ];

        $others = self::getOthersItems();

        if (!empty($others)) {
            $groups[] = ['title' => 'Admin', 'items' => $others];
        }

        return $groups;
    }

    public static function isActive($path)
    {
        $currentPath = '/' . ltrim(request()->path(), '/');
        $path = '/' . ltrim($path, '/');

        if ($path === '/') return $currentPath === '/';

        return str_starts_with($currentPath, $path);
    }

    private static function canAny($user, array $permissions): bool
    {
        if (!$user) {
            return false;
        }

        if (method_exists($user, 'isDeveloper') && $user->isDeveloper()) {
            return true;
        }

        try {
            if (method_exists($user, 'hasAnyPermission') && $user->hasAnyPermission($permissions)) {
                return true;
            }

            foreach ($permissions as $permission) {
                if (method_exists($user, 'can') && $user->can($permission)) {
                    return true;
                }
            }
        } catch (Throwable $e) {
            return false;
        }

        return false;
    }

    public static function getIconSvg($iconName)
    {
        $icons = [
            'dashboard' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M4 13.5C4 12.6716 4.67157 12 5.5 12H10.5C11.3284 12 12 12.6716 12 13.5V18.5C12 19.3284 11.3284 20 10.5 20H5.5C4.67157 20 4 19.3284 4 18.5V13.5Z" fill="currentColor" opacity="0.95"/><path d="M12 5.5C12 4.67157 12.6716 4 13.5 4H18.5C19.3284 4 20 4.67157 20 5.5V10.5C20 11.3284 19.3284 12 18.5 12H13.5C12.6716 12 12 11.3284 12 10.5V5.5Z" fill="currentColor" opacity="0.75"/><path d="M4 5.5C4 4.67157 4.67157 4 5.5 4H10.5C11.3284 4 12 4.67157 12 5.5V10.5C12 11.3284 11.3284 12 10.5 12H5.5C4.67157 12 4 11.3284 4 10.5V5.5Z" fill="currentColor" opacity="0.55"/><path d="M12 13.5C12 12.6716 12.6716 12 13.5 12H18.5C19.3284 12 20 12.6716 20 13.5V18.5C20 19.3284 19.3284 20 18.5 20H13.5C12.6716 20 12 19.3284 12 18.5V13.5Z" fill="currentColor" opacity="0.35"/></svg>',
            'ai' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M9 3h6a3 3 0 013 3v2h1a2 2 0 012 2v3a2 2 0 01-2 2h-1v3a3 3 0 01-3 3H9a3 3 0 01-3-3v-3H5a2 2 0 01-2-2V10a2 2 0 012-2h1V6a3 3 0 013-3z" fill="currentColor" opacity="0.9"/><path d="M9.5 10.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM14.5 10.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z" fill="currentColor"/></svg>',
            'forms' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" fill="currentColor" opacity="0.2"/><path d="M8 8h8M8 12h8M8 16h5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
            'ecommerce' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M6 6h15l-2 9H8L6 6z" fill="currentColor" opacity="0.2"/><path d="M6 6h15l-2 9H8L6 6z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M9 20a1 1 0 100-2 1 1 0 000 2zM18 20a1 1 0 100-2 1 1 0 000 2z" fill="currentColor"/><path d="M6 6L5 3H3" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
            'task' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M7 4h10a2 2 0 012 2v14H7a2 2 0 01-2-2V6a2 2 0 012-2z" fill="currentColor" opacity="0.2"/><path d="M8 9h8M8 13h8M8 17h5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
            'authentication' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 2l8 4v6c0 5-3.5 9-8 10C7.5 21 4 17 4 12V6l8-4z" fill="currentColor" opacity="0.2"/><path d="M12 2l8 4v6c0 5-3.5 9-8 10C7.5 21 4 17 4 12V6l8-4z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M9 12l2 2 4-4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
            'attendance' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M7 3.5V6.5M17 3.5V6.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M5 8.5H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M6.5 5H17.5C19.1569 5 20.5 6.34315 20.5 8V18C20.5 19.6569 19.1569 21 17.5 21H6.5C4.84315 21 3.5 19.6569 3.5 18V8C3.5 6.34315 4.84315 5 6.5 5Z" fill="currentColor" opacity="0.16"/><path d="M6.5 5H17.5C19.1569 5 20.5 6.34315 20.5 8V18C20.5 19.6569 19.1569 21 17.5 21H6.5C4.84315 21 3.5 19.6569 3.5 18V8C3.5 6.34315 4.84315 5 6.5 5Z" stroke="currentColor" stroke-width="2"/><path d="M8 14L10.5 16.5L16 11" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
            'wallet' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M5 7h14a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V9a2 2 0 012-2z" fill="currentColor" opacity="0.2"/><path d="M5 7h14a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V9a2 2 0 012-2z" stroke="currentColor" stroke-width="2"/><path d="M16 12h4" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M5 7V6a2 2 0 012-2h10" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
            'book' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M6 4.5C6 3.67157 6.67157 3 7.5 3H18a2 2 0 012 2v13.5a1.5 1.5 0 01-1.5 1.5H8a2 2 0 01-2-2V4.5z" fill="currentColor" opacity="0.18"/><path d="M6 4.5C6 3.67157 6.67157 3 7.5 3H18a2 2 0 012 2v13.5a1.5 1.5 0 01-1.5 1.5H8a2 2 0 01-2-2V4.5z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M8 6.5H16M8 10H16M8 13.5H13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
            'charts' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M5 19V5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M5 19H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M8 16v-5M12 16V8M16 16v-3" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
            'box' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 2l9 5v10l-9 5-9-5V7l9-5z" fill="currentColor" opacity="0.2"/><path d="M12 2l9 5v10l-9 5-9-5V7l9-5z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M12 22V12" stroke="currentColor" stroke-width="2"/><path d="M21 7l-9 5-9-5" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></svg>',
            'database' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 3c4.418 0 8 1.343 8 3s-3.582 3-8 3-8-1.343-8-3 3.582-3 8-3z" fill="currentColor" opacity="0.25"/><path d="M4 6v6c0 1.657 3.582 3 8 3s8-1.343 8-3V6" stroke="currentColor" stroke-width="2"/><path d="M4 12v6c0 1.657 3.582 3 8 3s8-1.343 8-3v-6" stroke="currentColor" stroke-width="2"/></svg>',
            'cart' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M7 6h14l-1.5 8.5H8.2L7 6z" fill="currentColor" opacity="0.2"/><path d="M7 6h14l-1.5 8.5H8.2L7 6z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M7 6L6 3H3" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M9 20a1 1 0 100-2 1 1 0 000 2zM18 20a1 1 0 100-2 1 1 0 000 2z" fill="currentColor"/></svg>',
            'receipt' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M7 3h10v18l-2-1-2 1-2-1-2 1-2-1-2 1V3z" fill="currentColor" opacity="0.2"/><path d="M7 3h10v18l-2-1-2 1-2-1-2 1-2-1-2 1V3z" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M9 8h6M9 12h6M9 16h4" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
            'settings' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 15.5a3.5 3.5 0 110-7 3.5 3.5 0 010 7z" fill="currentColor" opacity="0.9"/><path d="M19.4 13a7.9 7.9 0 000-2l2-1.2-2-3.5-2.3.7a8.2 8.2 0 00-1.7-1L15 3h-6l-.4 2.7a8.2 8.2 0 00-1.7 1l-2.3-.7-2 3.5L4.6 11a7.9 7.9 0 000 2l-2 1.2 2 3.5 2.3-.7a8.2 8.2 0 001.7 1L9 21h6l.4-2.7a8.2 8.2 0 001.7-1l2.3.7 2-3.5L19.4 13z" fill="currentColor" opacity="0.25"/></svg>',
            'user-profile' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 12a4 4 0 100-8 4 4 0 000 8z" fill="currentColor" opacity="0.9"/><path d="M4 20a8 8 0 0116 0" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
            'info' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z" fill="currentColor" opacity="0.18"/><path d="M12 10v6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/><path d="M12 7.25h.01" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"/></svg>',
        ];

        $fallback = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z" stroke="currentColor" stroke-width="2" opacity="0.6"/><path d="M8 12h8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>';

        return $icons[$iconName] ?? $fallback;
    }
}
