import { createRouter, createWebHistory } from 'vue-router'
import LoginView from '../views/LoginView.vue'
import HomeView from '../views/HomeView.vue'
import CartView from '../views/CartView.vue'
import OrdersView from '../views/OrdersView.vue'
import FavoritesView from '../views/FavoritesView.vue'
import ProfileView from '../views/ProfileView.vue'

// Admin Layout & Pages
import AdminLayout from '../views/admin/AdminLayout.vue'
import AdminOverview from '../views/admin/AdminOverview.vue'
import AdminOrders from '../views/admin/AdminOrders.vue'
import AdminRisk from '../views/admin/AdminRisk.vue'
import AdminProducts from '../views/admin/AdminProducts.vue'
import AdminAudit from '../views/admin/AdminAudit.vue'
import AdminUsers from '../views/admin/AdminUsers.vue'
import AdminBanners from '../views/admin/AdminBanners.vue'
import AdminReviews from '../views/admin/AdminReviews.vue'
import AdminLogistics from '../views/admin/AdminLogistics.vue'
import AdminInventory from '../views/admin/AdminInventory.vue'
import AdminProfile from '../views/admin/AdminProfile.vue'

// Merchant Layout & Pages
import MerchantLayout from '../views/merchant/MerchantLayout.vue'
import MerchantOverview from '../views/merchant/MerchantOverview.vue'
import MerchantProducts from '../views/merchant/MerchantProducts.vue'
import MerchantOrders from '../views/merchant/MerchantOrders.vue'
import MerchantReviews from '../views/merchant/MerchantReviews.vue'
import MerchantLogistics from '../views/merchant/MerchantLogistics.vue'
import MerchantInventory from '../views/merchant/MerchantInventory.vue'
import MerchantProfile from '../views/merchant/MerchantProfile.vue'

const routes = [
  { path: '/', redirect: '/products' },
  { path: '/products', component: HomeView },
  { path: '/cart', component: CartView },
  { path: '/orders', component: OrdersView },
  { path: '/favorites', component: FavoritesView },
  { path: '/profile', component: ProfileView },
  { path: '/login', component: LoginView },
  { path: '/customer', redirect: '/products' },
  
  // Admin Routes
  {
    path: '/admin',
    component: AdminLayout,
    redirect: '/admin/overview',
    children: [
      { path: 'overview', name: 'admin-overview', component: AdminOverview },
      { path: 'orders', name: 'admin-orders', component: AdminOrders },
      { path: 'risk', name: 'admin-risk', component: AdminRisk },
      { path: 'products', name: 'admin-products', component: AdminProducts },
      { path: 'audit', name: 'admin-audit', component: AdminAudit },
      { path: 'users', name: 'admin-users', component: AdminUsers },
      { path: 'banners', name: 'admin-banners', component: AdminBanners },
      { path: 'reviews', name: 'admin-reviews', component: AdminReviews },
      { path: 'logistics', name: 'admin-logistics', component: AdminLogistics },
      { path: 'inventory', name: 'admin-inventory', component: AdminInventory },
      { path: 'profile', name: 'admin-profile', component: AdminProfile }
    ]
  },
  
  // Merchant Routes
  {
    path: '/merchant',
    component: MerchantLayout,
    redirect: '/merchant/overview',
    children: [
      { path: 'overview', name: 'merchant-overview', component: MerchantOverview },
      { path: 'products', name: 'merchant-products', component: MerchantProducts },
      { path: 'orders', name: 'merchant-orders', component: MerchantOrders },
      { path: 'reviews', name: 'merchant-reviews', component: MerchantReviews },
      { path: 'logistics', name: 'merchant-logistics', component: MerchantLogistics },
      { path: 'inventory', name: 'merchant-inventory', component: MerchantInventory },
      { path: 'profile', name: 'merchant-profile', component: MerchantProfile }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router