package id.iiyh.inatrading.navigation

import android.net.Uri
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.outlined.Explore
import androidx.compose.material.icons.outlined.Home
import androidx.compose.material.icons.outlined.Inventory2
import androidx.compose.material.icons.outlined.Person
import androidx.compose.ui.graphics.vector.ImageVector
import id.iiyh.inatrading.R

sealed class Screen(val route: String) {
    // ── Main tabs (dengan BottomNav) ─────────────────────────────────────────
    data object Home    : Screen("home")
    data object Explore : Screen("explore")
    data object Products: Screen("products")
    data object Profile : Screen("profile")

    // ── Inner screens (tanpa BottomNav) ─────────────────────────────────────
    data object Login           : Screen("login")
    data object Register        : Screen("register")
    data object RegisterSuccess : Screen("register_success")
    data object ForgotPassword  : Screen("forgot_password")
    data object NewsList        : Screen("news_list")
    data object About              : Screen("about")
    data object HelpCenter         : Screen("help_center")
    data object TermsConditions    : Screen("terms_conditions")
    data object PrivacyPolicy      : Screen("privacy_policy")
    data object Favorites          : Screen("favorites")
    data object FavoriteGroupDetail: Screen("favorite_group_detail/{groupId}?name={groupName}") {
        fun createRoute(groupId: String, groupName: String) =
            "favorite_group_detail/$groupId?name=${Uri.encode(groupName)}"
    }
    data object NewsDetail         : Screen("news_detail/{newsId}") {
        fun createRoute(newsId: String) = "news_detail/$newsId"
    }
    data object ExploreDetail      : Screen("explore_detail/{locationId}") {
        fun createRoute(locationId: String) = "explore_detail/$locationId"
    }
    data object ProductDetail      : Screen("product_detail/{productId}") {
        fun createRoute(productId: String) = "product_detail/$productId"
    }
    data object Cart               : Screen("cart")
    data object EditProfile        : Screen("edit_profile")
    data object ChangePassword     : Screen("change_password")
    data object ShippingAddresses  : Screen("shipping_addresses")
    data object AddShippingAddress : Screen("shipping_addresses/add")
    data object EditShippingAddress : Screen("shipping_addresses/edit/{addressId}") {
        fun createRoute(addressId: String) = "shipping_addresses/edit/$addressId"
    }
    data object PaymentMethods     : Screen("payment_methods")
    data object OrderDetail        : Screen("order_detail/{orderId}") {
        fun createRoute(orderId: String) = "order_detail/$orderId"
    }
}

/** Tab-tab yang tampil di BottomNav */
val bottomNavItems = listOf(
    BottomNavItem(
        screen       = Screen.Home,
        labelRes     = R.string.nav_home,
        icon         = Icons.Outlined.Home,
        iconSelected = Icons.Outlined.Home,
    ),
    BottomNavItem(
        screen       = Screen.Explore,
        labelRes     = R.string.nav_explore,
        icon         = Icons.Outlined.Explore,
        iconSelected = Icons.Outlined.Explore,
    ),
    BottomNavItem(
        screen       = Screen.Products,
        labelRes     = R.string.nav_products,
        icon         = Icons.Outlined.Inventory2,
        iconSelected = Icons.Outlined.Inventory2,
    ),
    BottomNavItem(
        screen       = Screen.Profile,
        labelRes     = R.string.nav_profile,
        icon         = Icons.Outlined.Person,
        iconSelected = Icons.Filled.Person,
    ),
)

data class BottomNavItem(
    val screen: Screen,
    @StringRes val labelRes: Int,
    val icon: ImageVector,
    val iconSelected: ImageVector,
)

/** Route yang termasuk main screen (tampilkan BottomNav) */
val mainRoutes = setOf(
    Screen.Home.route,
    Screen.Explore.route,
    Screen.Products.route,
    Screen.Profile.route,
)
