<?php
/**
 * Plantilla de Checkout "Frisbee" v4.0 - Rediseño basado en imagen
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

add_filter( 'body_class', function( $classes ) {
    $classes[] = 'ckfylt25-template-frisbee';
    return $classes;
});
?>

<div class="ckfylt25-frisbee-wrapper">
    <!-- Barra de Advertencia -->
    <div class="ckfylt25-frisbee-alert-bar">
        <div class="alert-content">
            <span class="alert-arrow">←</span>
            <span class="alert-text"><?php echo esc_html__( 'Important: Order now limited supply...', 'checkoutify-lite' ); ?></span>
            <span class="alert-arrow">→</span>
        </div>
    </div>

    <div class="ckfylt25-frisbee-container">
        <form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
            
            <main class="ckfylt25-frisbee-main">
                <!-- Contact Information -->
                <div class="ckfylt25-frisbee-section">
                    <h3><?php esc_html_e( 'Contact Information', 'checkoutify-lite' ); ?></h3>
                    <?php do_action( 'woocommerce_checkout_billing' ); ?>
                </div>

                <!-- Método de Envío -->
                <div class="ckfylt25-frisbee-section">
                    <h3><?php esc_html_e( 'Shipping Method', 'checkoutify-lite' ); ?></h3>
                    <div id="custom_shipping_methods_placeholder" class="shipping-methods">
                        <!-- Los métodos de envío se cargarán aquí via JavaScript -->
                    </div>
                </div>

                <!-- Pago -->
                <div class="ckfylt25-frisbee-section">
                    <h3><?php esc_html_e( 'Payment', 'checkoutify-lite' ); ?></h3>
                    <p class="payment-notice"><?php echo esc_html__( 'All transactions are secure and encrypted.', 'checkoutify-lite' ); ?></p>
                    
                    <!-- Order Bump -->
                    <?php do_action('ckfylt25_before_testimonials'); ?>
                    
                    <div id="payment" class="woocommerce-checkout-payment">
                        <?php do_action( 'woocommerce_checkout_payment' ); ?>
                    </div>
                    
                    <p class="privacy-notice"><?php echo esc_html__( 'Your personal data will be used to process your order, support your experience throughout this website, and for other purposes described in our privacy policy.', 'checkoutify-lite' ); ?></p>
                    
                    <div class="guarantee-section">
                        <p class="guarantee-notice"><?php echo esc_html__( 'We respect your Privacy & Information', 'checkoutify-lite' ); ?></p>
                        <div class="guarantee-badges">
                            <div class="guarantee-badge">
                                <div class="badge-icon">✓</div>
                                <div class="badge-content">
                                    <strong><?php echo esc_html__( 'Money-Back Guaranteed', 'checkoutify-lite' ); ?></strong>
                                    <span><?php echo esc_html__( 'No hassle money back just contact us', 'checkoutify-lite' ); ?></span>
                                </div>
                            </div>
                            <div class="guarantee-badge">
                                <div class="badge-icon">✓</div>
                                <div class="badge-content">
                                    <strong><?php echo esc_html__( 'Secure Processing', 'checkoutify-lite' ); ?></strong>
                                    <span><?php echo esc_html__( '256-bit encryption, secure order processing', 'checkoutify-lite' ); ?></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </main>

            <!-- Sidebar con Resumen del Pedido -->
            <aside class="ckfylt25-frisbee-sidebar">
                <div class="ckfylt25-frisbee-cart-summary">
                    <h3><?php esc_html_e( 'Order summary', 'checkoutify-lite' ); ?></h3>
                    <div class="ckfylt25-frisbee-product-list">
                        <?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) :
                            $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
                            if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) : ?>
                                <div class="ckfylt25-cart-item">
                                    <div class="ckfylt25-cart-item__image">
                                        <?php echo wp_kses_post(apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image('thumbnail'), $cart_item, $cart_item_key )); ?>
                                    </div>
                                    <div class="ckfylt25-cart-item__details">
                                        <span class="ckfylt25-cart-item__name"><?php echo wp_kses_post( $_product->get_name() ); ?></span>
                                        <span class="ckfylt25-cart-item__quantity"><?php echo wp_kses_post(sprintf( '&times; %s', $cart_item['quantity'] )); ?></span>
                                    </div>
                                    <div class="ckfylt25-cart-item__price">
                                        <?php echo wp_kses_post( WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ) ); ?>
                                    </div>
                                </div>
                            <?php endif;
                        endforeach; ?>
                    </div>
                    
                    <!-- Totales -->
                    <div class="cart-totals">
                        <div class="total-row">
                            <span><?php esc_html_e( 'Subtotal', 'checkoutify-lite' ); ?></span>
                            <span class="amount"><?php echo wp_kses_post( WC()->cart->get_cart_subtotal() ); ?></span>
                        </div>
                        <div class="total-row">
                            <span><?php esc_html_e( 'Shipping', 'checkoutify-lite' ); ?></span>
                            <span class="amount" id="cart-shipping"><?php echo wp_kses_post( wc_cart_totals_shipping_html() ); ?></span>
                        </div>
                        <div class="total-row total-final">
                            <span><?php esc_html_e( 'Total', 'checkoutify-lite' ); ?></span>
                            <span class="amount"><?php echo wp_kses_post( WC()->cart->get_total() ); ?></span>
                        </div>
                    </div>
                    
                    <!-- Beneficios -->
                    <div class="benefits-section">
                        <h4><?php echo esc_html__( "Here's what you get", 'checkoutify-lite' ); ?></h4>
                        <ul class="benefits-list">
                            <li>
                                <span class="benefit-icon">✓</span>
                                <span><?php echo esc_html__( 'Money Back Guarantee - We stand behind our products with confidence', 'checkoutify-lite' ); ?></span>
                            </li>
                            <li>
                                <span class="benefit-icon">✓</span>
                                <span><?php echo esc_html__( 'Fast & Secure Processing - Your order is protected with bank-level security', 'checkoutify-lite' ); ?></span>
                            </li>
                            <li>
                                <span class="benefit-icon">✓</span>
                                <span><?php echo esc_html__( 'Full Support - We provide high quality post purchase support for all our customers', 'checkoutify-lite' ); ?></span>
                            </li>
                        </ul>
                    </div>
                </div>
                
                <!-- Order Review oculto para que WooCommerce pueda renderizar los métodos de envío -->
                <div id="order_review" class="woocommerce-checkout-review-order" style="opacity: 0; position: absolute; left: -9999px; pointer-events: none;">
                    <?php do_action( 'woocommerce_checkout_order_review' ); ?>
                </div>
            </aside>
        </form>
    </div>
    
</div>
