<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\ShopController;
use App\Http\Controllers\CartController;
use App\Http\Controllers\OrderController;
// use App\Http\Controllers\ProfileController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\Admin\CustomerController;
use App\Http\Controllers\CategoriesController;
use App\Http\Controllers\SearchController;
use App\Http\Controllers\BlogController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\CheckoutController;
use App\Http\Controllers\AccountController;
// use App\Http\Controllers\WishlistController;


use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\Auth\ResetPasswordController;
use App\Http\Controllers\SiteMapController;

// Add this with your other use statements at the top
use App\Http\Controllers\Admin\ShippingZoneController;
use App\Http\Controllers\Admin\ShippingMethodController;
use App\Http\Controllers\Admin\ShippingRateController;
use App\Http\Controllers\ShippingController;
use App\Http\Controllers\Admin\ExpenseController;
use App\Http\Controllers\Admin\ExpenseCategoryController;

use App\Http\Controllers\Admin\PermissionController;
use App\Http\Controllers\Admin\RoleController;
use App\Http\Controllers\Admin\UserController;
use App\Http\Controllers\Admin\TaxRateController;
use App\Http\Controllers\Admin\ChangePasswordController;

// Public Routes
Route::get('/', [HomeController::class, 'index'])->name('home');
Route::get('/search', [ProductController::class, 'search'])->name('search');
Route::get('/categories', [CategoryController::class, 'index'])->name('categories.index');
Route::get('/categories/{category:slug}', [CategoryController::class, 'show'])->name('categories.show');
Route::get('/subcategories/{subcategory:slug}', [CategoryController::class, 'showSubcategory'])->name('subcategories.show');
Route::get('/cart/index', [CartController::class, 'index'])->name('cart.index');
Route::get('/orders/track', [OrderController::class, 'track'])->name('order.track');
Route::get('/orders/{order:tracking_number}', [OrderController::class,'show'])->name('order.show');

// Frontend Category Routes
Route::get('/category/{slug}', [App\Http\Controllers\CategoryController::class, 'show'])
    ->name('category.show');
Route::get('/category/{category}/{subcategory}', [App\Http\Controllers\CategoryController::class, 'showSubcategory'])
    ->name('subcategory.show');
 

Route::get('/contact', [ContactController::class, 'index'])->name('contact');
Route::post('/contact/submit', [ContactController::class, 'submit'])->name('contact.submit');
Route::get('/about', [HomeController::class, 'about'])->name('about');
Route::get('/faq', [HomeController::class, 'faq'])->name('faq');
Route::get('/shipping-policy', [HomeController::class, 'shippingPolicy'])->name('shipping.policy');
Route::get('/return-policy', [HomeController::class, 'returnPolicy'])->name('return.policy');
Route::get('/privacy-policy', [HomeController::class, 'privacyPolicy'])->name('privacy.policy');
Route::get('/terms-of-service', [HomeController::class, 'termsOfService'])->name('terms.service');

// Add these routes
Route::get('/products/{product}/quick-view', [ProductController::class, 'quickView'])->name('products.quickView');
// Route::post('/wishlist/toggle/{product}', [WishlistController::class, 'toggle'])->name('wishlist.toggle');

Route::get('/products/offers', [ProductController::class, 'offers'])->name('products.offers');

// Route::get('/blog', [BlogController::class, 'index'])->name('blog.index');
// Route::get('/blog/{post}', [BlogController::class, 'show'])->name('blog.show');

Route::group(['middleware' => ['web']], function () {
    Route::post('/cart/add/{product}', [CartController::class, 'add'])->name('cart.add');
    Route::get('/cart/count', [CartController::class, 'getCount'])->name('cart.count');
    Route::post('/cart/update/{productId}', [CartController::class, 'update'])->name('cart.update');
    Route::delete('/cart/remove/{productId}', [CartController::class, 'remove'])->name('cart.remove');
    Route::post('/cart/empty', [CartController::class, 'empty'])->name('cart.empty');
});



// Add these routes with your existing routes
Route::get('/products/index', [ProductController::class, 'index'])->name('products.index');
Route::get('/products/{id}', [ProductController::class, 'show'])->name('products.show');


// Authentication Routes
Route::middleware('guest')->group(function () {
    Route::get('/login', [App\Http\Controllers\Auth\LoginController::class, 'showLoginForm'])->name('login');
    Route::post('/login', [App\Http\Controllers\Auth\LoginController::class, 'login']);
    Route::get('/register', [App\Http\Controllers\Auth\RegisterController::class, 'showRegistrationForm'])->name('register');
    Route::post('/register', [App\Http\Controllers\Auth\RegisterController::class, 'register']);
    Route::get('/forgot-password', [App\Http\Controllers\Auth\ForgotPasswordController::class, 'showLinkRequestForm'])->name('password.request');
    Route::post('/forgot-password', [App\Http\Controllers\Auth\ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email');
    Route::get('/reset-password/{token}', [App\Http\Controllers\Auth\ResetPasswordController::class, 'showResetForm'])->name('password.reset');
    Route::post('/reset-password', [App\Http\Controllers\Auth\ResetPasswordController::class, 'reset'])->name('password.update');

    // Route::get('/checkout/guest', [CheckoutController::class, 'guestCheckout'])->name('checkout.guest');
    // Route::post('/checkout/guest', [CheckoutController::class, 'processGuestCheckout'])->name('checkout.guest.process');

    // Checkout Routes
   // Keep only one set of checkout routes
   Route::get('/checkout/guest', [CheckoutController::class, 'guestCheckout'])->name('checkout.guest');
   Route::post('/checkout/guest/process', [CheckoutController::class, 'processGuestCheckout'])->name('checkout.guest.process');
   
});


Route::post('/shipping/zones-and-rates', [App\Http\Controllers\ShippingController::class, 'getZonesAndRates'])->name('shipping.zones-and-rates');
Route::post('/shipping/calculate', [ShippingController::class, 'calculateRates'])->name('shipping.calculate');

Route::get('/checkout/success/{order}', [CheckoutController::class, 'success'])->name('checkout.success');

// Route::post('/checkout/calculate-tax', [CheckoutController::class, 'calculateTax'])->name('checkout.calculate-tax');


Route::post('/checkout/update-tax', [CheckoutController::class, 'updateTax'])->name('checkout.update-tax');



// Order details route
Route::get('/orders/{order}', [App\Http\Controllers\OrderController::class, 'show'])->name('orders.show');

Route::post('/process-payment', [CheckoutController::class, 'processPayment']);

// Redirect /expenses to admin expenses
Route::get('/expenses', function () {
    return redirect('/admin/expenses');
});

// Protected Routes
Route::middleware(['auth'])->group(function () {
    //::post('/logout', [LoginController::class, 'logout'])->name('logout');

    Route::get('/account/dashboard', [AccountController::class, 'index'])->name('account.dashboard');

    Route::post('/logout', [App\Http\Controllers\Auth\LoginController::class, 'logout'])->name('logout');

    Route::get('/account/orders/{order}', [AccountController::class, 'showOrder'])->name('account.orders.show');
    // Checkout
    // Route::get('/checkout', [CartController::class, 'checkout'])->name('checkout');
    // Route::post('/checkout/process', [CartController::class, 'processCheckout'])->name('checkout.process');
    Route::get('/checkout', [CheckoutController::class, 'checkout'])->name('checkout');
    Route::post('/checkout/process', [CheckoutController::class, 'processCheckout'])->name('checkout.process');
    
    // Orders
    // Route::get('/orders', [OrderController::class, 'index'])->name('orders');
    // Route::get('/order/{id}', [OrderController::class, 'show'])->name('order.show');

    Route::get('/account/orders', [AccountController::class, 'orders'])->name('account.orders');
    
    // Profile
    // Route::get('/profile', [ProfileController::class, 'index'])->name('profile');
    // Route::post('/profile/update', [ProfileController::class, 'update'])->name('profile.update');
    // Route::get('/profile/change-password', [ProfileController::class, 'changePassword'])->name('profile.password');
    // Route::post('/profile/update-password', [ProfileController::class, 'updatePassword'])->name('profile.password.update');


    Route::get('/account', [App\Http\Controllers\AccountController::class, 'index'])->name('account');
    Route::get('/account/wishlist', [App\Http\Controllers\AccountController::class, 'wishlist'])->name('account.wishlist');
    Route::get('/account/addresses', [App\Http\Controllers\AccountController::class, 'addresses'])->name('account.addresses');
    Route::post('/account/addresses', [App\Http\Controllers\AccountController::class, 'storeAddress'])->name('account.addresses.store');
    Route::put('/account/addresses/{address}', [App\Http\Controllers\AccountController::class, 'updateAddress'])->name('account.addresses.update');
    Route::delete('/account/addresses/{address}', [App\Http\Controllers\AccountController::class, 'deleteAddress'])->name('account.addresses.delete');
    Route::get('/account/settings', [App\Http\Controllers\AccountController::class, 'settings'])->name('account.settings');
    Route::post('/account/settings', [App\Http\Controllers\AccountController::class, 'updateSettings'])->name('account.settings.update');
    Route::post('/account/password', [App\Http\Controllers\AccountController::class, 'updatePassword'])->name('account.password.update');
    // Route::delete('/wishlist/remove/{product}', [WishlistController::class, 'remove'])->name('wishlist.remove');

});


Route::get('/blog', [App\Http\Controllers\PostController::class, 'index'])->name('blog.index');
Route::get('/blog/category/{slug}', [App\Http\Controllers\PostController::class, 'category'])->name('blog.category');
Route::get('/blog/tag/{slug}', [App\Http\Controllers\PostController::class, 'tag'])->name('blog.tag');
Route::get('/blog/{slug}', [App\Http\Controllers\PostController::class, 'show'])->name('blog.show');

// Route::prefix('admin')->group(function () {
//     Route::get('login', [App\Http\Controllers\Admin\AuthController::class, 'showLoginForm'])->name('admin.login');
//     Route::post('login', [App\Http\Controllers\Admin\AuthController::class, 'login']);
//     Route::post('logout', [App\Http\Controllers\Admin\AuthController::class, 'logout'])->name('admin.logout');

//     // Protected admin routes
//     Route::middleware(['auth:admin'])->group(function () {
//         Route::get('/', function () {
//             return redirect()->route('admin.dashboard');
//         });
//         Route::get('dashboard', [App\Http\Controllers\Admin\DashboardController::class, 'index'])->name('admin.dashboard');
//         // Add other admin routes here
//     });
// });
Route::get('/order/track', [App\Http\Controllers\OrderController::class, 'trackForm'])->name('order.track.form');
Route::post('/track-order', [App\Http\Controllers\OrderController::class, 'trackOrder'])->name('order.track.submit');


Route::prefix('admin')->group(function () {
    // Guest admin routes
    Route::middleware('guest:admin')->group(function () {
        Route::get('login', [App\Http\Controllers\Admin\AuthController::class, 'showLoginForm'])->name('admin.login');
        Route::post('login', [App\Http\Controllers\Admin\AuthController::class, 'login']);
    });

    // Protected admin routes
    Route::middleware(['auth:admin'])->group(function () {
        Route::get('/', function () {
            return redirect()->route('admin.dashboard');
        });
        Route::get('dashboard', [App\Http\Controllers\Admin\DashboardController::class, 'index'])->name('admin.dashboard');
        
        // Products Management
        // Categories
        Route::get('/categories', [App\Http\Controllers\Admin\CategoryController::class, 'index'])->name('admin.categories.index');
        Route::get('/categories/create', [App\Http\Controllers\Admin\CategoryController::class, 'create'])->name('admin.categories.create');
        Route::post('/categories', [App\Http\Controllers\Admin\CategoryController::class, 'store'])->name('admin.categories.store');
        Route::get('/categories/{category}/edit', [App\Http\Controllers\Admin\CategoryController::class, 'edit'])->name('admin.categories.edit');
        Route::put('/categories/{category}', [App\Http\Controllers\Admin\CategoryController::class, 'update'])->name('admin.categories.update');
        Route::delete('/categories/{category}', [App\Http\Controllers\Admin\CategoryController::class, 'destroy'])->name('admin.categories.destroy');
    
        // Subcategories
        Route::get('/subcategories', [App\Http\Controllers\Admin\SubcategoryController::class, 'index'])->name('admin.subcategories.index');
        Route::get('/subcategories/create', [App\Http\Controllers\Admin\SubcategoryController::class, 'create'])->name('admin.subcategories.create');
        Route::post('/subcategories', [App\Http\Controllers\Admin\SubcategoryController::class, 'store'])->name('admin.subcategories.store');
        Route::get('/subcategories/{subcategory}/edit', [App\Http\Controllers\Admin\SubcategoryController::class, 'edit'])->name('admin.subcategories.edit');
        Route::put('/subcategories/{subcategory}', [App\Http\Controllers\Admin\SubcategoryController::class, 'update'])->name('admin.subcategories.update');
        Route::delete('/subcategories/{subcategory}', [App\Http\Controllers\Admin\SubcategoryController::class, 'destroy'])->name('admin.subcategories.destroy');

        // Products Routes
        Route::get('/products', [App\Http\Controllers\Admin\ProductController::class, 'index'])->name('admin.products.index');
        Route::get('/products/create', [App\Http\Controllers\Admin\ProductController::class, 'create'])->name('admin.products.create');
        Route::post('/products', [App\Http\Controllers\Admin\ProductController::class, 'store'])->name('admin.products.store');
        Route::get('/products/{product}/edit', [App\Http\Controllers\Admin\ProductController::class, 'edit'])->name('admin.products.edit');
        Route::put('/products/{product}', [App\Http\Controllers\Admin\ProductController::class, 'update'])->name('admin.products.update');
        Route::delete('/products/{product}', [App\Http\Controllers\Admin\ProductController::class, 'destroy'])->name('admin.products.destroy');
        Route::get('/products/inventory', [App\Http\Controllers\Admin\ProductController::class, 'inventory'])->name('admin.products.inventory');
        Route::post('/products/{product}/add-stock', [App\Http\Controllers\Admin\ProductController::class, 'addStock'])
    ->name('admin.products.add-stock');

    // Add this with your other admin routes
        Route::delete('products/images/{image}', [App\Http\Controllers\Admin\ProductController::class, 'deleteImage'])
        ->name('admin.products.images.delete');


        Route::get('/orders', [App\Http\Controllers\Admin\OrderController::class, 'index'])->name('admin.orders.index');
        Route::get('/orders/{order}', [App\Http\Controllers\Admin\OrderController::class, 'show'])->name('admin.orders.show');
        // Route::patch('/orders/{order}/status', [App\Http\Controllers\Admin\OrderController::class, 'updateStatus'])->name('admin.orders.update-status');
        Route::patch('/orders/{order}/status', [App\Http\Controllers\Admin\OrderController::class, 'updateStatus'])
        ->name('admin.orders.update.status');
        Route::get('/export', [App\Http\Controllers\Admin\OrderController::class, 'export'])->name('admin.orders.export');
        // Customers Management
       
         // Customer routes
        Route::get('/customers', [CustomerController::class, 'index'])->name('admin.customers.index');
        Route::get('/customers/{customer}', [CustomerController::class, 'show'])->name('admin.customers.show');
        Route::get('/reviews', [CustomerController::class, 'reviews'])->name('admin.customers.reviews');
        Route::post('/reviews/{review}/toggle-status', [CustomerController::class, 'toggleReviewStatus'])
            ->name('admin.customers.reviews.toggle-status');
        Route::delete('/reviews/{review}', [CustomerController::class, 'deleteReview'])
            ->name('admin.customers.reviews.delete');



            // Shipping Zones Routes
    Route::get('/shipping/zones', [App\Http\Controllers\Admin\ShippingZoneController::class, 'index'])->name('admin.shipping.zones.index');
    Route::get('/shipping/zones/create', [App\Http\Controllers\Admin\ShippingZoneController::class, 'create'])->name('admin.shipping.zones.create');
    Route::post('/shipping/zones', [App\Http\Controllers\Admin\ShippingZoneController::class, 'store'])->name('admin.shipping.zones.store');
    Route::get('/shipping/zones/{zone}/edit', [App\Http\Controllers\Admin\ShippingZoneController::class, 'edit'])->name('admin.shipping.zones.edit');
    Route::put('/shipping/zones/{zone}', [App\Http\Controllers\Admin\ShippingZoneController::class, 'update'])->name('admin.shipping.zones.update');
    Route::delete('/shipping/zones/{zone}', [App\Http\Controllers\Admin\ShippingZoneController::class, 'destroy'])->name('admin.shipping.zones.destroy');
    
    // Shipping Rates Routes (nested under zones)
    Route::get('/shipping/zones/{zone}/rates', [App\Http\Controllers\Admin\ShippingRateController::class, 'index'])->name('admin.shipping.zones.rates.index');
    Route::get('/shipping/zones/{zone}/rates/create', [App\Http\Controllers\Admin\ShippingRateController::class, 'create'])->name('admin.shipping.zones.rates.create');
    Route::post('/shipping/zones/{zone}/rates', [App\Http\Controllers\Admin\ShippingRateController::class, 'store'])->name('admin.shipping.zones.rates.store');
    Route::get('/shipping/zones/{zone}/rates/{rate}/edit', [App\Http\Controllers\Admin\ShippingRateController::class, 'edit'])->name('admin.shipping.zones.rates.edit');
    Route::put('/shipping/zones/{zone}/rates/{rate}', [App\Http\Controllers\Admin\ShippingRateController::class, 'update'])->name('admin.shipping.zones.rates.update');
    Route::delete('/shipping/zones/{zone}/rates/{rate}', [App\Http\Controllers\Admin\ShippingRateController::class, 'destroy'])->name('admin.shipping.zones.rates.destroy');


        // Promotions Routes
    // Coupons
        Route::get('/coupons', [App\Http\Controllers\Admin\CouponController::class, 'index'])
        ->name('admin.promotions.coupons.index');
        Route::get('/coupons/create', [App\Http\Controllers\Admin\CouponController::class, 'create'])
        ->name('admin.promotions.coupons.create');
        Route::post('/coupons', [App\Http\Controllers\Admin\CouponController::class, 'store'])
            ->name('admin.promotions.coupons.store');
        Route::get('/coupons/{coupon}/edit', [App\Http\Controllers\Admin\CouponController::class, 'edit'])
            ->name('admin.promotions.coupons.edit');
        Route::put('/coupons/{coupon}', [App\Http\Controllers\Admin\CouponController::class, 'update'])
            ->name('admin.promotions.coupons.update');
        Route::delete('/coupons/{coupon}', [App\Http\Controllers\Admin\CouponController::class, 'destroy'])
            ->name('admin.promotions.coupons.destroy');

        // Discounts
        Route::get('/discounts', [App\Http\Controllers\Admin\DiscountController::class, 'index'])
            ->name('admin.promotions.discounts.index');
        Route::get('/discounts/create', [App\Http\Controllers\Admin\DiscountController::class, 'create'])
            ->name('admin.promotions.discounts.create');
        Route::post('/discounts', [App\Http\Controllers\Admin\DiscountController::class, 'store'])
            ->name('admin.promotions.discounts.store');
        Route::get('/discounts/{discount}/edit', [App\Http\Controllers\Admin\DiscountController::class, 'edit'])
            ->name('admin.promotions.discounts.edit');
        Route::put('/discounts/{discount}', [App\Http\Controllers\Admin\DiscountController::class, 'update'])
            ->name('admin.promotions.discounts.update');
        Route::delete('/discounts/{discount}', [App\Http\Controllers\Admin\DiscountController::class, 'destroy'])
            ->name('admin.promotions.discounts.destroy');
            
        // Settings
        // Route::get('settings', [App\Http\Controllers\Admin\SettingController::class, 'index'])->name('admin.settings');
        // Route::post('settings', [App\Http\Controllers\Admin\SettingController::class, 'update'])->name('admin.settings.update');


        Route::get('/settings/general', [App\Http\Controllers\Admin\SettingsController::class, 'general'])->name('admin.settings.general');
        Route::get('/settings/shipping', [App\Http\Controllers\Admin\SettingsController::class, 'shipping'])->name('admin.settings.shipping');
        Route::get('/settings/payment', [App\Http\Controllers\Admin\SettingsController::class, 'payment'])->name('admin.settings.payment');
        Route::post('/settings/{type}', [App\Http\Controllers\Admin\SettingsController::class, 'update'])->name('admin.settings.update');


        Route::get('/pages', [App\Http\Controllers\Admin\PageController::class, 'index'])->name('admin.pages.index');
        Route::get('/pages/create', [App\Http\Controllers\Admin\PageController::class, 'create'])->name('admin.pages.create');
        Route::post('/pages/store', [App\Http\Controllers\Admin\PageController::class, 'store'])->name('admin.pages.store');
        Route::get('/pages/{page}/edit', [App\Http\Controllers\Admin\PageController::class, 'edit'])->name('admin.pages.edit');
        Route::put('/pages/{page}/update', [App\Http\Controllers\Admin\PageController::class, 'update'])->name('admin.pages.update');
        Route::delete('/pages/{page}/delete', [App\Http\Controllers\Admin\PageController::class, 'destroy'])->name('admin.pages.destroy');
    
        // Banners
        Route::get('/banners', [App\Http\Controllers\Admin\BannerController::class, 'index'])->name('admin.banners.index');
        Route::get('/banners/create', [App\Http\Controllers\Admin\BannerController::class, 'create'])->name('admin.banners.create');
        Route::post('/banners/store', [App\Http\Controllers\Admin\BannerController::class, 'store'])->name('admin.banners.store');
        Route::get('/banners/{banner}/edit', [App\Http\Controllers\Admin\BannerController::class, 'edit'])->name('admin.banners.edit');
        Route::put('/banners/{banner}/update', [App\Http\Controllers\Admin\BannerController::class, 'update'])->name('admin.banners.update');
        Route::delete('/banners/{banner}/delete', [App\Http\Controllers\Admin\BannerController::class, 'destroy'])->name('admin.banners.destroy');

        
               // Blog Posts
               Route::get('/blog', [App\Http\Controllers\Admin\BlogController::class, 'index'])->name('admin.blog.index');
               Route::get('/blog/create', [App\Http\Controllers\Admin\BlogController::class, 'create'])->name('admin.blog.create');
               Route::post('/blog', [App\Http\Controllers\Admin\BlogController::class, 'store'])->name('admin.blog.store');
               Route::get('/blog/{blog}/edit', [App\Http\Controllers\Admin\BlogController::class, 'edit'])->name('admin.blog.edit');
               Route::put('/blog/{blog}', [App\Http\Controllers\Admin\BlogController::class, 'update'])->name('admin.blog.update');
               Route::delete('/blog/{blog}', [App\Http\Controllers\Admin\BlogController::class, 'destroy'])->name('admin.blog.destroy');
    
        // Blog Categories
        Route::get('/blog/categories', [App\Http\Controllers\Admin\BlogCategoryController::class, 'index'])->name('admin.blog-categories.index');
        Route::get('/blog-categories/create', [App\Http\Controllers\Admin\BlogCategoryController::class, 'create'])->name('admin.blog-categories.create');
        Route::post('/blog-categories', [App\Http\Controllers\Admin\BlogCategoryController::class, 'store'])->name('admin.blog-categories.store');
        Route::get('/blog-categories/{category}/edit', [App\Http\Controllers\Admin\BlogCategoryController::class, 'edit'])->name('admin.blog-categories.edit');
        Route::put('/blog-categories/{category}', [App\Http\Controllers\Admin\BlogCategoryController::class, 'update'])->name('admin.blog-categories.update');
        Route::delete('/blog-categories/{category}', [App\Http\Controllers\Admin\BlogCategoryController::class, 'destroy'])->name('admin.blog-categories.destroy');
        
        // Blog Tags
        Route::get('/tags', [App\Http\Controllers\Admin\TagController::class, 'index'])->name('admin.tags.index');
        Route::get('/tags/create', [App\Http\Controllers\Admin\TagController::class, 'create'])->name('admin.tags.create');
        Route::post('/tags', [App\Http\Controllers\Admin\TagController::class, 'store'])->name('admin.tags.store');
        Route::get('/tags/{tag}/edit', [App\Http\Controllers\Admin\TagController::class, 'edit'])->name('admin.tags.edit');
        Route::put('/tags/{tag}', [App\Http\Controllers\Admin\TagController::class, 'update'])->name('admin.tags.update');
        Route::delete('/tags/{tag}', [App\Http\Controllers\Admin\TagController::class, 'destroy'])->name('admin.tags.destroy');


        ///APIs

        Route::get('/categories/{category}/subcategories', [App\Http\Controllers\Admin\CategoryController::class, 'getSubcategories'])
        ->name('categories.subcategories');

                // Shipping Methods Routes
                Route::get('/shipping/methods', [ShippingMethodController::class, 'index'])->name('admin.shipping.methods.index');
                Route::get('/shipping/methods/create', [ShippingMethodController::class, 'create'])->name('admin.shipping.methods.create');
                Route::post('/shipping/methods', [ShippingMethodController::class, 'store'])->name('admin.shipping.methods.store');
                Route::get('/shipping/methods/{method}/edit', [ShippingMethodController::class, 'edit'])->name('admin.shipping.methods.edit');
                Route::put('/shipping/methods/{method}', [ShippingMethodController::class, 'update'])->name('admin.shipping.methods.update');
                Route::delete('/shipping/methods/{method}', [ShippingMethodController::class, 'destroy'])->name('admin.shipping.methods.destroy');
        
                // Shipping Rates (redirect to zones, since rates are per-zone)
                Route::get('/shipping/rates', function () {
                    return redirect()->route('admin.shipping.zones.index');
                })->name('admin.shipping.rates.index');

                // Shipping Calculation Route
                Route::post('/shipping/calculate', [ShippingRateController::class, 'calculateRate'])->name('admin.shipping.calculate');

        
        Route::prefix('reports')->name('admin.reports.')->group(function () {
            Route::get('/sales', [App\Http\Controllers\Admin\ReportController::class, 'sales'])->name('sales');
            Route::get('/revenue', [App\Http\Controllers\Admin\ReportController::class, 'revenue'])->name('revenue');
            Route::get('/transactions', [App\Http\Controllers\Admin\ReportController::class, 'transactions'])->name('transactions');
            Route::get('/expenses', [App\Http\Controllers\Admin\ReportController::class, 'expenses'])->name('expenses');
            Route::get('/disbursements', [App\Http\Controllers\Admin\ReportController::class, 'disbursements'])->name('disbursements');
            
            // API endpoints for AJAX calls
            Route::get('/sales/data', [App\Http\Controllers\Admin\ReportController::class, 'getSalesData'])->name('sales.data');
            Route::get('/revenue/data', [App\Http\Controllers\Admin\ReportController::class, 'getRevenueData'])->name('revenue.data');
            Route::get('/transactions/data', [App\Http\Controllers\Admin\ReportController::class, 'getTransactionData'])->name('transactions.data');
            Route::get('/expenses/data', [App\Http\Controllers\Admin\ReportController::class, 'getExpenseData'])->name('expenses.data');
        });

        //Route::resource('expenses', ExpenseController::class);
        Route::get('/expense-categories', [ExpenseCategoryController::class, 'index'])->name('admin.expense-categories.index');
        Route::get('/expense-categories/create', [ExpenseCategoryController::class, 'create'])->name('admin.expense-categories.create');
        Route::post('/expense-categories', [ExpenseCategoryController::class, 'store'])->name('admin.expense-categories.store');
        Route::get('/expense-categories/{category}/edit', [ExpenseCategoryController::class, 'edit'])->name('admin.expense-categories.edit');
        Route::put('/expense-categories/{category}', [ExpenseCategoryController::class, 'update'])->name('admin.expense-categories.update');
        Route::delete('/expense-categories/{category}', [ExpenseCategoryController::class, 'destroy'])->name('admin.expense-categories.destroy');
    
        // Expenses
        Route::get('/expenses', [ExpenseController::class, 'index'])->name('admin.expenses.index');
        Route::get('/expenses/create', [ExpenseController::class, 'create'])->name('admin.expenses.create');
        Route::post('/expenses', [ExpenseController::class, 'store'])->name('admin.expenses.store');
        Route::get('/expenses/{expense}/edit', [ExpenseController::class, 'edit'])->name('admin.expenses.edit');
        Route::put('/expenses/{expense}', [ExpenseController::class, 'update'])->name('admin.expenses.update');
        Route::delete('/expenses/{expense}', [ExpenseController::class, 'destroy'])->name('admin.expenses.destroy');

                // Brand Management
        Route::get('/brands', [App\Http\Controllers\Admin\BrandController::class, 'index'])->name('admin.brands.index');
        Route::get('/brands/create', [App\Http\Controllers\Admin\BrandController::class, 'create'])->name('admin.brands.create');
        Route::post('/brands', [App\Http\Controllers\Admin\BrandController::class, 'store'])->name('admin.brands.store');
        Route::get('/brands/{brand}/edit', [App\Http\Controllers\Admin\BrandController::class, 'edit'])->name('admin.brands.edit');
        Route::put('/brands/{brand}', [App\Http\Controllers\Admin\BrandController::class, 'update'])->name('admin.brands.update');
        Route::delete('/brands/{brand}', [App\Http\Controllers\Admin\BrandController::class, 'destroy'])->name('admin.brands.destroy');

        // Review Moderation
        Route::get('/reviews', [App\Http\Controllers\Admin\ReviewController::class, 'index'])->name('admin.reviews.index');
        Route::get('/reviews/{review}', [App\Http\Controllers\Admin\ReviewController::class, 'show'])->name('admin.reviews.show');
        Route::post('/reviews/{review}/approve', [App\Http\Controllers\Admin\ReviewController::class, 'approve'])->name('admin.reviews.approve');
        Route::post('/reviews/{review}/reject', [App\Http\Controllers\Admin\ReviewController::class, 'reject'])->name('admin.reviews.reject');
        Route::delete('/reviews/{review}', [App\Http\Controllers\Admin\ReviewController::class, 'destroy'])->name('admin.reviews.destroy');

        // FAQ Management
        Route::get('/faqs', [App\Http\Controllers\Admin\FaqController::class, 'index'])->name('admin.faqs.index');
        Route::get('/faqs/create', [App\Http\Controllers\Admin\FaqController::class, 'create'])->name('admin.faqs.create');
        Route::post('/faqs', [App\Http\Controllers\Admin\FaqController::class, 'store'])->name('admin.faqs.store');
        Route::get('/faqs/{faq}/edit', [App\Http\Controllers\Admin\FaqController::class, 'edit'])->name('admin.faqs.edit');
        Route::put('/faqs/{faq}', [App\Http\Controllers\Admin\FaqController::class, 'update'])->name('admin.faqs.update');
        Route::delete('/faqs/{faq}', [App\Http\Controllers\Admin\FaqController::class, 'destroy'])->name('admin.faqs.destroy');

        // FAQ Categories
        Route::get('/faq-categories', [App\Http\Controllers\Admin\FaqCategoryController::class, 'index'])->name('admin.faq-categories.index');
        Route::get('/faq-categories/create', [App\Http\Controllers\Admin\FaqCategoryController::class, 'create'])->name('admin.faq-categories.create');
        Route::post('/faq-categories', [App\Http\Controllers\Admin\FaqCategoryController::class, 'store'])->name('admin.faq-categories.store');
        Route::get('/faq-categories/{faqCategory}/edit', [App\Http\Controllers\Admin\FaqCategoryController::class, 'edit'])->name('admin.faq-categories.edit');
        Route::put('/faq-categories/{faqCategory}', [App\Http\Controllers\Admin\FaqCategoryController::class, 'update'])->name('admin.faq-categories.update');
        Route::delete('/faq-categories/{faqCategory}', [App\Http\Controllers\Admin\FaqCategoryController::class, 'destroy'])->name('admin.faq-categories.destroy');

        // Permissions Management
        Route::get('permissions', [PermissionController::class, 'index'])->name('admin.permissions.index');
        Route::get('permissions/create', [PermissionController::class, 'create'])->name('admin.permissions.create');
        Route::post('permissions', [PermissionController::class, 'store'])->name('admin.permissions.store');
        Route::get('permissions/{permission}/edit', [PermissionController::class, 'edit'])->name('admin.permissions.edit');
        Route::put('permissions/{permission}', [PermissionController::class, 'update'])->name('admin.permissions.update');
        Route::delete('permissions/{permission}', [PermissionController::class, 'destroy'])->name('admin.permissions.destroy');

        // Roles Management
        Route::get('roles', [RoleController::class, 'index'])->name('admin.roles.index');
        Route::get('roles/create', [RoleController::class, 'create'])->name('admin.roles.create');
        Route::post('roles', [RoleController::class, 'store'])->name('admin.roles.store');
        Route::get('roles/{role}/edit', [RoleController::class, 'edit'])->name('admin.roles.edit');
        Route::put('roles/{role}', [RoleController::class, 'update'])->name('admin.roles.update');
        Route::delete('roles/{role}', [RoleController::class, 'destroy'])->name('admin.roles.destroy');

        // User Management
        Route::get('users', [UserController::class, 'index'])->name('admin.users.index');
        Route::get('users/create', [UserController::class, 'create'])->name('admin.users.create');
        Route::post('users', [UserController::class, 'store'])->name('admin.users.store');
        Route::get('users/{user}/edit', [UserController::class, 'edit'])->name('admin.users.edit');
        Route::put('users/{user}', [UserController::class, 'update'])->name('admin.users.update');
        Route::delete('users/{user}', [UserController::class, 'destroy'])->name('admin.users.destroy');

        // Role Permissions
        Route::post('roles/{role}/permissions', [RoleController::class, 'updatePermissions'])->name('admin.roles.permissions.update');

        // User Permissions
        Route::get('users/{user}/permissions', [UserController::class, 'permissions'])->name('admin.users.permissions');
        Route::post('users/{user}/permissions', [UserController::class, 'updatePermissions'])->name('admin.users.permissions.update');

        Route::get('/tax-rates', [TaxRateController::class, 'index'])->name('admin.tax-rates.index');
        Route::get('/tax-rates/create', [TaxRateController::class, 'create'])->name('admin.tax-rates.create');
        Route::post('/tax-rates', [TaxRateController::class, 'store'])->name('admin.tax-rates.store');
        Route::get('/tax-rates/{taxRate}/edit', [TaxRateController::class, 'edit'])->name('admin.tax-rates.edit');
        Route::put('/tax-rates/{taxRate}', [TaxRateController::class, 'update'])->name('admin.tax-rates.update');
        Route::delete('/tax-rates/{taxRate}', [TaxRateController::class, 'destroy'])->name('admin.tax-rates.destroy');


        // Returns & Refunds
        Route::get('/returns', [App\Http\Controllers\Admin\ReturnController::class, 'index'])->name('admin.returns.index');
        Route::get('/returns/{return}', [App\Http\Controllers\Admin\ReturnController::class, 'show'])->name('admin.returns.show');
        Route::post('/returns/{return}/update-status', [App\Http\Controllers\Admin\ReturnController::class, 'updateStatus'])->name('admin.returns.update-status');
        Route::delete('/returns/{return}', [App\Http\Controllers\Admin\ReturnController::class, 'destroy'])->name('admin.returns.destroy');

        // Gift Cards
        Route::get('/gift-cards', [App\Http\Controllers\Admin\GiftCardController::class, 'index'])->name('admin.gift-cards.index');
        Route::get('/gift-cards/create', [App\Http\Controllers\Admin\GiftCardController::class, 'create'])->name('admin.gift-cards.create');
        Route::post('/gift-cards', [App\Http\Controllers\Admin\GiftCardController::class, 'store'])->name('admin.gift-cards.store');
        Route::get('/gift-cards/{giftCard}/edit', [App\Http\Controllers\Admin\GiftCardController::class, 'edit'])->name('admin.gift-cards.edit');
        Route::put('/gift-cards/{giftCard}', [App\Http\Controllers\Admin\GiftCardController::class, 'update'])->name('admin.gift-cards.update');
        Route::delete('/gift-cards/{giftCard}', [App\Http\Controllers\Admin\GiftCardController::class, 'destroy'])->name('admin.gift-cards.destroy');

        // Flash Sales
        Route::get('/flash-sales', [App\Http\Controllers\Admin\FlashSaleController::class, 'index'])->name('admin.flash-sales.index');
        Route::get('/flash-sales/create', [App\Http\Controllers\Admin\FlashSaleController::class, 'create'])->name('admin.flash-sales.create');
        Route::post('/flash-sales', [App\Http\Controllers\Admin\FlashSaleController::class, 'store'])->name('admin.flash-sales.store');
        Route::get('/flash-sales/{flashSale}/edit', [App\Http\Controllers\Admin\FlashSaleController::class, 'edit'])->name('admin.flash-sales.edit');
        Route::put('/flash-sales/{flashSale}', [App\Http\Controllers\Admin\FlashSaleController::class, 'update'])->name('admin.flash-sales.update');
        Route::delete('/flash-sales/{flashSale}', [App\Http\Controllers\Admin\FlashSaleController::class, 'destroy'])->name('admin.flash-sales.destroy');

        // Delivery Management
        Route::get('/delivery/men', [App\Http\Controllers\Admin\DeliveryManController::class, 'index'])->name('admin.delivery.men.index');
        Route::get('/delivery/men/create', [App\Http\Controllers\Admin\DeliveryManController::class, 'create'])->name('admin.delivery.men.create');
        Route::post('/delivery/men', [App\Http\Controllers\Admin\DeliveryManController::class, 'store'])->name('admin.delivery.men.store');
        Route::get('/delivery/men/{deliveryMan}/edit', [App\Http\Controllers\Admin\DeliveryManController::class, 'edit'])->name('admin.delivery.men.edit');
        Route::put('/delivery/men/{deliveryMan}', [App\Http\Controllers\Admin\DeliveryManController::class, 'update'])->name('admin.delivery.men.update');
        Route::delete('/delivery/men/{deliveryMan}', [App\Http\Controllers\Admin\DeliveryManController::class, 'destroy'])->name('admin.delivery.men.destroy');

        Route::get('/delivery/drivers', [App\Http\Controllers\Admin\DeliveryDriverController::class, 'index'])->name('admin.delivery.drivers.index');
        Route::get('/delivery/drivers/create', [App\Http\Controllers\Admin\DeliveryDriverController::class, 'create'])->name('admin.delivery.drivers.create');
        Route::post('/delivery/drivers', [App\Http\Controllers\Admin\DeliveryDriverController::class, 'store'])->name('admin.delivery.drivers.store');
        Route::get('/delivery/drivers/{deliveryDriver}/edit', [App\Http\Controllers\Admin\DeliveryDriverController::class, 'edit'])->name('admin.delivery.drivers.edit');
        Route::put('/delivery/drivers/{deliveryDriver}', [App\Http\Controllers\Admin\DeliveryDriverController::class, 'update'])->name('admin.delivery.drivers.update');
        Route::delete('/delivery/drivers/{deliveryDriver}', [App\Http\Controllers\Admin\DeliveryDriverController::class, 'destroy'])->name('admin.delivery.drivers.destroy');

        Route::get('/delivery/zones', [App\Http\Controllers\Admin\DeliveryZoneController::class, 'index'])->name('admin.delivery.zones.index');
        Route::get('/delivery/zones/create', [App\Http\Controllers\Admin\DeliveryZoneController::class, 'create'])->name('admin.delivery.zones.create');
        Route::post('/delivery/zones', [App\Http\Controllers\Admin\DeliveryZoneController::class, 'store'])->name('admin.delivery.zones.store');
        Route::get('/delivery/zones/{deliveryZone}/edit', [App\Http\Controllers\Admin\DeliveryZoneController::class, 'edit'])->name('admin.delivery.zones.edit');
        Route::put('/delivery/zones/{deliveryZone}', [App\Http\Controllers\Admin\DeliveryZoneController::class, 'update'])->name('admin.delivery.zones.update');
        Route::delete('/delivery/zones/{deliveryZone}', [App\Http\Controllers\Admin\DeliveryZoneController::class, 'destroy'])->name('admin.delivery.zones.destroy');

        Route::get('/delivery/slots', [App\Http\Controllers\Admin\DeliverySlotController::class, 'index'])->name('admin.delivery.slots.index');
        Route::get('/delivery/slots/create', [App\Http\Controllers\Admin\DeliverySlotController::class, 'create'])->name('admin.delivery.slots.create');
        Route::post('/delivery/slots', [App\Http\Controllers\Admin\DeliverySlotController::class, 'store'])->name('admin.delivery.slots.store');
        Route::get('/delivery/slots/{deliverySlot}/edit', [App\Http\Controllers\Admin\DeliverySlotController::class, 'edit'])->name('admin.delivery.slots.edit');
        Route::put('/delivery/slots/{deliverySlot}', [App\Http\Controllers\Admin\DeliverySlotController::class, 'update'])->name('admin.delivery.slots.update');
        Route::delete('/delivery/slots/{deliverySlot}', [App\Http\Controllers\Admin\DeliverySlotController::class, 'destroy'])->name('admin.delivery.slots.destroy');

        Route::get('/change-password', [ChangePasswordController::class, 'showChangePasswordForm'])->name('admin.change-password');
        Route::post('/change-password', [ChangePasswordController::class, 'changePassword'])->name('admin.change-password.update');

        // Support Tickets
        Route::get('/support-tickets', [App\Http\Controllers\Admin\SupportTicketController::class, 'index'])->name('admin.support-tickets.index');
        Route::get('/support-tickets/{ticket}', [App\Http\Controllers\Admin\SupportTicketController::class, 'show'])->name('admin.support-tickets.show');
        Route::post('/support-tickets/{ticket}/reply', [App\Http\Controllers\Admin\SupportTicketController::class, 'reply'])->name('admin.support-tickets.reply');
        Route::post('/support-tickets/{ticket}/update-status', [App\Http\Controllers\Admin\SupportTicketController::class, 'updateStatus'])->name('admin.support-tickets.update-status');
        Route::delete('/support-tickets/{ticket}', [App\Http\Controllers\Admin\SupportTicketController::class, 'destroy'])->name('admin.support-tickets.destroy');

        // Newsletter Subscribers
        Route::get('/newsletters', [App\Http\Controllers\Admin\NewsletterController::class, 'index'])->name('admin.newsletters.index');
        Route::delete('/newsletters/{newsletter}', [App\Http\Controllers\Admin\NewsletterController::class, 'destroy'])->name('admin.newsletters.destroy');

        // Product Attributes
        Route::get('/product-attributes', [App\Http\Controllers\Admin\ProductAttributeController::class, 'index'])->name('admin.product-attributes.index');
        Route::get('/product-attributes/create', [App\Http\Controllers\Admin\ProductAttributeController::class, 'create'])->name('admin.product-attributes.create');
        Route::post('/product-attributes', [App\Http\Controllers\Admin\ProductAttributeController::class, 'store'])->name('admin.product-attributes.store');
        Route::get('/product-attributes/{productAttribute}/edit', [App\Http\Controllers\Admin\ProductAttributeController::class, 'edit'])->name('admin.product-attributes.edit');
        Route::put('/product-attributes/{productAttribute}', [App\Http\Controllers\Admin\ProductAttributeController::class, 'update'])->name('admin.product-attributes.update');
        Route::delete('/product-attributes/{productAttribute}', [App\Http\Controllers\Admin\ProductAttributeController::class, 'destroy'])->name('admin.product-attributes.destroy');

        // Product Variations
        Route::get('/product-variations', [App\Http\Controllers\Admin\ProductVariationController::class, 'index'])->name('admin.product-variations.index');
        Route::get('/product-variations/create', [App\Http\Controllers\Admin\ProductVariationController::class, 'create'])->name('admin.product-variations.create');
        Route::post('/product-variations', [App\Http\Controllers\Admin\ProductVariationController::class, 'store'])->name('admin.product-variations.store');
        Route::get('/product-variations/{productVariation}/edit', [App\Http\Controllers\Admin\ProductVariationController::class, 'edit'])->name('admin.product-variations.edit');
        Route::put('/product-variations/{productVariation}', [App\Http\Controllers\Admin\ProductVariationController::class, 'update'])->name('admin.product-variations.update');
        Route::delete('/product-variations/{productVariation}', [App\Http\Controllers\Admin\ProductVariationController::class, 'destroy'])->name('admin.product-variations.destroy');

        // Variation Types
        Route::get('/variation-types', [App\Http\Controllers\Admin\VariationTypeController::class, 'index'])->name('admin.variation-types.index');
        Route::get('/variation-types/create', [App\Http\Controllers\Admin\VariationTypeController::class, 'create'])->name('admin.variation-types.create');
        Route::post('/variation-types', [App\Http\Controllers\Admin\VariationTypeController::class, 'store'])->name('admin.variation-types.store');
        Route::get('/variation-types/{variationType}/edit', [App\Http\Controllers\Admin\VariationTypeController::class, 'edit'])->name('admin.variation-types.edit');
        Route::put('/variation-types/{variationType}', [App\Http\Controllers\Admin\VariationTypeController::class, 'update'])->name('admin.variation-types.update');
        Route::delete('/variation-types/{variationType}', [App\Http\Controllers\Admin\VariationTypeController::class, 'destroy'])->name('admin.variation-types.destroy');

        // Vendors
        Route::get('/vendors', [App\Http\Controllers\Admin\VendorController::class, 'index'])->name('admin.vendors.index');
        Route::get('/vendors/create', [App\Http\Controllers\Admin\VendorController::class, 'create'])->name('admin.vendors.create');
        Route::post('/vendors', [App\Http\Controllers\Admin\VendorController::class, 'store'])->name('admin.vendors.store');
        Route::get('/vendors/{vendor}/edit', [App\Http\Controllers\Admin\VendorController::class, 'edit'])->name('admin.vendors.edit');
        Route::put('/vendors/{vendor}', [App\Http\Controllers\Admin\VendorController::class, 'update'])->name('admin.vendors.update');
        Route::delete('/vendors/{vendor}', [App\Http\Controllers\Admin\VendorController::class, 'destroy'])->name('admin.vendors.destroy');

        // Currencies
        Route::get('/currencies', [App\Http\Controllers\Admin\CurrencyController::class, 'index'])->name('admin.currencies.index');
        Route::get('/currencies/create', [App\Http\Controllers\Admin\CurrencyController::class, 'create'])->name('admin.currencies.create');
        Route::post('/currencies', [App\Http\Controllers\Admin\CurrencyController::class, 'store'])->name('admin.currencies.store');
        Route::get('/currencies/{currency}/edit', [App\Http\Controllers\Admin\CurrencyController::class, 'edit'])->name('admin.currencies.edit');
        Route::put('/currencies/{currency}', [App\Http\Controllers\Admin\CurrencyController::class, 'update'])->name('admin.currencies.update');
        Route::delete('/currencies/{currency}', [App\Http\Controllers\Admin\CurrencyController::class, 'destroy'])->name('admin.currencies.destroy');

        // Languages
        Route::get('/languages', [App\Http\Controllers\Admin\LanguageController::class, 'index'])->name('admin.languages.index');
        Route::get('/languages/create', [App\Http\Controllers\Admin\LanguageController::class, 'create'])->name('admin.languages.create');
        Route::post('/languages', [App\Http\Controllers\Admin\LanguageController::class, 'store'])->name('admin.languages.store');
        Route::get('/languages/{language}/edit', [App\Http\Controllers\Admin\LanguageController::class, 'edit'])->name('admin.languages.edit');
        Route::put('/languages/{language}', [App\Http\Controllers\Admin\LanguageController::class, 'update'])->name('admin.languages.update');
        Route::delete('/languages/{language}', [App\Http\Controllers\Admin\LanguageController::class, 'destroy'])->name('admin.languages.destroy');

        // Store Locations
        Route::get('/store-locations', [App\Http\Controllers\Admin\StoreLocationController::class, 'index'])->name('admin.store-locations.index');
        Route::get('/store-locations/create', [App\Http\Controllers\Admin\StoreLocationController::class, 'create'])->name('admin.store-locations.create');
        Route::post('/store-locations', [App\Http\Controllers\Admin\StoreLocationController::class, 'store'])->name('admin.store-locations.store');
        Route::get('/store-locations/{storeLocation}/edit', [App\Http\Controllers\Admin\StoreLocationController::class, 'edit'])->name('admin.store-locations.edit');
        Route::put('/store-locations/{storeLocation}', [App\Http\Controllers\Admin\StoreLocationController::class, 'update'])->name('admin.store-locations.update');
        Route::delete('/store-locations/{storeLocation}', [App\Http\Controllers\Admin\StoreLocationController::class, 'destroy'])->name('admin.store-locations.destroy');

        // Loyalty Points
        Route::get('/loyalty-points', [App\Http\Controllers\Admin\LoyaltyPointController::class, 'index'])->name('admin.loyalty-points.index');
        Route::get('/loyalty-points/create', [App\Http\Controllers\Admin\LoyaltyPointController::class, 'create'])->name('admin.loyalty-points.create');
        Route::post('/loyalty-points', [App\Http\Controllers\Admin\LoyaltyPointController::class, 'store'])->name('admin.loyalty-points.store');
        Route::delete('/loyalty-points/{loyaltyPoint}', [App\Http\Controllers\Admin\LoyaltyPointController::class, 'destroy'])->name('admin.loyalty-points.destroy');

        // Affiliate Programs
        Route::get('/affiliate-programs', [App\Http\Controllers\Admin\AffiliateProgramController::class, 'index'])->name('admin.affiliate-programs.index');
        Route::get('/affiliate-programs/create', [App\Http\Controllers\Admin\AffiliateProgramController::class, 'create'])->name('admin.affiliate-programs.create');
        Route::post('/affiliate-programs', [App\Http\Controllers\Admin\AffiliateProgramController::class, 'store'])->name('admin.affiliate-programs.store');
        Route::get('/affiliate-programs/{affiliateProgram}/edit', [App\Http\Controllers\Admin\AffiliateProgramController::class, 'edit'])->name('admin.affiliate-programs.edit');
        Route::put('/affiliate-programs/{affiliateProgram}', [App\Http\Controllers\Admin\AffiliateProgramController::class, 'update'])->name('admin.affiliate-programs.update');
        Route::delete('/affiliate-programs/{affiliateProgram}', [App\Http\Controllers\Admin\AffiliateProgramController::class, 'destroy'])->name('admin.affiliate-programs.destroy');

        // Affiliates
        Route::get('/affiliates', [App\Http\Controllers\Admin\AffiliateController::class, 'index'])->name('admin.affiliates.index');
        Route::get('/affiliates/{affiliate}', [App\Http\Controllers\Admin\AffiliateController::class, 'show'])->name('admin.affiliates.show');
        Route::patch('/affiliates/{affiliate}/approve', [App\Http\Controllers\Admin\AffiliateController::class, 'approve'])->name('admin.affiliates.approve');
        Route::delete('/affiliates/{affiliate}', [App\Http\Controllers\Admin\AffiliateController::class, 'destroy'])->name('admin.affiliates.destroy');

        // Subscription Plans
        Route::get('/subscription-plans', [App\Http\Controllers\Admin\SubscriptionPlanController::class, 'index'])->name('admin.subscription-plans.index');
        Route::get('/subscription-plans/create', [App\Http\Controllers\Admin\SubscriptionPlanController::class, 'create'])->name('admin.subscription-plans.create');
        Route::post('/subscription-plans', [App\Http\Controllers\Admin\SubscriptionPlanController::class, 'store'])->name('admin.subscription-plans.store');
        Route::get('/subscription-plans/{subscriptionPlan}/edit', [App\Http\Controllers\Admin\SubscriptionPlanController::class, 'edit'])->name('admin.subscription-plans.edit');
        Route::put('/subscription-plans/{subscriptionPlan}', [App\Http\Controllers\Admin\SubscriptionPlanController::class, 'update'])->name('admin.subscription-plans.update');
        Route::delete('/subscription-plans/{subscriptionPlan}', [App\Http\Controllers\Admin\SubscriptionPlanController::class, 'destroy'])->name('admin.subscription-plans.destroy');

        // Subscriptions (read-only)
        Route::get('/subscriptions', [App\Http\Controllers\Admin\SubscriptionController::class, 'index'])->name('admin.subscriptions.index');

        // Customer Groups
        Route::get('/customer-groups', [App\Http\Controllers\Admin\CustomerGroupController::class, 'index'])->name('admin.customer-groups.index');
        Route::get('/customer-groups/create', [App\Http\Controllers\Admin\CustomerGroupController::class, 'create'])->name('admin.customer-groups.create');
        Route::post('/customer-groups', [App\Http\Controllers\Admin\CustomerGroupController::class, 'store'])->name('admin.customer-groups.store');
        Route::get('/customer-groups/{customerGroup}/edit', [App\Http\Controllers\Admin\CustomerGroupController::class, 'edit'])->name('admin.customer-groups.edit');
        Route::put('/customer-groups/{customerGroup}', [App\Http\Controllers\Admin\CustomerGroupController::class, 'update'])->name('admin.customer-groups.update');
        Route::delete('/customer-groups/{customerGroup}', [App\Http\Controllers\Admin\CustomerGroupController::class, 'destroy'])->name('admin.customer-groups.destroy');

        // Product Bundles
        Route::get('/product-bundles', [App\Http\Controllers\Admin\ProductBundleController::class, 'index'])->name('admin.product-bundles.index');
        Route::get('/product-bundles/create', [App\Http\Controllers\Admin\ProductBundleController::class, 'create'])->name('admin.product-bundles.create');
        Route::post('/product-bundles', [App\Http\Controllers\Admin\ProductBundleController::class, 'store'])->name('admin.product-bundles.store');
        Route::get('/product-bundles/{productBundle}/edit', [App\Http\Controllers\Admin\ProductBundleController::class, 'edit'])->name('admin.product-bundles.edit');
        Route::put('/product-bundles/{productBundle}', [App\Http\Controllers\Admin\ProductBundleController::class, 'update'])->name('admin.product-bundles.update');
        Route::delete('/product-bundles/{productBundle}', [App\Http\Controllers\Admin\ProductBundleController::class, 'destroy'])->name('admin.product-bundles.destroy');

        // Bulk Pricing
        Route::get('/bulk-pricing', [App\Http\Controllers\Admin\BulkPricingController::class, 'index'])->name('admin.bulk-pricing.index');
        Route::get('/bulk-pricing/create', [App\Http\Controllers\Admin\BulkPricingController::class, 'create'])->name('admin.bulk-pricing.create');
        Route::post('/bulk-pricing', [App\Http\Controllers\Admin\BulkPricingController::class, 'store'])->name('admin.bulk-pricing.store');
        Route::get('/bulk-pricing/{bulkPricing}/edit', [App\Http\Controllers\Admin\BulkPricingController::class, 'edit'])->name('admin.bulk-pricing.edit');
        Route::put('/bulk-pricing/{bulkPricing}', [App\Http\Controllers\Admin\BulkPricingController::class, 'update'])->name('admin.bulk-pricing.update');
        Route::delete('/bulk-pricing/{bulkPricing}', [App\Http\Controllers\Admin\BulkPricingController::class, 'destroy'])->name('admin.bulk-pricing.destroy');

        // Product Shipping Classes
        Route::get('/product-shipping-classes', [App\Http\Controllers\Admin\ProductShippingClassController::class, 'index'])->name('admin.product-shipping-classes.index');
        Route::get('/product-shipping-classes/create', [App\Http\Controllers\Admin\ProductShippingClassController::class, 'create'])->name('admin.product-shipping-classes.create');
        Route::post('/product-shipping-classes', [App\Http\Controllers\Admin\ProductShippingClassController::class, 'store'])->name('admin.product-shipping-classes.store');
        Route::get('/product-shipping-classes/{productShippingClass}/edit', [App\Http\Controllers\Admin\ProductShippingClassController::class, 'edit'])->name('admin.product-shipping-classes.edit');
        Route::put('/product-shipping-classes/{productShippingClass}', [App\Http\Controllers\Admin\ProductShippingClassController::class, 'update'])->name('admin.product-shipping-classes.update');
        Route::delete('/product-shipping-classes/{productShippingClass}', [App\Http\Controllers\Admin\ProductShippingClassController::class, 'destroy'])->name('admin.product-shipping-classes.destroy');

        // Admin Activities
        Route::get('/admin-activities', [App\Http\Controllers\Admin\AdminActivityController::class, 'index'])->name('admin.admin-activities.index');
        Route::get('/admin-activities/{adminActivity}', [App\Http\Controllers\Admin\AdminActivityController::class, 'show'])->name('admin.admin-activities.show');

        // System Backups
        Route::get('/system-backups', [App\Http\Controllers\Admin\SystemBackupController::class, 'index'])->name('admin.system-backups.index');
        Route::get('/system-backups/create', [App\Http\Controllers\Admin\SystemBackupController::class, 'create'])->name('admin.system-backups.create');
        Route::get('/system-backups/{systemBackup}', [App\Http\Controllers\Admin\SystemBackupController::class, 'show'])->name('admin.system-backups.show');
        Route::delete('/system-backups/{systemBackup}', [App\Http\Controllers\Admin\SystemBackupController::class, 'destroy'])->name('admin.system-backups.destroy');

        // Payment Gateways
        Route::get('/payment-gateways', [App\Http\Controllers\Admin\PaymentGatewayController::class, 'index'])->name('admin.payment-gateways.index');
        Route::get('/payment-gateways/create', [App\Http\Controllers\Admin\PaymentGatewayController::class, 'create'])->name('admin.payment-gateways.create');
        Route::post('/payment-gateways', [App\Http\Controllers\Admin\PaymentGatewayController::class, 'store'])->name('admin.payment-gateways.store');
        Route::get('/payment-gateways/{paymentGateway}/edit', [App\Http\Controllers\Admin\PaymentGatewayController::class, 'edit'])->name('admin.payment-gateways.edit');
        Route::put('/payment-gateways/{paymentGateway}', [App\Http\Controllers\Admin\PaymentGatewayController::class, 'update'])->name('admin.payment-gateways.update');
        Route::delete('/payment-gateways/{paymentGateway}', [App\Http\Controllers\Admin\PaymentGatewayController::class, 'destroy'])->name('admin.payment-gateways.destroy');

        // Payment Transactions
        Route::get('/payment-transactions', [App\Http\Controllers\Admin\PaymentTransactionController::class, 'index'])->name('admin.payment-transactions.index');
        Route::get('/payment-transactions/{paymentTransaction}', [App\Http\Controllers\Admin\PaymentTransactionController::class, 'show'])->name('admin.payment-transactions.show');

        // Email Templates
        Route::get('/email-templates', [App\Http\Controllers\Admin\EmailTemplateController::class, 'index'])->name('admin.email-templates.index');
        Route::get('/email-templates/create', [App\Http\Controllers\Admin\EmailTemplateController::class, 'create'])->name('admin.email-templates.create');
        Route::post('/email-templates', [App\Http\Controllers\Admin\EmailTemplateController::class, 'store'])->name('admin.email-templates.store');
        Route::get('/email-templates/{emailTemplate}/edit', [App\Http\Controllers\Admin\EmailTemplateController::class, 'edit'])->name('admin.email-templates.edit');
        Route::put('/email-templates/{emailTemplate}', [App\Http\Controllers\Admin\EmailTemplateController::class, 'update'])->name('admin.email-templates.update');
        Route::delete('/email-templates/{emailTemplate}', [App\Http\Controllers\Admin\EmailTemplateController::class, 'destroy'])->name('admin.email-templates.destroy');

        // Email Logs
        Route::get('/email-logs', [App\Http\Controllers\Admin\EmailLogController::class, 'index'])->name('admin.email-logs.index');

        // Inventory Alerts
        Route::get('/inventory-alerts', [App\Http\Controllers\Admin\InventoryAlertController::class, 'index'])->name('admin.inventory-alerts.index');
        Route::get('/inventory-alerts/{inventoryAlert}', [App\Http\Controllers\Admin\InventoryAlertController::class, 'show'])->name('admin.inventory-alerts.show');
        Route::patch('/inventory-alerts/{inventoryAlert}/resolve', [App\Http\Controllers\Admin\InventoryAlertController::class, 'resolve'])->name('admin.inventory-alerts.resolve');
        Route::delete('/inventory-alerts/{inventoryAlert}', [App\Http\Controllers\Admin\InventoryAlertController::class, 'destroy'])->name('admin.inventory-alerts.destroy');

        Route::post('logout', [App\Http\Controllers\Admin\AuthController::class, 'logout'])->name('admin.logout');
    });
});


// Site Map Routes
Route::get('/sitemap', [SitemapController::class, 'index'])->name('sitemap');

// Authentication Routes
Auth::routes();