<?php
$class = isset($args['class']) ? $args['class'] : '';
?>

<section class="section bonded-warehouse-benefits <?php echo $class; ?>">
    <div class="container">
        <div class="text-cont">
            <h2 class="section-title text-center">
                <?php echo get_field('bonded_warehouse_benefits_section_title'); ?>
            </h2>
            <p class="section-content text-center">
                <?php echo get_field('bonded_warehouse_benefits_section_text'); ?>
            </p>
        </div>

        <div class="bonded-warehouse-benefits-wrapper">
            <?php if( have_rows('bonded_warehouse_benefits_section_cards') ): ?>
                <?php $cards = 1; ?>
                <div class="row gy-4">
                    <?php while( have_rows('bonded_warehouse_benefits_section_cards') ): the_row(); ?>
                        
                        <?php if($cards == 1): ?>
                            <!-- First card left column -->
                            <div class="col-lg-12 col-xl-4">
                                <div class="bonded-warehouse-benefits-card">
                                    <div class="d-flex flex-column justify-content-end h-100">
                                        <div class="svg-wrapper">
                                            <?php echo get_sub_field('bonded_warehouse_benefits_section_cards__icon'); ?>
                                        </div>
                                        <div class="text-cont">
                                            <h2 class="bonded-warehouse-benefits-title">
                                                <?php echo get_sub_field('bonded_warehouse_benefits_section_cards__title'); ?>
                                            </h2>
                                            <p class="bonded-warehouse-benefits-content">
                                                <?php echo get_sub_field('bonded_warehouse_benefits_section_cards__text'); ?>
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- right column wrapper -->
                            <div class="col-lg-12 col-xl-8">
                                <div class="row gy-4">
                        <?php else: ?>
                            <!-- Other cards in right column -->
                            <div class="col-lg-12 col-xl-6">
                                <div class="bonded-warehouse-benefits-card secure-handling-benefit">
                                    <div class="svg-wrapper">
                                        <?php echo get_sub_field('bonded_warehouse_benefits_section_cards__icon'); ?>
                                    </div>
                                    <div class="text-cont">
                                        <h2 class="bonded-warehouse-benefits-title">
                                            <?php echo get_sub_field('bonded_warehouse_benefits_section_cards__title'); ?>
                                        </h2>
                                        <p class="bonded-warehouse-benefits-content">
                                            <?php echo get_sub_field('bonded_warehouse_benefits_section_cards__text'); ?>
                                        </p>
                                    </div>
                                </div>
                            </div>
                        <?php endif; ?>

                        <?php $cards++; ?>
                    <?php endwhile; ?>
                                </div>
                            </div>
                </div>
            <?php endif; ?>
        </div>
    </div>
</section>
