<?php
/**
 * Empty cart page
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/cart/cart-empty.php.
 *
 * @see     https://woocommerce.com/document/template-structure/
 * @package Pawfect
 * @version 10.9.1
 */

defined( 'ABSPATH' ) || exit;

/*
 * @hooked wc_empty_cart_message - 10
 */
do_action( 'woocommerce_cart_is_empty' );

// Get recent products to display
$recent_products = wc_get_products(array(
    'limit' => 4,
    'status' => 'publish',
    'visibility' => 'catalog'
));

// Get the product card style from theme options
$card_style = get_theme_mod('pawfect_shop_card_style', 'modern');
?>

<div class="pawfect-empty-cart-products pawfect-mt-12">
    <h3 class="pawfect-text-2xl pawfect-font-bold pawfect-text-center pawfect-mb-8 pawfect-text-gray-800"><?php echo esc_html__( 'New in store', 'pawfect' ); ?></h3>
    
    <?php if (!empty($recent_products)): ?>
        <div class="pawfect-grid pawfect-grid-cols-2 md:pawfect-grid-cols-4 pawfect-gap-6">
            <?php foreach ($recent_products as $product): ?>
                <div class="pawfect-product-item pawfect-group pawfect-shop-card-<?php echo esc_attr($card_style); ?>">
                    <?php if ($card_style === 'modern'): ?>
                        <!-- Modern Product Card (Shop by Category Style) -->
                        <div class="pawfect-category-card pawfect-group pawfect-relative pawfect-bg-white pawfect-rounded-2xl pawfect-shadow-sm pawfect-border pawfect-border-gray-100 pawfect-overflow-hidden pawfect-transition-all pawfect-duration-500 hover:pawfect-shadow-lg hover:pawfect-scale-[1.02]">
                            
                            <a href="<?php echo esc_url( $product->get_permalink() ); ?>" class=" pawfect-relative pawfect-z-10">
                                <!-- Product Image -->
                                <div class="pawfect-relative pawfect-h-48 pawfect-bg-gray-100 pawfect-overflow-hidden">
                                    <?php echo wp_kses_post( $product->get_image('woocommerce_thumbnail', [
                                        'class' => 'pawfect-w-full pawfect-h-full pawfect-object-cover pawfect-transition-all pawfect-duration-700 group-hover:pawfect-scale-110'
                                    ]) ); ?>

                                    <!-- Sale Badge -->
                                    <?php if ($product->is_on_sale()): ?>
                                        <div class="pawfect-absolute pawfect-top-3 pawfect-right-3 pawfect-bg-red-500 pawfect-text-white pawfect-text-xs pawfect-font-bold pawfect-px-2 pawfect-py-1 pawfect-rounded-full pawfect-z-10">
                                            <?php esc_html_e( 'SALE', 'pawfect' ); ?>
                                        </div>
                                    <?php endif; ?>
                                </div>

                                <!-- Product Info -->
                                <div class="pawfect-p-4">
                                    <h3 class="pawfect-font-semibold pawfect-text-lg pawfect-text-gray-900 pawfect-mb-2 pawfect-line-clamp-2 group-hover:pawfect-text-pawfect-primary pawfect-transition-colors">
                                        <?php echo esc_html( $product->get_name() ); ?>
                                    </h3>
                                    
                                    <div class="pawfect-flex pawfect-items-center pawfect-justify-between pawfect-mb-3">
                                        <span class="pawfect-text-xl pawfect-font-bold pawfect-text-pawfect-primary">
                                            <?php echo wp_kses_post( $product->get_price_html() ); ?>
                                        </span>
                                    </div>
                                </div>
                            </a>

                            <!-- Add to Cart Button -->
                            <div class="pawfect-p-4 pawfect-pt-0">
                                <?php
                                woocommerce_template_loop_add_to_cart(array(
                                    'class' => 'pawfect-btn pawfect-w-full pawfect-text-center'
                                ));
                                ?>
                            </div>
                        </div>

                    <?php elseif ($card_style === 'classic'): ?>
                        <!-- Classic Product Card -->
                        <div class="pawfect-feature-card pawfect-bg-white pawfect-rounded-xl pawfect-shadow-md pawfect-overflow-hidden pawfect-transition-all pawfect-duration-300 hover:pawfect-shadow-lg hover:pawfect-scale-105">
                            
                            <a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="pawfect-block">
                                <!-- Product Image -->
                                <div class="pawfect-relative pawfect-h-48 pawfect-bg-gray-100 pawfect-overflow-hidden">
                                    <?php echo wp_kses_post( $product->get_image('woocommerce_thumbnail', [
                                        'class' => 'pawfect-w-full pawfect-h-full pawfect-object-cover pawfect-transition-transform pawfect-duration-700 group-hover:pawfect-scale-110'
                                    ]) ); ?>

                                    <!-- Sale Badge -->
                                    <?php if ($product->is_on_sale()): ?>
                                        <div class="pawfect-absolute pawfect-top-3 pawfect-right-3 pawfect-bg-red-500 pawfect-text-white pawfect-text-xs pawfect-font-bold pawfect-px-2 pawfect-py-1 pawfect-rounded-full">
                                            <?php esc_html_e( 'SALE', 'pawfect' ); ?>
                                        </div>
                                    <?php endif; ?>
                                </div>

                                <!-- Product Info -->
                                <div class="pawfect-p-4">
                                    <h3 class="pawfect-font-semibold pawfect-text-lg pawfect-text-gray-900 pawfect-mb-2 pawfect-line-clamp-2">
                                        <?php echo esc_html( $product->get_name() ); ?>
                                    </h3>
                                    
                                    <div class="pawfect-text-xl pawfect-font-bold pawfect-text-pawfect-primary pawfect-mb-3">
                                        <?php echo wp_kses_post( $product->get_price_html() ); ?>
                                    </div>

                                    <!-- Add to Cart Button -->
                                    <?php
                                    woocommerce_template_loop_add_to_cart(array(
                                        'class' => 'pawfect-btn pawfect-w-full pawfect-text-center'
                                    ));
                                    ?>
                                </div>
                            </a>
                        </div>

                    <?php else: ?>
                        <!-- Minimal Product Card -->
                        <div class="pawfect-feature-card pawfect-bg-white pawfect-rounded-lg pawfect-border pawfect-border-gray-200 pawfect-overflow-hidden pawfect-transition-all pawfect-duration-300 hover:pawfect-border-pawfect-primary hover:pawfect-shadow-md">
                            
                            <a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="pawfect-block">
                                <!-- Product Image -->
                                <div class="pawfect-relative pawfect-h-48 pawfect-bg-gray-50 pawfect-overflow-hidden">
                                    <?php echo wp_kses_post( $product->get_image('woocommerce_thumbnail', [
                                        'class' => 'pawfect-w-full pawfect-h-full pawfect-object-cover pawfect-transition-transform pawfect-duration-500 group-hover:pawfect-scale-105'
                                    ]) ); ?>

                                    <!-- Sale Badge -->
                                    <?php if ($product->is_on_sale()): ?>
                                        <div class="pawfect-absolute pawfect-top-2 pawfect-right-2 pawfect-bg-red-500 pawfect-text-white pawfect-text-xs pawfect-font-bold pawfect-px-2 pawfect-py-1 pawfect-rounded">
                                            <?php esc_html_e( 'SALE', 'pawfect' ); ?>
                                        </div>
                                    <?php endif; ?>
                                </div>

                                <!-- Product Info -->
                                <div class="pawfect-p-4">
                                    <h3 class="pawfect-font-medium pawfect-text-gray-900 pawfect-mb-2 pawfect-line-clamp-2">
                                        <?php echo esc_html( $product->get_name() ); ?>
                                    </h3>
                                    
                                    <div class="pawfect-text-lg pawfect-font-bold pawfect-text-pawfect-primary pawfect-mb-3">
                                        <?php echo wp_kses_post( $product->get_price_html() ); ?>
                                    </div>

                                    <!-- Add to Cart Button -->
                                    <?php
                                    woocommerce_template_loop_add_to_cart(array(
                                        'class' => 'pawfect-btn pawfect-w-full pawfect-text-center'
                                    ));
                                    ?>
                                </div>
                            </a>
                        </div>
                    <?php endif; ?>
                </div>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
</div>

<?php if ( wc_get_page_id( 'shop' ) > 0 ) : ?>
    <p class="return-to-shop pawfect-text-center pawfect-mt-8">
        <a class="pawfect-btn" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
            <?php echo esc_html( apply_filters( 'woocommerce_return_to_shop_text', __( 'Return to shop', 'pawfect' ) ) ); ?>
        </a>
    </p>
<?php endif; ?>

