<?php
/**
 * Features Section Template
 *
 * @package Logistics Express
 */

$logistics_express_section_features = get_theme_mod('logistics_express_section_features_enable');
if ('Disable' === $logistics_express_section_features) {
    return;
}

// Check if any feature has data
$has_content = false;
for ($i = 1; $i <= 3; $i++) {
    $title = get_theme_mod("logistics_express_feature_title_$i", '');
    $text  = get_theme_mod("logistics_express_feature_text_$i", '');
    if (!empty($title) || !empty($text)) {
        $has_content = true;
        break;
    }
}

if (!$has_content) {
    return; // No features to display
}
?>

<section class="features-section">
    <div class="container">
        <div class="row">
            <?php for ($i = 1; $i <= 3; $i++) : ?>
                <?php
                $title = get_theme_mod("logistics_express_feature_title_$i", '');
                $text  = get_theme_mod("logistics_express_feature_text_$i", '');
                if (empty($title) && empty($text)) {
                    continue; // Skip empty feature box
                }
                ?>
                <div class="col-md-4">
                    <div class="feature-box fade-in">
                        <?php if (!empty($title)) : ?>
                            <h3 class="slide-up"><?php echo esc_html($title); ?></h3>
                        <?php endif; ?>
                        
                        <?php if (!empty($text)) : ?>
                            <p class="fade-in"><?php echo esc_html($text); ?></p>
                        <?php endif; ?>
                    </div>
                </div>
            <?php endfor; ?>
        </div>
    </div>
</section>
